Sound Example
4 posters
Sound Example
I believe I'm back on track. Thanks!
Any chance you have an example of implementing sio2 sound on a physics collision?
Any chance you have an example of implementing sio2 sound on a physics collision?
jj- Posts : 77
Join date : 2008-09-24
Re: Sound Example
For implementing "trigger" on collision checkout SIO2sensor... for the sounds Im working on it to have a tutorial... but something happen recently and I lost some work... It'll take a bit longer than plan... sorry...
Re: Sound Example
Can you write little bit of sample code how use sound in engine ? And which formats of files you use?
hazeleye- Posts : 34
Join date : 2008-09-24
Re: Sound Example
Allright quick and dirty:
1. Link an OGG into the third texture channel of your material
2. Now from that texture property:
MIPMAP = Autoplay
REPEAT = Loop Sound
INTERPOLATE = Ambient Sound
else
FX Sound
And you can control the volume of ambient or FX with:
sio2->_SIO2window->volume // For ambient sound
sio2->_SIO2window->fx_volume // For FX sound
Then pass the resource & window pointer to one of these function:
void sio2ResourceSetAmbientVolume( SIO2resource *_SIO2resource,
SIO2window *_SIO2window );
void sio2ResourceSetFxVolume( SIO2resource *_SIO2resource,
SIO2window *_SIO2window );
You can also control the sound with the SIO2sound structure check sio2_sound.h (for play,pause, stop etc...)
1. Link an OGG into the third texture channel of your material
2. Now from that texture property:
MIPMAP = Autoplay
REPEAT = Loop Sound
INTERPOLATE = Ambient Sound
else
FX Sound
And you can control the volume of ambient or FX with:
sio2->_SIO2window->volume // For ambient sound
sio2->_SIO2window->fx_volume // For FX sound
Then pass the resource & window pointer to one of these function:
void sio2ResourceSetAmbientVolume( SIO2resource *_SIO2resource,
SIO2window *_SIO2window );
void sio2ResourceSetFxVolume( SIO2resource *_SIO2resource,
SIO2window *_SIO2window );
You can also control the sound with the SIO2sound structure check sio2_sound.h (for play,pause, stop etc...)
Re: Sound Example
can I know sound playing or not now? I want play my sound again by again
I write:
I write:
- Code:
void templateRender( void )
{
...
if (_SIO2sound1->state != SIO2_SOUND_PLAY) //But if I once set SIO2_SOUND_PLAY (in sio2SoundPlay()) state always will be ==SIO2_SOUND_PLAY even if sound not playing now
{
sio2SoundPlay(_SIO2sound1);
}
...
}
hazeleye- Posts : 34
Join date : 2008-09-24
Re: Sound Example
Well to play your sound again and again (which is called loop)... Im the Map Image panel make sure that REPEAT is toggled and it will play again and again...
Re: Sound Example
I can't manipulate with volume of my sounds. For testing I change your function in sio2_window.cc
- Code:
void sio2WindowDefaultMode( SIO2window *_SIO2window )
{
_SIO2window->volume = 0.0f;//0.65f;
_SIO2window->fx_volume = 0.0f;//0.85f;
}
hazeleye- Posts : 34
Join date : 2008-09-24
Re: Sound Example
That's because this have absolutely no effect on the OpenAL API... Hey listen man... I upload this file for you, I do not have a video tutorial yet but that the tutorial that Im about to release to explain sound, its probably going to be different than the final one but all the basics are there, I also include the .blend file that I use to test as wel as the OGG's.
Check it out:
http://sio2interactive.com/dump/tutorial09.zip
Check it out:
http://sio2interactive.com/dump/tutorial09.zip
Re: Sound Example
Can I control sounds that are not mapped to the object's material texture, and simply load the .ogg used in the implementation?
What methods do I need to setup the sound file and then play on command?
What methods do I need to setup the sound file and then play on command?
jj- Posts : 77
Join date : 2008-09-24
Re: Sound Example
Checkout for the exact implementation, but just to explain briefly, basically you have 2 things, 1 is the SIO2soundbuffer that you need to init to load the OGG, and the second thing is SIO2sound that represent a sound in space, since you can have multiple sound source that use the same sound no need to have multiple sound buffer loaded in memory.
Basically the sequence is like this:
Then you can use OpenAL directly to set up the volume
Basically the sequence is like this:
- Code:
// Create a new sound buffer
sio2SoundBufferInit
// Load your OGG using an SIO2stream
sio2SoundBufferLoad
// Generate a sound buffer ID
sio2SoundBufferGenId
// Init a sound source
sio2SoundInit
// Bind the sound buffer to the source and generate a source ID, and pass the default parameters to the flags eg: SIO2_SOUND_AUTOPLAY | SIO2_SOUND_LOOP | SIO2_SOUND_AMBIENT
sio2SoundGenId
Then you can use OpenAL directly to set up the volume
Re: Sound Example
I tried it like so:
Best,
Matt
- Code:
SIO2soundbuffer* buffer = sio2SoundBufferInit( "music.ogg" );
SIO2stream* stream = sio2StreamOpen( "music.ogg", 1 );
sio2SoundBufferLoad( buffer, stream );
sio2StreamClose( stream );
sio2SoundBufferGenId( buffer );
SIO2sound* sound = sio2SoundInit( "music.ogg" );
sio2SoundGenId( sound, buffer, 0 );
sio2SoundPlay( sound );
Best,
Matt
Re: Sound Example
Ah! I found this thread and that was it. OpenAL doesn't work with OS 2.0 in the simulator, you need to use 2.1.
Best,
Matt
Best,
Matt
Similar topics
» Trying to play a sound
» Stream sound
» Error when using sound files
» Hook a sound to a physics collision
» Duplicating an object with sound attached
» Stream sound
» Error when using sound files
» Hook a sound to a physics collision
» Duplicating an object with sound attached
Permissions in this forum:
You cannot reply to topics in this forum