Post anything here that does not fall into the other topic categories.

Possible Sound Issue?

Possible Sound Issue?

Postby Shando » 18 May 2019, 02:09

Hi All,

I'm creating some simple 2D Sounds in my "onInit":

Code: Select all
-- Create Sounds
   sound.setLooped ( 0 )
   sound.setVolume ( 1 )
   sound.setSoundFile ( "success.ogg" )
   sound.setIsStreamed ( 0 )
   sndSuccess = sound.createSound ( )
   sound.setLooped ( 0 )
   sound.setVolume ( 1 )
   sound.setSoundFile ( "failure.ogg" )
   sound.setIsStreamed ( 0 )
   sndFailure = sound.createSound ( )
   sound.setLooped ( 0 )
   sound.setVolume ( 1 )
   sound.setSoundFile ( "selected.ogg" )
   sound.setIsStreamed ( 0 )
   sndSelect = sound.createSound ( )


and then playing them in "onMouseDown" - depending on certain logic:

Code: Select all
if iMatch == 1 then
    sound.play2DSound ( sndSelect )
else
    sound.play2DSound ( sndFailure )
end


The first time each sound plays it works fine, but doesn't seem to play after that? I've tried using

Code: Select all
if sound.isPlaying ( sndFailure ) == 1 then
    sound.stopSound ( sndFailure )
end


but that doesn't seem to make any difference.

Does anyone have any idea what I'm doing wrong (it's been a while since I played with sounds, so please be gentle!)?

Thanks in advance

Shando
Ryzen 7 4800H 16GB GTX1650 Win 11 64
Love, Hope, Strength http://www.lovehopestrength.co.uk
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: Possible Sound Issue?

Postby SolarPortal » 18 May 2019, 12:25

that is because they are self deleting, when you call createsound, pass a 0 in to disable the self deletion but it means you have to clean the sound manually.

Code: Select all
sound.createSound( 0 )
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: Possible Sound Issue?

Postby Shando » 18 May 2019, 23:38

Hi SP,

Thanks for the quick reply :D

How would you recommend handling sounds?

i.e. which is better performance wise:

1) Creating with the '0' and manually deleting; or
2) Recreating the sound each time it's used?

Thanks again.

Shando
Ryzen 7 4800H 16GB GTX1650 Win 11 64
Love, Hope, Strength http://www.lovehopestrength.co.uk
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: Possible Sound Issue?

Postby SolarPortal » 19 May 2019, 01:25

reuse it if possible, creating more sounds will hit a sound limit eventually which needs fixed within the engine :)
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer


Return to Misc

Who is online

Users browsing this forum: No registered users and 6 guests

cron