Audiere Multiple Sound Effects

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
handless
Posts: 19
Joined: Thu Jan 13, 2005 6:40 am
Location: earth

Audiere Multiple Sound Effects

Post by handless »

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
dhenton9000
Posts: 395
Joined: Fri Apr 08, 2005 8:46 pm

Post by dhenton9000 »

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);
	}
}
This is a code snippet from my demo that uses audiere for explosions, which occur multiple times, like you want. The device is the Audiere device m_elevatorSound is of type SoundEffect*. The demo is at
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.
Quall
Posts: 154
Joined: Mon Mar 07, 2005 10:16 pm

Post by Quall »

Wouldn't that clog the memory with sound devices that will only end up being played once?
dhenton9000
Posts: 395
Joined: Fri Apr 08, 2005 8:46 pm

Post by dhenton9000 »

Quall wrote:Wouldn't that clog the memory with sound devices that will only end up being played once?
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.
Guest

Post by Guest »

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:

Code: Select all

	
audiereDevice = OpenDevice(); 
stream = OpenSound(audiereDevice.get(), "media/mp3/pistol_shot.mp3", MULTIPLE); 
Using SoundEffect* stream;

Code: Select all

	
audiereDevice = OpenDevice(); 
stream = OpenSoundEffect(audiereDevice.get(), "media/mp3/pistol_shot.mp3", MULTIPLE, FF_MP3);
Both compile fine, neither work as expected, and the latter crashes..

Any ideas?

Thanks.
handless
Posts: 19
Joined: Thu Jan 13, 2005 6:40 am
Location: earth

Post by handless »

Could have sworn, I was logged in. :?
handless
Posts: 19
Joined: Thu Jan 13, 2005 6:40 am
Location: earth

Post by handless »

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.

Code: Select all

	
AudioDevicePtr audiereDevice;
SoundEffect* BulletFire;

audiereDevice = OpenDevice(); 
BulletFire = OpenSoundEffect(audiereDevice.get(), "media/wav/pistol_shot.wav", MULTIPLE, FF_WAV); 
Post Reply