#20079 - jdxpolygon - Sat May 01, 2004 4:28 pm
Hi
I wasn't sure how to word this question so I've decided to cut out most of the specific details of my problem. What I'd like to know is, for a sound mixing setup that uses two sound buffers that are swapped every frame, what would be the correct sequence of events to cleanly move playback from one buffer to the start of the alternate one? Presuming that direct sound is set up in the normal way, using DMAs to fill the buffer when it needs data, etc.
I've written a program to do this (in assembly but that's mostly irrelevant because I just want to know the right steps), and it mixes the sound fine, but I can never get it to cleanly switch from one buffer to another - I can't remember every permutation I've tried, but I've recorded the output to a WAV file to analyse it, and I always seem to get either a pop (caused seemingly by zeroes) at the point where the buffers switch over, or some repetition of either what's about to play, or what has just played (I can't remember which, it's been a while since I had that situation), but both cause distortion to the sound output that is undesirable.
I think it's probably because the only information I can find on the way things like the FIFO work are so vague or incomplete or conflicting, it's impossible to know. I'd appreciate if anyone that's created one before (or is sure that they know the answer) could tell me what the correct sequence of operations are to move the playback position, or suggest what else could be the problem (I'm 90% sure it's to do with working the FIFO right - what I find particularly confusing is information given on what happens when you actually write to the FIFO address manually, what happens when you reset it, and all that). For example, I read that 'powers of 2' sample rates would work best, which is why I chose 16384 Hz, but I don't think the varying number of samples used per frame caused by this (I think it's 273 95% of the time, 274 the rest), but I've provided for this eventuality, and it's not overrunning the buffer that's causing the zeroes in the output. Could it be to do with the amount of data the DMA has to get each time? (I'm lead to believe it's probably about 16 bytes, half of the FIFO size, and that a sample buffer that's a multiple of 16 would work best, but I'm pretty sure I tried this too). Any help would be really appreciated, and obviously some people have managed to get it working very well.
thanks for your time
J
I wasn't sure how to word this question so I've decided to cut out most of the specific details of my problem. What I'd like to know is, for a sound mixing setup that uses two sound buffers that are swapped every frame, what would be the correct sequence of events to cleanly move playback from one buffer to the start of the alternate one? Presuming that direct sound is set up in the normal way, using DMAs to fill the buffer when it needs data, etc.
I've written a program to do this (in assembly but that's mostly irrelevant because I just want to know the right steps), and it mixes the sound fine, but I can never get it to cleanly switch from one buffer to another - I can't remember every permutation I've tried, but I've recorded the output to a WAV file to analyse it, and I always seem to get either a pop (caused seemingly by zeroes) at the point where the buffers switch over, or some repetition of either what's about to play, or what has just played (I can't remember which, it's been a while since I had that situation), but both cause distortion to the sound output that is undesirable.
I think it's probably because the only information I can find on the way things like the FIFO work are so vague or incomplete or conflicting, it's impossible to know. I'd appreciate if anyone that's created one before (or is sure that they know the answer) could tell me what the correct sequence of operations are to move the playback position, or suggest what else could be the problem (I'm 90% sure it's to do with working the FIFO right - what I find particularly confusing is information given on what happens when you actually write to the FIFO address manually, what happens when you reset it, and all that). For example, I read that 'powers of 2' sample rates would work best, which is why I chose 16384 Hz, but I don't think the varying number of samples used per frame caused by this (I think it's 273 95% of the time, 274 the rest), but I've provided for this eventuality, and it's not overrunning the buffer that's causing the zeroes in the output. Could it be to do with the amount of data the DMA has to get each time? (I'm lead to believe it's probably about 16 bytes, half of the FIFO size, and that a sample buffer that's a multiple of 16 would work best, but I'm pretty sure I tried this too). Any help would be really appreciated, and obviously some people have managed to get it working very well.
thanks for your time
J