• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

audio_play_sound just not working?

T

tamation

Guest
Really strange error here, it's been happening the last few days with this prototype and it's never happened to me before, really confused here.

When trying to play a sound with audio_play_sound, sometimes it just...doesn't work? I'll add a sound called snd_door for example, set it up with the new sound effect, and then when adding audio_play_sound(snd_door,1,false) to a line of code it will just play another completely random sound from the game. I've tried double checking to make sure it's the right sound, I've tried making multiple versions of the same sound under different names, but even when swapping it out with the new sounds under new names it still plays the other sound effect. Sometimes it does this, sometimes it doesn't. Sometimes I'll add a new sound and when I reference it by name, it will just give me a windows error beep, however another previous working sound effect in the game will suddenly be replaced by the new sound, despite not being told to play the new sound in code. It will just replace the sound effect of whatever was previously saved, and trying to reload the old sound from a file will do nothing and it will continue to be bugged and play the new sound but under a different name.

I'm extremely confused and frustrated. Is there anything in options to look out for that I may have selected accidentally that's causing this, or any other solution at all?
 
M

maxdax5

Guest
It never happened to me but is your sound a .wav file or mp3?
 
Have you tried clearing the project cache (use the broom icon) before you run your game? Do the sounds play correctly when you preview them in the IDE?
 

Yal

šŸ§ *penguin noises*
GMC Elder
Sounds like cache corruption. But some other steps worth checking out...
  • Make sure you have the arguments in the right order so you don't accidentally use another argument for the asset reference, that could cause random sounds to play.
  • audio_set_channel_num (or something along those lines) can be used to set how many sounds can play at once, having it too low will cut off low-prio sounds and having it too high can make sounds very loud if a lot happens at once
  • Check the compile log, if a sound file is missing (e.g. import failed, corruption, unsupported format) there will be a message like "can't find sound <name>, using default (windows ding)"
 
Sorry for the bump- but I have found a resolution that may be useful for future readers.

I was having sounds playing fine at the start of the game, but after a certain sequence of events, specific sounds would no longer work (but would return a valid sound id, returned true for "is playing" and had a gain of 1.

It seems to be caused by trying to play some other sound id that doesn't exist. I then see a message like this: "Error: no sound exists for soundid -1074790400" in the console.
From then on, certain sounds that did work before, no longer work. After I resolved this, the issue stopped.

For reference, all my sounds are .wav and are using the "compressed - not streamed" settings.
 

MrOut

Member
"I was having sounds playing fine at the start of the game, but after a certain sequence of events, specific sounds would no longer work (but would return a valid sound id, returned true for "is playing" and had a gain of 1."

I had the exact same problem with my music.

I made a check to relaunch the music when it's done, to avoid to have to play it infinite loop.

But somehow, when I was changing level, the music was stop when a specific object appear (intentionally) but never play again until I used " audio_stop_all() "

So I add a safecheck in my algorythm to stop the relaunch of the music, while before it was launch, then stop in the next few lines of code.
 
Top