Re: Sugestions or Comments about my Sound Tutorial
Now I'm having another problem. When I stop my sound buffer from playing, and then I later start it up again, with different data, it for a fraction of a second continues playing the previous data, before it reads the new data. I assume that's because when I stopped it, I stopped it before it had finished playing the previous segment of the buffer. So to fix that, I just made sure to load an empty array like this
Code:
DSB.Stop
If ResetBuffer Then
DSB.SetCurrentPosition 0
ReDim EmptyBuffer(BuffSize * 2 - 1)
' The *2 accounts for the entire buffer size, not just the half-buffer size that is stored in the BuffSize variable.
DSB.WriteBuffer 0, 0, EmptyBuffer(0), DSBLOCK_ENTIREBUFFER
End If
DSB is the name I gave the DirectSound Buffer object. By stopping the playback, and then clearing the entire buffer, it should make it so that it completely overwrites the content of the buffer. Unfortunately, this only MOSTLY works. It leaves a tiny amount at the start of the buffer that appears that it can't be overwritten. The next time I start the buffer playing, there is a VERY brief "click" sound at the beginning (about 100 samples or so I would guess, remained untouched by my overwriting the buffer with blank data it seems), and then for about a tenth of a second there's silence (where the buffer was successfully overwritten) and then it starts playing the desired sound.
Why are a few samples at the start of the buffer untouched by the write operation that I use to try to clear the buffer?