DirectSound capture/playback corrupts sound

Last post 04-30-2008, 6:24 AM by Dabuzz. 3 replies.
Sort Posts: Previous Next
  •  08-08-2007, 3:35 AM

    DirectSound capture/playback corrupts sound

    Hello everyone,

    I have a problem with the FullDuplexFilter sample from the DirectX9 SDK. When using 44100Hz the example works fine, but when using another sampling rate the output sound is corrupted. It takes some time before the sounds starts getting corrupted, and after a while the sound turns back to normal. The happens periodically. I.E. when using 8Khz 16bit stereo it takes about 20 second before the corrupting begins and then lasts for 10 seconds.
    The corrupted sound sounds like parts of the sound is missing or playing is"halted" for short periods.
    I have tested it on another computer with another sound card and on that PC it works fine. That PC has a SoundBlaster Audigy2 CZ. The computer with the problem has a AC97 sound card. The audigy supports HW buffering where the AC97 does not.
    I have tried many configurations for notification positions/size/ buffer sizes e.d. but with the only effect of changing the interval of the corrupting.
    I know applications that do just this thing at 8Khz 16bit stereo with DirectSound and work fine.
    I have read in the FAQ from microsoft that notifications can be very inaccurate and some sort of polling should be used instead. Could that be the problem?
    Any other suggestions?
  •  08-17-2007, 3:28 PM

    Re: DirectSound capture/playback corrupts sound

    Hello,
        I'm having exactly the same problem but I think I have found the cause (but not the solution :(), listen up:

    I'm using two buffers:
    a cyclic capture buffer (CaptureBuffer) to captureSound and,
    a cyclic playback buffer (SecondaryBuffer) to play the sound.

    The captureBuffer has 4 (could be any other number) notifyPositions distributed within the buffer. when data is written to this position a notification is sent to a thread that will copy data from the captureBuffer to the playbackBuffer so it can be played right away, so data is copied in chunks (4 chunks and then begin at the position 0 of the buffers, because there are 4 notification positions).

    Now the playBuffer has a write position which is the position ahead of which is safe to write data (so you dont overwrite data that is being played). The problem is here: the playPosition moves slower than the writePosition so eventually you will begin writing to a position < playPosition and thats when the gaps in audio begin. The difference in the velocity of this pointers can be very slow so its hard to notice, but there is a difference which is increased if I add Effects.

    How can we fix this? Which is the best way to do this? I've heard of FullDuplex class but I haven't tryed it yet.

    Thanks in advanced,
    JC.
  •  08-21-2007, 10:01 AM

    Re: DirectSound capture/playback corrupts sound

    I've found a posible solution:
        I have to watch the pointers to be aware of the distance between them, then I insignifically increase or decrease the frequency of the playback buffer (secondaryBuffer) so the pointer stay in position. I have been able to control the distance between the pointers, but now I need to see how much I can skew the frequency without noticebly distorting the output sound (maybe one hundred hertz, I don't know).

    JC.
  •  04-30-2008, 6:24 AM

    Re: DirectSound capture/playback corrupts sound

    Hi.
    I have exacty the same issiue can you explain what you suggest as solution for this?
View as RSS news feed in XML
©2007 Microsoft Corporation. All rights reserved. Privacy Statement Terms of Use Code of Conduct Feedback