I believe I may have stumbled across a small glitch in the Ogg Vorbis audio handler. I don't know if this has been uncovered before; if not, let me know and I'll see if I can track it down in the source code and fix it!
The issue is that audio files that are Ogg formatted seem to ignore the "audio-cache-limit" directive when they are loaded; regardless of the setting in the Config.prc file, they adhere to a "no more than fifteen simultaneously" rule while playing. Don't ask why I was trying to play sixteen Ogg files simultaneously; it's a long story
One viable solution appears to be to force the "audio-cache-limit" setting at the top of your main code body. I'm not sure why, but doing this does seem to allow you to play more than fifteen Oggs simultaneously.
What follows is an example program to demonstrate the issue. To use it, create four sound files that you could distinguish easily while they are simultaneously playing. I used four guitar plucks, each of which starts a second after the last one (so the audio files compare as follows):
- Code: Select all
Now, run the program shown below, and flick your fingers across the "p," "f," "g," "h," and "j" keys. You would expect a five-note sequence: c-c-c-c-c, e-e-e-e-e, g-g-g-g-g, c5-c5-c5-c5-c5. Instead, you're likely to hear c-c-c-c, e-e-e-e, g-g-g-g, c5-c5-c5. Uncommenting the top four lines in the source code will give you the expected sequence.
If someone could double-check my results, I'd appreciate it. Thanks to everyone for their help on this issue!
- Code: Select all
##Uncomment the lines below to get all the notes to play
##from pandac.PandaModules import ConfigVariableInt
##SOUND = ConfigVariableInt("audio-cache-limit")
from direct.showbase import DirectObject
from pandac.PandaModules import *
from direct.task import Task
from direct.actor import Actor
from direct.interval.IntervalGlobal import*
from direct.gui.DirectGui import *
## The sound files you want to load. If these are all oggs, they
## seem to ignore the audio-cache-limit without warning,
## unless the audio-cache-limit directive is specified at the top of
## this file.
for sound in self.sounds:
for aMusic in whichStream:
## Now, press pfghj to hear fifteen notes simultaneously. Uncomment the lines above to hear twenty-five notes simultaneously.