audiere and irrlicht

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
saulotmalo
Posts: 54
Joined: Wed Oct 04, 2006 6:56 am

audiere and irrlicht

Post by saulotmalo »

hello I don't know if it is the better location to post so.. sorry if bother. I'm trying to do an audiere an irrlitch integration but when i play 2 sounds at the same time one on them does not play.... can it be helped or it is because the library?

thanks
Luke
Admin
Posts: 449
Joined: Fri Jul 14, 2006 7:55 am
Location: Australia
Contact:

Post by Luke »

I think I had the same problem, I'd like to find out it's possible too.
saulotmalo
Posts: 54
Joined: Wed Oct 04, 2006 6:56 am

Post by saulotmalo »

so you're using another library or are you using this still? i mean i can change the api for me it is the same use audiere or other if other works better.
Warchief
Posts: 204
Joined: Tue Nov 22, 2005 10:58 am

Post by Warchief »

Weird i had no problems with Audiere. Have you opened one stream for each file?
Warchief's Warboard 3D Now hotseat release
saulotmalo
Posts: 54
Joined: Wed Oct 04, 2006 6:56 am

Post by saulotmalo »

No, i've opened only one stream. One for every one will be a lot of work for the pc, don't you think?... or if it is stored in memory it does consume memory or cpu?

UPDATE: I've tried to use a circular buffer and it works but... i think it overhead something :(

for(int p=0;p<10;p++){
sonidos[p]=audiere::OpenSound(sistemaSonido, "test.mp3", false);
Warchief
Posts: 204
Joined: Tue Nov 22, 2005 10:58 am

Post by Warchief »

I did not take care about freeing streams. Think audiere does it (as they are smart pointers).

But if you want to be sure, just register a callback.

Code: Select all

/**
   * To listen for stream stopped events on a device, implement this interface
   * and call registerStopCallback() on the device, passing your
   * implementation.  streamStopped() will be called whenever a stream on that
   * device stops playback.
   *
   * WARNING: StopCallback is called from another thread.  Make sure your
   * callback is thread-safe.
   */
  class StopCallback : public Callback {
  protected:
    ~StopCallback() { }

  public:
    EventType ADR_CALL getType() { return ET_STOP; }
    void ADR_CALL call(Event* event) {
      streamStopped(static_cast<StopEvent*>(event));
    }

    /**
     * Called when a stream has stopped.
     *
     * @param event  Information pertaining to the event.
     */
    ADR_METHOD(void) streamStopped(StopEvent* event) = 0;
  };
  typedef RefPtr<StopCallback> StopCallbackPtr;
Delete the stream when it stops.
Warchief's Warboard 3D Now hotseat release
saulotmalo
Posts: 54
Joined: Wed Oct 04, 2006 6:56 am

Post by saulotmalo »

i think with this it will stop playing the background music :(
Warchief
Posts: 204
Joined: Tue Nov 22, 2005 10:58 am

Post by Warchief »

The event has a member OutputStreamPtr StopEventImpl::m_stream that gives a pointer to the stream that stopped. You should only free that one.
Warchief's Warboard 3D Now hotseat release
saulotmalo
Posts: 54
Joined: Wed Oct 04, 2006 6:56 am

Post by saulotmalo »

Thanks for the help, but in the game that i'm doing actually it runs well like i post before so.. il let it be. But i'll try to understant this way too.

thanks
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Is it a good idea to use only audiere for BGM and IrrKlang for sound effects, etc? That seems to be the best way for me right now...
Warchief
Posts: 204
Joined: Tue Nov 22, 2005 10:58 am

Post by Warchief »

saulotmalo wrote:Thanks for the help, but in the game that i'm doing actually it runs well like i post before so.. il let it be. But i'll try to understant this way too.

thanks
It works, but you may find continuous allocations if you continue loading sounds. Just make sure you store the streams into a container and pick up from there. (For example, allow a maximum of 3 streams for the same sound).

@Blindside
I would prefer to go just with 1 library.
Warchief's Warboard 3D Now hotseat release
saulotmalo
Posts: 54
Joined: Wed Oct 04, 2006 6:56 am

Post by saulotmalo »

i've just did that ;) i made a circular buffer for the sound as in my game only have has much 4 diferent sounds running at the same time i use 4 buffers and they are stream so i think it will run well
Post Reply