Sound glitch after sound complete (includes code)

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
Post Reply
David Winter
Posts: 5
Joined: Fri Apr 13, 2007 5:27 pm
Location: Vancouver, BC, Canada
Contact:

Sound glitch after sound complete (includes code)

Post by David Winter »

Hi.

This is likely a case of me not coding things properly, but I'm having a problem when a sound finishes.

After my sounds finish, there is a pop-crackle sound (actually, sounds like flatulence).

These are the same sounds I used previously, making direct calls to DirectX8 via VB6. The crackle sound was not present then.

Thoughts?

My code is below, I don't think I do anything special;

Code: Select all

STDMETHODIMP CSoundObject::PlaySound(BSTR vSoundFile, BOOL vLooped, float vVolume)
{

	//The creation of the private sound object from the global engine
	//We need to track it so that the class can do things with it.

	mSound = gEngine->play2D(_bstr_t(vSoundFile), (bool)vLooped, false, true);

	//Automatically set the volume to that passed in.

	this->ChangeVolume(vVolume);

	return 0;
}

STDMETHODIMP CSoundObject::ChangeVolume(float vNewVolume)
{
	

	//This routine will change the volume

	//Make sure the sound object exists first.
	if (! mSound)
		return(1);

	//Make sure it's not greater than 1
	if(vNewVolume > 1)
		vNewVolume = 1;

	//Not less than zero
	if(vNewVolume < 0)
		vNewVolume = 0;

	//Set the sound volume
	mSound->setVolume(vNewVolume);

	return 0;
}
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Hm, maybe you could try to change the file format (sample rate?) or add some silence in the end of the file. I got some reports that some sounds are causing this, but don't know yet why, I haven't looked at it closely. Going to fix this soon.
In the meanwhile, try if one of my suggestions would work for you, or also maybe switching to another driver (specifiy winmm for example as first parameter when using createIrrklangDevice()).
David Winter
Posts: 5
Joined: Fri Apr 13, 2007 5:27 pm
Location: Vancouver, BC, Canada
Contact:

Post by David Winter »

Okay thanks.

Do you need anything from me? A copy of one of the sound files maybe? Granted, I'm not sure it's the file as they sounded okay previously. They also sound okay if played in WinAmp for example.
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Sure, a copy of the sound would be very nice, just email it me.
Post Reply