[sdiy] dsPIC DMA buffered audio Re: Quick C query
Tom Wiltshire
tom at electricdruid.net
Sun Nov 21 20:11:07 CET 2010
On 21 Nov 2010, at 18:18, Eric Brombaugh wrote:
> There was some talk a while back of using dsPIC DMA to handle buffer-oriented processing of audio samples. I started a project along this line recently and it's been working nicely.
I've had a crack at this too, and I agree entirely. You can get a couple of buffers set up, and get the DMA to read samples out of one whilst you fill the other. If your buffer is (say) 16 samples long, that gives you a good chunk of time to generate samples without being interrupted. When the DMA finishes the buffer, it sets a flag to tell the main code that the buffer is empty and then starts on the other buffer. The main code just has to poll the two flags and fill whichever buffer has just been emptied.
I had this running with a 89KHz sample rate, with modulations at the block rate (eg generated once after all the audio samples are done) which gives a modulation rate of 89/16 = 5.5KHz. It's pretty good, and if I run out of time I'll push it to a block size of 32 samples and use a mod rate of 2.75KHz. Prophet 08 allegedly uses around 1KHz mod rate, so if I'm going twice as fast as Dave Smith, I'm still happy!
On a separate note, thanks everyone for all the help with C. I know it's not entirely synthy, but I knew there'd be loads of people here who would know and who would have tried similar things to where I'm heading. And so it proved.
T.
More information about the Synth-diy
mailing list