#177817 - Bregalad - Wed Mar 20, 2013 3:06 pm
I want to create my own sound engine, and I want it to get updated way faster than 60Hz (I plan to do it at aprox. 200Hz).
I found this excellent tutorial, so I'll not be asking how to write a sound engine. However, I'm afraid of something :
The problem is that I really want to do it based on a timer, because VBlank is too slow (and this gives impresision for rapid pitch and voluem changes).
If I update the sound engine at 200Hz, but the sound mixing at 60Hz it will be weird, because all the updates that would be done by the sound engine will not be applied to the mixer until the next VBlank, so only PSG sound channels will be able to benefix from the increased refresh frequency. I want to avoid that if possible.
Is there a way (even if it is a bit tricky or hacky) to make a timer interrupt higher priority than VBlank (i.e. when the timer overflows, it calls the sound engine even if this is during a VBlank interrupt) ?
If no, I still think there is a work arround. I can do a dummy copy of the fist part of the first sound buffer at the end of the second buffer, so that even if the timer interrupt is asserved late, the sound will still continue correctly.
Now the problem is asserting the new address to the sound buffer, since there is jiterring in the interrupt, it should be done by subtracting a constant to the adress, instead simply forcing the start of the first buffer.
Is there a way to do this RMW operation of the sound DMA pointers ?
I found this excellent tutorial, so I'll not be asking how to write a sound engine. However, I'm afraid of something :
Quote: |
The easiest kind of buffering for use on GBA is double buffering. With it, you have 2 distinct buffers, each the same size, and use an interrupt to decide when to swap them out. For now, we'll do it with a VBlank interrupt, because it's the safest. Doing it on a timer means opening up possibilities of another interrupt happening first and delaying the swap, causing a click. |
The problem is that I really want to do it based on a timer, because VBlank is too slow (and this gives impresision for rapid pitch and voluem changes).
If I update the sound engine at 200Hz, but the sound mixing at 60Hz it will be weird, because all the updates that would be done by the sound engine will not be applied to the mixer until the next VBlank, so only PSG sound channels will be able to benefix from the increased refresh frequency. I want to avoid that if possible.
Is there a way (even if it is a bit tricky or hacky) to make a timer interrupt higher priority than VBlank (i.e. when the timer overflows, it calls the sound engine even if this is during a VBlank interrupt) ?
If no, I still think there is a work arround. I can do a dummy copy of the fist part of the first sound buffer at the end of the second buffer, so that even if the timer interrupt is asserved late, the sound will still continue correctly.
Now the problem is asserting the new address to the sound buffer, since there is jiterring in the interrupt, it should be done by subtracting a constant to the adress, instead simply forcing the start of the first buffer.
Is there a way to do this RMW operation of the sound DMA pointers ?