[sdiy] Raspberry Pi 2 B Synthesizer Project Progress

rsdio at audiobanshee.com rsdio at audiobanshee.com
Sun Mar 13 07:25:29 CET 2016

The high latency is most likely due to the fact that you're running Linux and ALSA, instead of bare metal (or RTOS) and direct to the CODEC via I2S peripheral access. The choice of the C language should not impede your ability to drop the latency, if you want lower latency.

I almost thought you wrote that the measurement granularity was 6.4 ms, but I see that it's actually 6.4 us - and that should be plenty. It's less than one audio sample at 48 kHz or 96 kHz, although it's not quite fine enough to measure individual samples at 192 kHz.

I only say this is high latency because I believe you should be able to reduce that drastically with proper design. However, even if you don't care to reduce the latency, the most important factor is to have as close to a constant latency as possible. Random latency is far more disruptive to music than constant latency.

When running ALSA on Linux, you're basically getting typical desktop/laptop performance. Embedded systems make it possible to circumvent an operating system entirely and reduce the latency significantly, and thus bring you into a realm of performance that's not possible with a desktop/laptop system.

Brian Willoughby

On Mar 12, 2016, at 4:25 PM, Scott Gravenhorst <music.maker at gte.net> wrote:
> For those who might be interested in this...
> I've developed what seems to be a stable 32 voice Karplus-Strong MIDI synthesizer and I've just measure the latency time (defined as from time of receipt of MIDI note-on to start of actual sound signal at the DAC).  This was done with a dsPIC and the measurement has a granularity of 6.4 microseconds.  The latency I measured at first was 24.5 milliseconds, but a bit of sleuthing and happy accidents in troubleshooting lead me to the source - ALSA buffer size.  Once I reduced it, I attained a measured worst case latency of approximately 7.1 milliseconds.  This is with Xorg running...  I am currently stress testing it with Chopin Mazurkas and am finding no problems.
> This has been quite a road of discovery...  I am motivated now to do more.  Next will be adding another synth (bitimbral) or an effects processor, perhaps both.  Seems the hardware ought to handle it.
> This code is all in C.  I now have a framework of software for development of other synths.
> -- Scott

More information about the Synth-diy mailing list