[sdiy] Raspberry Pi 2 Synthesizer Project
Scott Gravenhorst
music.maker at gte.net
Sun Feb 7 21:37:05 CET 2016
"Richie Burnett" <rburnett at richieburnett.co.uk> wrote:
>> I've been able to get a period size of 8 frames and I'm using a
>> polling function instead of a callback. Either way, the period size
>> is much larger than 2 frames.
>
>Okay. By "frames" do you mean audio samples?
It's the data that is sent to the DAC, in this case 2 samples for stereo
>It looks like I'll have
>to read up on ALSA if I'm going to make my R-Pi do anything impressive
>audio related. I've had it playing and recording WAV files via an
>external Edirol USB audio interface (the on-board Audio output is
>awful quality,) but not actually processing or synthesising anything
>in real-time.
>
>> I prefer interrupt per DAC frame, but this worked surprisingly well
>> so I'm encouraged to continue.
>
>The block processing scheme is what I am used to myself. One
>interrupt >generated every 48 samples, or 64 samples or whatever, then
>you synthesise another block of 64 samples to re-fill the buffer
>before they're played out. Usually in two separate halves: The buffer
>write pointer and the playback pointer ping-pong between the halves,
>so that you are always writing to the other buffer to the one that the
>DAC is playing back the audio from. It increases latency over the one
>interrupt per sample scheme for sure, but you generate a lot less
>interrupts and it's a much more efficient way of working once you get
>used to it.
>
>-Richie,
In this environment, you deal with chunks of frames called periods. In
my case, the buffer size is 1024 (I assume frames) and the period size
is 8, so there is a huge ring buffer.
With dsPICs, I wrote the synth code into the DAC ISR (gasp) which first
stuffed the DAC, then computed and stored the next sample. The active
foreground task was the MIDI controller, so the MIDI controller got what
was ever left after sample generation was done. The only interrupt is
the DAC interrupt. Everything is run off of that, polling the UART,
getting DMA data and starting ADC DMA. It's quite simple and has
overhead for only 1 interrupt. I wind up adding features or voices
until I risk choking the MIDI controller of CPU cycles. The CPU stays
very busy.
More information about the Synth-diy
mailing list