OpenAL limit on number of playing sound clips

edited May 2011 in Help request
I'll often want to fire a one-off sound clip, without storing a reference to the sound, or going through any sort of complex audio management:
orxSOUND *foo = orxSound_CreateFromConfig("mysound");
orxSound_Play(foo);

I previously did this on the assumption that the audio resource would be cleared out automatically after playing. However, I'm noticing a bug where, after a certain number of times playing a given sound, I'll get an OpenAL error (in Debug mode), or the sound will stop playing when I call orxSound_Play(). This is regardless of whether or not the sound is marked as KeepInCache in the config files.

Is my assumption incorrect? Is OpenAL crashing because of too many simultaneous-open sounds, and should I manage my sounds after firing them?

Comments

  • edited May 2011
    newton64 wrote:
    I'll often want to fire a one-off sound clip, without storing a reference to the sound, or going through any sort of complex audio management:
    orxSOUND *foo = orxSound_CreateFromConfig("mysound");
    orxSound_Play(foo);
    

    I previously did this on the assumption that the audio resource would be cleared out automatically after playing. However, I'm noticing a bug where, after a certain number of times playing a given sound, I'll get an OpenAL error (in Debug mode), or the sound will stop playing when I call orxSound_Play(). This is regardless of whether or not the sound is marked as KeepInCache in the config files.

    The KeepInCache only relates to the data itself, not to the playing instances.
    Is my assumption incorrect? Is OpenAL crashing because of too many simultaneous-open sounds, and should I manage my sounds after firing them?

    I think you're correct but you don't need to handle your sound, you simply should use a different part of the API for that.

    You can add music/sounds on objects, even empty ones. Objects are really all-purpose containers. If you call orxObject_AddSound() you'll get these advantages:
    - the sound will be managed by orx, ie. stopped/cleared when done or when the object is deleted
    - the sound will get its properties from the object: if you have a clock to do time stretching on an object, the sound playing on it will also time stretch
    - if your sound is mono, it'll use the object's coordinates for spatialization (you can move the microphone directly with the sound API).
    - if the object is disabled, the sound will be muted
    - it's only one line of code, the sound will play directly, hard to do it with less code ;)

    Hope this helps! :)
  • edited June 2011
    Hey iarwain,
    I'using the orxObject_AddSound(). Right after that I call orxObject_GetLastAddedSound() and then I get the sound's position and it is always (0,0,0). I checked the orx code and I didn't see where you get the object's position in order to set the sound position accordingly. Can you verify that? thanks.
  • edited June 2011
    Hi!

    Yes, the sound's position will be updated during the next update (orxObject_UpdateALL()) so a newly added sound won't have the object's position yet.

    I just changed that on the svn: you can now get the expected position from your sound right away, even from the orxSOUND_EVENT_START event handling.
  • edited June 2011
    Thanks for the quick change. But I think you only changed the orxSoundPointer_AddSound() and not the orxSoundPointer_AddSoundFromConfig().
  • edited June 2011
    Indeed! Fixed now. Sorry about that! ^^
Sign In or Register to comment.