Proper Music system in BGE (to prevent music from stopping after buffer fills)

I’m working on an action game project that’s up to 8 way split screen. There are many explosions, missiles, bullets, collisions, etc. They all have sounds.

There is also music. It plays off a sound actuator in the background.

However, after a certain number of other sounds play (I don’t know the number, I’m hoping I don’t need to) the music stops playing. It simply cuts out. It’s as if a buffer has been filled up and blender is automagically protecting itself from playing too many sounds at once.

Is there a workaround?

Is this something that could be fixed inside of blender itself?

Is there a library I can distribute with my game that allows me to play music outside of bge, so it doesn’t get cut off?

The game will be freeware.

This sounds like a limitation of OpenAL noted by nexyon here: (note, when he first says OpenGL, he means OpenAL). Can you provide an estimate of how many sounds you’re trying to play? More than 32?

what about assigning a “level of importance?” so if over X sounds are playing, and new sound is added stop 1 at lowest priority level?

Have you tried going with the aud module to see if it also has the same problem? Or are you just using logic bricks?

It somehow stops working even if I have only 1 player, but with (1 shoot + 1 hit) x 6players + background music + powerup spawning + explosions, I have 10 simultaneous sounds starting, and they may overlap, easily breaching a 32 sound buffer.

I’m using logic bricks. Objects call a sound module which triggers their sound actuator IF the global volume is “1”
I could probably convert that into an AUD thingy.
I’m just using stereo sounds now because blender has only 1 listener, so it just doesn’t work in surround.

So, I’ll try out the AUD stuff, and see what happens.

I think Blender supports stereo sound. Are your sounds Mono? They have to be Mono for 3D audio to properly work, if I recall.

EDIT: Unless that’s what you meant - I got confused on the “it just doesn’t work in surround” part. Do you mean surround sound as opposed to stereo?

It is a limitation for creative openal for windows (I think that creative openal only can use 16/32 hardware sources). Anyway, if blender could use openal-soft for windows as we use in linux you could use so many sources as you want.

Can each client handle its own sounds, and only play the closest 32?

Yes, you could do a proper system using aud library in python that only uses the 32 closest sounds.

Oh, hey, just to be sure, you don’t have blank space at the end of your sound files, right? Because that would keep the sound playing even if they sound short, and push you closer into the limit than you really need to be. If not, you can use Audacity to clip out unnecessary blank space.

Naa, my audio guy cuts 'em up nicely. There isn’t much tail. It’s just that since I’m having so many sounds at once it’s cutting the music out.

The sounds are mono waves.

The surround issue is
1: Blender doesn’t do surround 7.1 / 5.1 properly in windows anymore.
2: There is only one listener (tagged to the active camera), so 7 of the 8 players would hear nothing unless they were close to the active camera player, or shooting that player.

So, I guess I could take a list of the currently active sounds (except the music) and every time I try to play a new sound, cut out the earliest sound (but not the music) to keep it under the mysterious limit?

Is there a different library I could use to just play music, and keep my logic brick sound system in place?

I think your going to want to use time and distance,

also, one music track played (omni) for music (not unique for each player) right?

Ah, I see. Yeah, you could try that. You could also try tallying the number of sounds you have playing to see exactly how many is the limit - maybe there’s an error or “bad” number of sounds somewhere.

Well, there is SDL and OpenAL in the preferences, but

  1. I don’t know if those settings are saved with runtimes (though it’s easy to check),
  2. I don’t know if SDL is adequate in terms of playing sounds on time (last I checked, it was laggy), and
  3. I don’t know if SDL has any buffer limit either.

You could also try an external Python library like pygame, though it might be awkward to install, and I’m unsure if pygame allows for an infinite number of channels. The default is 8, but it can be changed at will.

What if I were to combine AUD with logic bricks?

It might work, I haven’t tested it. It seems like it may have cut out once, and a few other times, the logic bricks overpowered it, but it was still playing in the background.

I’ll update once I can confirm or deny its status.

I have tried combining AUD and logic bricks. It does not seem solve my problems. The music still cuts out.

I suppose I could try to hack around and make an AUD based thing that is called and somehow keeps the sound count in check… but it seems like a dreadful amount of work. Perhaps I’ll train a monkey to do it for me!

Also you can do:

  • Download OpenAl-Soft DLLs
  • Check for 32 or 64bit folder (depends on your system)
  • Rename the soft_oal.dll to OpenAL32.dll (also the 64bit soft_oal should be rename to OpenAL32.dll)
  • Check in the Blender root directory
  • Move apart the OpenAL32.dll file
  • Copy in this directory the file that you previously have renamed from soft_oal.dll to OpenAL32.dll

This way you will use the OpenAL-Soft implementation which it has not any limit for sound quantity.

I’ll try that! If it works, that’d be amazing!

replacing the DLL didn’t fix it.