IrrKlang and/or time help [H E L P!]

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
Systemerror
Posts: 98
Joined: Fri Oct 03, 2008 1:25 pm
Location: UK
Contact:

IrrKlang and/or time help [H E L P!]

Post by Systemerror »

Hey guys,

I think the best way to ask my question is to explain what I want to do, well - what I want is to create an introduction to the client about who developed the game before going to the main menu - for instance, creating a static image with the company logo, playing a sound effect and then going to the main menu.

The way I tried to approach this was to render the image, play the required sound, and then test a condition to see if the sound is playing/finished is methods to as (ISoundSource) as a param etc, but it doesn't seem to work correctly, I've managed to use the IsCurrentlyPlaying functions correctly, and isFinished, it compiled fine and all arguments are correct, but only the first condition works in the correctly set up if/else conditional statements, I've tried a few ways to test if the engine is/is not playing a specified sound but to no avail, I have looked through the IrrKlang API documentation and it appears what I am doing is correct, and debugging confirms this - can someone shed some light on this and some code would be nice.

Lastly, I tried to think of a different approach, that was, to chech if a certain amount of seconds has passed, then to perform the required task - I also looked this up in the API doc's but could not find a definitive method to do this, thus, some help there would be nice too :P
Last edited by Systemerror on Wed Apr 22, 2009 9:11 am, edited 1 time in total.
-System error
Systemerror
Posts: 98
Joined: Fri Oct 03, 2008 1:25 pm
Location: UK
Contact:

Post by Systemerror »

I really need help with this, *bump.
-System error
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You can use the Irrlicht timer to check the time already used. For irrKlang please ask in their forum (therefore also moving too game programming forum).
Systemerror
Posts: 98
Joined: Fri Oct 03, 2008 1:25 pm
Location: UK
Contact:

Post by Systemerror »

hybrid wrote:You can use the Irrlicht timer to check the time already used. For irrKlang please ask in their forum (therefore also moving too game programming forum).

Ok, like a time elapsed function... can you give a code example, I can't look through the documentation until tommorow as I'm not on my box.

The example structure being:

if time passed (in milliseconds I imagine so 5 nano seconds is 5000 milliseconds I believe)

//do something/show logo
else
//do something else
-System error
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

Systemerror wrote:5 nano seconds is 5000 milliseconds I believe
1 nano second is 0.000001 milliseconds.

See http://en.wikipedia.org/wiki/SI_prefix
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
xDan
Competition winner
Posts: 673
Joined: Thu Mar 30, 2006 1:23 pm
Location: UK
Contact:

Post by xDan »

um...

ITimer *timer = device->getTimer();

u32 startTime = timer->getTime();

while (timer->getTime() - startTime < 5000) // wait 5 seconds
{
logoRenderUpdate();
}
//continue


it really depends on how *you* implement your main loop though
Systemerror
Posts: 98
Joined: Fri Oct 03, 2008 1:25 pm
Location: UK
Contact:

Post by Systemerror »

Sylence wrote:
Systemerror wrote:5 nano seconds is 5000 milliseconds I believe
1 nano second is 0.000001 milliseconds.

See http://en.wikipedia.org/wiki/SI_prefix

Yeah it's 1 "standard second" to 1,000 "milliseconds", I don't know why I said nano second.

um...
ITimer *timer = device->getTimer();

u32 startTime = timer->getTime();

while (timer->getTime() - startTime < 5000) // wait 5 seconds
{
logoRenderUpdate();
}
//continue

Great that cheers, I couldn't get to the API docs :(
-System error
Systemerror
Posts: 98
Joined: Fri Oct 03, 2008 1:25 pm
Location: UK
Contact:

Post by Systemerror »

Oh did anyone manage to find a definitive way to check when an audio track has finished playing? as I said I believe I was doing it correctly as I followed the API docs and it compiled fine also but to no avail.
-System error
pc0de
Posts: 300
Joined: Wed Dec 05, 2007 4:41 pm

Post by pc0de »

Have a look at irrklang::ISoundStopEventReceiver. In the section of code that checks if the sound is done playing, you can check a flag that is set by the event handler:

Code: Select all

 
 bool sndIsDone=false;
 irrklang::ISound* snd;

 class MySoundEndReceiver : public irrklang::ISoundStopEventReceiver
 {
   public:
     virtual void OnSoundStopped (irrklang::ISound* sound, irrklang::E_STOP_EVENT_CAUSE reason, void* userData)
     {
        // called when the sound has ended playing
        if(userData == snd)
        {
            sndIsDone = true;
            printf("sound has ended");
        }
     }
 }

 // ...

 MySoundEndReceiver* myReceiver = new MySoundEndReceiver();
 snd = engine->play2D("speech.mp3", false, false, true); 
 if (snd)
    snd->setSoundStopEventReceiver(myReceiver, snd);

 // render loop 
 while(Device->run())
 {
     if(sndIsDone)
     {
         // proceed to menu state
     }
 }
moekkog
Posts: 44
Joined: Tue Feb 24, 2009 6:02 am

im working on a dialog type

Post by moekkog »

im doing a type of dialog playing sounds in times that i want if you are interested i can tell you more just tell me if you are interested
Post Reply