I have a problem I can't seem to get passed. I need to be able to load a single sound using Audiere, and have it stream multiple times, ie: When you shoot a gun, I want the sound to play, and then play again before the other is finished.
I did some research, and found out that Audiere handles this with something like audiere::MultipleSoundEffect, where it opens a new steam everytime and then re-uses old ones whenever possible.. But I can't seem to find a way to implement it. Can anyone point me in the right direction? The forum search, Audiere's API and it's non-existent community does me no justice.. =/
Thanks
Audiere Multiple Sound Effects
-
- Posts: 395
- Joined: Fri Apr 08, 2005 8:46 pm
Code: Select all
void CNewtonElevator::InitializeSound(AudioDevicePtr device, char *fileName)
{
if (device != NULL)
{
m_elevatorSound = OpenSound(device.get(), fileName,true);
m_elevatorSound->setVolume(0.15f);
m_elevatorSound->setRepeat(true);
}
}
http://www.s-fonline.com/webhosting/dhenton9000 look for the Newton demo link.
The demo is mostly about newton, but if you text search it, you can pull out the sound code you are looking for.
-
- Posts: 395
- Joined: Fri Apr 08, 2005 8:46 pm
There is only one device, which is created in the containing class and passed around. What will get stored multiple times is the SoundEffect, a elevator sound, a button sound, a gunshot sound, an explosion sound. The device is not created each time. My demo runs this, and I haven't seen any problems, but I don't know a good way to watch memory, so I can't be sure.Quall wrote:Wouldn't that clog the memory with sound devices that will only end up being played once?
Thanks for the refrence, and your demo looks really good. But I still don't know to open another stream before the other is closed. The way you have it setup is almost identical to the way I have mine setup yet it doesn't like to do as it should. I even tried using the OpenSoundEffect() class, but it yeilds nothing more then an app. crash.
Using OutputStreamPtr* stream, this is what I do:
Using SoundEffect* stream;
Both compile fine, neither work as expected, and the latter crashes..
Any ideas?
Thanks.
Using OutputStreamPtr* stream, this is what I do:
Code: Select all
audiereDevice = OpenDevice();
stream = OpenSound(audiereDevice.get(), "media/mp3/pistol_shot.mp3", MULTIPLE);
Code: Select all
audiereDevice = OpenDevice();
stream = OpenSoundEffect(audiereDevice.get(), "media/mp3/pistol_shot.mp3", MULTIPLE, FF_MP3);
Any ideas?
Thanks.
Ok, I managed to get it working.. I guess it has to do something with mp3/wav. The .mp3 won't reopen streams as .wav will.
Heres what I used.
Heres what I used.
Code: Select all
AudioDevicePtr audiereDevice;
SoundEffect* BulletFire;
audiereDevice = OpenDevice();
BulletFire = OpenSoundEffect(audiereDevice.get(), "media/wav/pistol_shot.wav", MULTIPLE, FF_WAV);