Latency is a key characteristic of a sampler. The lower it is, the more comfortable it is to play an instrument. Even normal human speech appears to be out of sync on video when sound is delayed by 50ms or more. With digital instruments most players' preference is to achieve latency lower than 10ms.
The latency itself appears due to processing delay, while a synth or a DAW is processing note input from a keyboard or controller, adds time for loading a sample, starting playback, applying digital filters, buffering, sending data to ADC and playing. Note that buffering is the only part of total latency visible in DAW or sound card settings on a computer.
Naturally its been a great question for us to find out how much can be achieved with a sampler written on Python and running on a Raspberry Pi. The answer is to measure.
The measurement setup consisted of:
- MIDI keyboard connected using serial MIDI to eliminate any variability that may be introduced by USB protocol.
- Raspberry Pi 3 running latest SamplerBox software version from https://github.com/alexmacrae/SamplerBox
- SamplerBox Player PCB MIDI interface and DAC.
- An oscilloscope.
The latency was measured as a delay between MIDI note on event and instrument sound appearing on DAC output. Therefore it included both software buffering and hardware I/O delays. The result was a pleasant surprise: only 8 ms.