Noise Click Playback

I am trying to write a program to play a small WAV file in C ++. I programmed it according to the DirectX SDK docs for recording and playing back on a secondary static buffer. It works correctly, except that at the end of playback for any WAV file there is a very noticeable “click” of noise. I am sure this is not a defect on my audio hardware because any other game that I know uses DirectSound does not have it.

I tried the GetCurrentPosition poll for each cycle and stopped it right before it was completed, but was unreliable. I cannot play it in the main buffer because the .wav played on the primary buffers must be encoded, which I don't want.

Does anyone know how to fix this problem? Thanks in advance.

+3
source share
1 answer

We will need to see both the WAV file and the code for loading the WAV file into the sound buffer. But here are a few guesses.

First of all, I suppose that if we loaded the WAV file into the visual audio editor, we would see the sound approaching its steep end, instead of narrowing into silence. This will cause popping noise with almost any audio player.

, . WAV , DATA. , , , . WAV (, Visual Studio), , DATA , ? ReadFile , , ?

+4

Source: https://habr.com/ru/post/1752019/