directX audio, I don't want echos!

Started by
7 comments, last by Sepultang 18 years, 7 months ago
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]
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.
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.
Could be happening: Are you sure you call play only once or everytime basically restarting the sound again and again?

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

I play the sound just once at a time.
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).
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...)
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).
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.

This topic is closed to new replies.

Advertisement