: I am trying to write a program in Visual C++ that is supposed to play a wav file. It works fine except that it produces a crackling noise at the start and end. The file is OK (I used Winamp to verify that).
: Does anyone have an idea what the problem might be
Not all of the WAV file is data that is to be played.
The file begins with "RIFF"
Then comes the length of the file. Then each chunk of the file comes. First there are 4 bytes to identify the chunk, and then, the length of the chunk comes.
The relevant chunks are "fmt " (it is a WAVEFORMATEX structure) and "data" which contains the data.