Trying to play a sound
3 posters
Trying to play a sound
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:
In the moment of playing:
The sound is not played. What am I doing wrong?
Thanks.
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.
Re: Trying to play a sound
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...
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...
Re: Trying to play a sound
Change the sound setting and got nothing. Iīve sent you the ogg file.
Thanks.
Thanks.
Re: Trying to play a sound
Hey man taking another look at your post:
1. Have you initialize OpenAL with sio2InitAL();
2. You didn't gen the soundbuffer ID
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 );
Re: Trying to play a sound
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!
Re: Trying to play a sound
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
Cheers..
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 );
Cheers..
Re: Trying to play a sound
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
Cheers,
Cheers,
Re: Trying to play a sound
Iīve tried it and does not work
Is it working for you? Are you using a "third texture" sound?
Iīm using 1.3.1, not the latest version.
Is it working for you? Are you using a "third texture" sound?
Iīm using 1.3.1, not the latest version.
Re: Trying to play a sound
Yes it's working I use the code above to load and play the sound directly in code using 1.3.2
Re: Trying to play a sound
Well if you are using an FX sound remember to call sio2CameraUpdateListener, in order to update the listener sound position & direction.
Re: Trying to play a sound
No, Iīm still not using FX. Iīll update to 1.3.2 and give it another try later.
Re: Trying to play a sound
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.
Do you have a record of funtion changes after each version??
Cheers.
Similar topics
» How to play sound in templateRender
» Sound Example
» Stream sound
» Error when using sound files
» Hook a sound to a physics collision
» Sound Example
» Stream sound
» Error when using sound files
» Hook a sound to a physics collision
Permissions in this forum:
You cannot reply to topics in this forum