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?
This sounds like a limitation of OpenAL noted by nexyon here: https://developer.blender.org/T32096 (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?
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.
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.
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?
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
I don’t know if those settings are saved with runtimes (though it’s easy to check),
I don’t know if SDL is adequate in terms of playing sounds on time (last I checked, it was laggy), and
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.
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!