Jump to content
  • Advertisement
Sign in to follow this  
RoyChen204

Direct Sound 3D help!

This topic is 3708 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I got a problem with DirectSound. heres how it goes, I created an Audio class to store any music files I loaded. When its just background music, its fine, but when I insert a listener, things become problematic. I can change the values of the sound position to no effect, while if I change the listener, even the background music becomes "dropped off"
void AudioManager::PlaySegment(unsigned int value, int times)
{
	for(std::vector<Sound *>::iterator g2 = Audio.begin(); g2 != Audio.end();g2++)
	{
		if((*g2)->id == value)
		{
			if(times > -1)
			{
				(*g2)->m_pSegment->SetRepeats(times);
				m_pPerformance->PlaySegmentEx((*g2)->m_pSegment,NULL,NULL, DMUS_SEGF_DEFAULT, 0, NULL,NULL, (*g2)->m_p3DAudioPath);
			}
			else
			{
				(*g2)->m_pSegment->SetRepeats(DMUS_SEG_REPEAT_INFINITE);
				m_pPerformance->PlaySegmentEx((*g2)->m_pSegment,NULL,NULL, DMUS_SEGF_SECONDARY, 0, NULL,NULL, (*g2)->m_p3DAudioPath);
			}

			
			return;
		}
	}
}
void AudioManager::SetListener(Vector *position)
{
	m_pListener->SetPosition(position->x,position->y,position->z ,DS3D_IMMEDIATE);
}
void AudioManager::SetPosition(unsigned int value, Vector *position)
{
	for(std::vector<Sound *>::iterator g2 = Audio.begin(); g2 != Audio.end();g2++)
	{
		if((*g2)->id == value)
		{
			if((*g2)->m_pDirectSoundBuffer3D != NULL)
			{
				(*g2)->m_pDirectSoundBuffer3D->SetPosition(position->x, position->y, position->z, DS3D_DEFERRED);
			}
		}
	}
}

p.s: How to I post blocks of codes neatly like how some of the other guys do it? [Edited by - RoyChen204 on July 29, 2008 1:07:31 PM]

Share this post


Link to post
Share on other sites
Advertisement
If you change any parameter of the listener or a 3D soundbuffer and pass DS3D_IMMEDIATE, those changes will be applied immediately. If you pass DS3D_DEFERRED, your changes will not be applied until you call IDirectSound3DListener::CommitDeferredSettings().

I guess your error is that you're not calling this function.
Since you change the position of your 3D sound using DS3D_DEFERRED, those changes won't be applied.

Quote:
Original post by RoyChen204
p.s: How to I post blocks of codes neatly like how some of the other guys do it?


Read the FAQ.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!