Game Over Sound Effect gets worse the further into the game I go

So, the game that I’ve been working on has a two second game over mp3 sound effect that starts playing when my character changes to its “dying” animation, and if I play a random level and then die in that same level, it works just fine.
However, I’ve noticed an issue that occurs the more levels I play. Each scene in my game is its own level. When I complete one level, the scene switches over to the next on. But if I play multiple levels in and then die, something odd happens. If I die after having completed at least two levels prior to the one that I’m playing, the sound is not only delayed, but it also cuts off roughly halfway (and it’s always halfway). I suspect that the latter may have to do with my character being deleted after the death animation is finished, as the sound only plays during the death animation, but I don’t get why the sound is getting delayed. All of my gameplay scenes more or less have the same events, and I can play a preview of any level and then die on it and the sound plays just fine, but if I die after playing two or more levels in a row the sound gets delayed.
This issue has been going on for several months now and I’ve restarted my browser multiple times since then to see if that would help, but nothing has changed.

Any insight on how would be highly appreciated!

Are you preloading the sound in the resource tab?

1 Like

This wouldn’t matter in this case, since upon playing a sound for the first time, it is loaded into memory permanently the same way as preloading does.

Try using .wav for sound effects. And .ogg for music.

MP3s don’t perform as well.

1 Like

Could someone explain the reason for this? I’m curious.

It’s not GD specific, most game devs don’t use mp3s for sound effects. Beyond that I don’t know the specifics, other than .wav is much smaller and more efficient.

1 Like

So, is there any way I can convert an mp3 file to either a wav or and ogg file? I’ve tried seeing if there are any free online ones, but I don’t know if any of them are trustworthy.

Just to double check this isn’t something simple, can you show your actual events to play the game over sound?

Okay, but as mentioned earlier it only happens when I play levels consecutively.

The only thing I could think of from that event is if the MP3 isn’t getting unloaded from memory somehow.

Before you try changing the audio file (freeconvert’s site should work fine), you might try changing from “Play the sound” to “play the sound on a channel” and choose a very low or very high channel number you don’t use for something else. As far as I know “play the sound” puts all audio onto the same channel and maybe there’s some sort of memory leak over time?

Before I try that I just discovered something.
If I don’t start on the scene with the intro to the game, the game over sound plays just fine. The intro has a six second long theme song that plays during it. Could that be what’s causing this, possibly the memory leak that you proposed?