Jump to content
  • Advertisement
Sign in to follow this  
Sepultang

directX audio, I don't want echos!

This topic is 4836 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've implemented a simple sound playing class using directX audio. But when I play my sounds they've got echos on them. I don't want that and I never specified any effects. I don't set any audiopath or anything. This is how I load my sounds:
void DirectAudio::LoadSound(WCHAR *filename, int soundNr)
{
  // Create segment
  m_pSegments[soundNr] = NULL;
  CoCreateInstance(CLSID_DirectMusicSegment, NULL, CLSCTX_INPROC, IID_IDirectMusicSegment8, (void**) &m_pSegments[soundNr]);

  // Load the file
  m_pLoader->LoadObjectFromFile(CLSID_DirectMusicSegment, IID_IDirectMusicSegment8, filename, (void**) &m_pSegments[soundNr]);

  // Download the band
  m_pSegments[soundNr]->Download(m_pPerformance);
}
And this is how I play it:
void DirectAudio::Play(int soundNr)
{
  m_pPerformance->PlaySegment(m_pSegments[soundNr], NULL, 0, NULL);
}
[Edited by - Sepultang on August 21, 2005 12:30:40 PM]

Share this post


Link to post
Share on other sites
Advertisement
Does your soundcard have something like the EAX console of the sound blaster audigy platinum 2 cards? If so, check to make sure that all effects are turned off. That could be causing your echo.

Share this post


Link to post
Share on other sites
I've got a sounblaster live! yes. But I have no effects on (everything else sounds ok on my computer), also I've tried my code on other people's computers as well.

Share this post


Link to post
Share on other sites
Don't be so sure about that. Lets say you play the sound by pressing a key. I'm guessing your checking if the file is already playing with IsPlaying or whatever its called. There is a delay between when you press the key and when DX actually plays the audio. Thus on the next loop when your still pressing the key, it sends the signal to play again. Thus an echo occurs. That would be my guess as to what is happening (since we have so little code to go by).

Share this post


Link to post
Share on other sites
I've got a simple application playing no sounds at all at first, but when I press a key I play a wave-file.

When I start my app I init directAudio and load my sound with LoadSound(WCHAR *filename, int soundNr) and when I push a key I call Play(int soundNr). The functions are included in my first message.

Thats the only thing I do.

I'm not checking if IsPlaying is true or false, but I'm only calling my Play-function once. (I've made a keyIsDownOnce-function...)

Share this post


Link to post
Share on other sites
Well then there is either errors in the rest of your code, an error on the system (not likely), its loading a different file with an echo effect (also not likely), or you tore a hole in the fabric of time and space causing the sounds to play in a different time than when you press the button. As such in the future it may not work at all as the sound was actually sent to the past... So kudos if its the last one. :)

Actually it looks like your loading the file correctly and since I haven't used PlaySegment (PlaySegmentEx has a lot more options) in a while, I believe that everything your sending it works fine. Its playing with no flags, immediately, and your not getting a pointer to the segment's state. My guess is that its an error in other portions of your code (probably something small).

Share this post


Link to post
Share on other sites
It turned out I was an idiot after all.

When initing the performance object I sat DefaultPathType to DMUS_APATH_SHARED_STEREOPLUSREVERB...
So the mystery is solved.


My guess is, as you said TheFez6255, that I tore a hole in the fabric of time when pressing space, and that caused my code I wrote yesterday to change to something I will write in the future.

Anyway, thanks all for your help.

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!