FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Trying to play a sound

3 posters

Go down

Trying to play a sound Empty Trying to play a sound

Post  iphoniac Tue Feb 10, 2009 12:10 pm

Hi, my scene has a music added to the third texture channel in the blender file and itīs played fine but I want to play an explosion sound in a specific moment of the game.

I donīt see doc or video to do this so this is what Iīve done:

In scene loading:
Code:
      _explosion = sio2SoundInit( "Boom" );
      SIO2soundbuffer *_soundBuffer = sio2SoundBufferInit( "BoomBuffer" );
      
      SIO2stream *_SIO2soundstream = sio2StreamOpen( "boom.ogg", 1 );
      sio2SoundBufferLoad( _soundBuffer, _SIO2soundstream );
      
      sio2SoundGenId( _explosion, _soundBuffer, SIO2_SOUND_FX);
      

In the moment of playing:
Code:
   sio2SoundSetFx( _explosion, &pos, 100.0f );
   sio2SoundSetVolume(_explosion, 20.0f);
   sio2SoundPlay( _explosion );

The sound is not played. What am I doing wrong?

Thanks.

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Trying to play a sound Empty Re: Trying to play a sound

Post  sio2interactive Tue Feb 10, 2009 3:52 pm

Well looking quick quick at your code, I can see that you set the sound at 20.0f, the volume is from 0.0f to 1.0f...

The rest look about right... lemme know if it fix the problem... if not send me that boom sound in order for me to test...
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Trying to play a sound Empty Re: Trying to play a sound

Post  iphoniac Wed Feb 11, 2009 8:22 am

Change the sound setting and got nothing. Iīve sent you the ogg file.

Thanks.

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Trying to play a sound Empty Re: Trying to play a sound

Post  sio2interactive Wed Feb 11, 2009 7:10 pm

Hey man taking another look at your post:

1. Have you initialize OpenAL with sio2InitAL();

2. You didn't gen the soundbuffer ID

Code:


   SIO2sound *_explosion = sio2SoundInit( "Boom" );
   SIO2soundbuffer *_soundBuffer = sio2SoundBufferInit( "BoomBuffer" );

   SIO2stream *_SIO2soundstream = sio2StreamOpen( "boom.ogg", 1 );
   sio2SoundBufferLoad( _soundBuffer, _SIO2soundstream );

   sio2SoundBufferGenId( _soundBuffer );

   sio2SoundGenId( _explosion, _soundBuffer, SIO2_SOUND_AMBIENT | SIO2_SOUND_LOOP );

   //sio2SoundSetFx( _explosion, &pos, 100.0f );
   sio2SoundSetVolume( _explosion, 1.0f );
   sio2SoundPlay( _explosion );   

sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Trying to play a sound Empty Re: Trying to play a sound

Post  iphoniac Thu Feb 12, 2009 4:31 am

1. Have you initialize OpenAL with sio2InitAL();

Yep.


2. You didn't gen the soundbuffer ID

Thatīs probably where the problem is. Iīll check it later...

Thanks!

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Trying to play a sound Empty Re: Trying to play a sound

Post  sio2interactive Thu Feb 12, 2009 5:21 am

Heuu dude just copy paste the code above and it will work...
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Trying to play a sound Empty Re: Trying to play a sound

Post  iphoniac Thu Feb 12, 2009 7:37 am

Ok, ok, Iīll try later, when I arrive home.

umm, that piece of code will be unawared of the position of the explosion. That was the reason of my
Code:
sio2SoundSetFx( _explosion, &pos, 100.0f );
You commented that, should I suppose 3d sound is not working?

Cheers..

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Trying to play a sound Empty Re: Trying to play a sound

Post  sio2interactive Thu Feb 12, 2009 8:48 am

Of course it is working, I just test it with an ambient sound to make sure that the sound was playing correctly... With if the ambient sound play, positional source is not a problem Wink

Cheers,
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Trying to play a sound Empty Re: Trying to play a sound

Post  iphoniac Thu Feb 12, 2009 12:13 pm

Iīve tried it and does not work Crying or Very sad

Is it working for you? Are you using a "third texture" sound?

Iīm using 1.3.1, not the latest version.

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Trying to play a sound Empty Re: Trying to play a sound

Post  sio2interactive Thu Feb 12, 2009 4:42 pm

Yes it's working I use the code above to load and play the sound directly in code using 1.3.2
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Trying to play a sound Empty Re: Trying to play a sound

Post  sio2interactive Thu Feb 12, 2009 5:46 pm

Well if you are using an FX sound remember to call sio2CameraUpdateListener, in order to update the listener sound position & direction.
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Trying to play a sound Empty Re: Trying to play a sound

Post  iphoniac Fri Feb 13, 2009 2:48 am

No, Iīm still not using FX. Iīll update to 1.3.2 and give it another try later.

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Trying to play a sound Empty Re: Trying to play a sound

Post  iphoniac Fri Feb 13, 2009 9:22 am

Nevermind. 298 errors after compiling for the first time with 1.3.2. Itīs too many work now just for a sound.

Do you have a record of funtion changes after each version??

Cheers.

iphoniac

Posts : 62
Join date : 2008-12-11

http://thecaveaniphonegame.blogspot.com/

Back to top Go down

Trying to play a sound Empty Re: Trying to play a sound

Post  Admin Fri Feb 13, 2009 3:58 pm

Its all on SVN dude...

Admin
Admin

Posts : 10
Join date : 2008-08-26

http://forum.sio2interactive.com

Back to top Go down

Trying to play a sound Empty Re: Trying to play a sound

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum