|
Hi.
I have an application where I have music source data that is
converted to DirectSound samples on the fly (i.e. the entire tune is
too big to be decompressed into one large sample).
I would like some advice on how to do this.
The approach I am considering is a simple double-buffer. Play one
buffer whilst decoding the next music segment into the other.
From some tutorials on the web, I have managed to play a single
buffer, however, I am not sure what to do to flip over to the second
buffer.
This is what I am doing:
1. Setup Timer0 at 44.1kHz to play the sample.
2. Setup Timer1 to cascade, counting N samples and then interrupting.
3. Set DMA1 from the first soundbuffer.
4. Enable Timer0.
Now I'll get an interrupt from Timer1 after N samples.
Q. What do I have to do to seamlessly move over to the second buffer?
- I think I have to:
1. Disable Timer0.
2. Disable DMA1.
3. Reset DMA1 to new source buffer.
4. Reenable DMA1.
5. Reenable Timer0.
This does not work on VisualBoyAdvance (although I have not tried on
my hardware yet).
Please let me know if this approach is ok, and I would appreciate any
other suggestions.
Regards,
David.
|