OpenAl tutorial 8

0bf92ebb0380b313a10dd44a549d6702
0
Adrian_Manolache 101 Feb 05, 2008 at 11:33

I’m trying to modify the 8’th tutorial on OpenAl and make a fuction that will
stop the sound and then play it again from the start, but i’m having some difficulties with this. Can you post a snippet of how would you write such a function?

1 Reply

Please log in or register to post a reply.

7cf78e7f6a5d5dbb5c32841e8a26518f
0
ryutenchi 101 Mar 25, 2008 at 09:47

you would need to change the while loop in the main() to check for key input and process it … something like this:

bool running = true;
while(running)
{
   char=getKeyBoardInput(); ///not that this needs to not pause the system 
   if(char == "P"||char=="p")
        ogg.playback();
   if(char=="S||char=="s")
       ogg.stop();
   if(char=="q"||char=="Q")
       running =false;

   ogg.idle();
}

idle() should look something like this:

idle()
{
 if(playing)
 {
   if(!update())
   {
      alSourceStop(source);
      ov_raw_seek(&oggStream,0);
    }
 }
}

you should be able to make stop just:

stop()
{
   alSourceStop(source);
   ov_raw_seek(&oggStream,0);
 }

if you wanted to do a pause it should simply be:

pause()
{
  alSourcePause(source);
}

now I’m no expert, but I think that’ll work. if anyone sees anything wrong with that please correct me.
-ryu