Ogg Vorbis audio: possible hiccup

Hey all!

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 :wink:

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):

c5 ---------------o---
g ------------o-------
e -------o------------
c --o-----------------

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!

-Mark

##Uncomment the lines below to get all the notes to play
##from pandac.PandaModules import ConfigVariableInt
##
##SOUND = ConfigVariableInt("audio-cache-limit")
##SOUND.setValue(40)

import direct.directbase.DirectStart
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 *




class World(DirectObject):

    ## 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.
    sounds=["c.ogg","e.ogg","g.ogg","c5.ogg"]

    
    

    def __init__(self):
        self.loadedMusic=[]
        self.loadedSounds=[]
        self.loadedMusic2=[]
        self.loadedSounds2=[]
        self.loadedSounds3=[]
        for sound in self.sounds:
            s=loader.loadMusic(sound)
            self.loadedMusic.append(s)
            s=loader.loadSfx(sound)
            self.loadedSounds.append(s)
            s=loader.loadMusic(sound)
            self.loadedMusic2.append(s)
            s=loader.loadSfx(sound)
            self.loadedSounds2.append(s)
            s=loader.loadSfx(sound)
            self.loadedSounds3.append(s)

        self.accept("p",self.fireAll,[self.loadedSounds])
        self.accept("f",self.fireAll,[self.loadedMusic])
        self.accept("g",self.fireAll,[self.loadedMusic2])
        self.accept("h",self.fireAll,[self.loadedSounds2])
        self.accept("j",self.fireAll,[self.loadedSounds3])
        
        
    def fireAll(self,whichStream):
        for aMusic in whichStream:
            aMusic.play()

w=World()
run()

## Now, press pfghj to hear fifteen notes simultaneously. Uncomment the lines above to hear twenty-five notes simultaneously.

This may be a silly question, but are you sure that you were editing the Config.prc that Panda was actually reading?

You can start up your application (without setting the config variable in the code) and try:


print ConfigVariableInt("audio-cache-limit")

just to prove that the variable, as read from the Config.prc file, has the value you think it does.

David

D’oh! Excellent suggestion. :blush:

I double-checked the variable in Config.prc, and setting it there did the job. I must have gotten myself confused while testing this initially; maybe I forgot to save Config.prc after editing it.

I think it’s still worth noting, however, that when loading ogg files the “audio cache limit exceeded. Limit is 15” warning did not show up like it normally does with mp3 files. I haven’t gotten a chance to check the code path to see why this might be.

Thank you for spot-checking me on this!

-Mark