Re:Optimizing latency of an Arduino MIDI controller
by kazinator on Tuesday August 29, 2017 @02:01PM
(#15126261)
Low latency is useful if many devices are chained together. If you have a chain of ten, 80us becomes 800us: 0.8ms. That is still very good.
The original MIDI was designed for (reasonable) serial chaining; many devices have a MIDI IN and OUT port (and some have a THROUGH).
In spite of this, the protocol runs at only 31250 bps. It takes 10 bits (8N1) to encode one byte, and it takes something like 3 bytes to encode a "note on" message (for instance). The message is consequently 960 us wide: almost 1 ms!
So with no chaining of anything, just connecting a MIDI source (like a keyboard) to a synthesizer with a MIDI cable, we have a 1 ms minimum delay to turn on a note caused by the sheer duration of the message on the wire.
192 kHz sample rate for storage and transmission of audio is complete, utter bunk.
For sampling, oversampling is useful because it's easier and cheaper to make a fast ADC, and couple it with a cheaper, simpler analog filter. If you want to sample at 44.1 kHz or even 48 kHz, and capture a decent range of the audio spectrum without aliasing, you need a very steep "brick wall" filter at the Nyquist frequency. But if you sample at 192 kHz (with an aim to capturing the same spectrum), the filter doesn't need to be that steep. You still roll off past 20 kHz, but less aggressively. Not only is that simpler and cheaper, but the filter can be designed with better properties in regard to phase shift and group delay, and flatter response near the threshold. Of course, the idea is then to immediately reduce the data from the sampler to a lower rate. It's like moving much of the filter into the digital domain.
The original MIDI was designed for (reasonable) serial chaining; many devices have a MIDI IN and OUT port (and some have a THROUGH).
In spite of this, the protocol runs at only 31250 bps. It takes 10 bits (8N1) to encode one byte, and it takes something like 3 bytes to encode a "note on" message (for instance). The message is consequently 960 us wide: almost 1 ms!
So with no chaining of anything, just connecting a MIDI source (like a keyboard) to a synthesizer with a MIDI cable, we have a 1 ms minimum delay to turn on a note caused by the sheer duration of the message on the wire.
192 kHz sample rate for storage and transmission of audio is complete, utter bunk.
For sampling, oversampling is useful because it's easier and cheaper to make a fast ADC, and couple it with a cheaper, simpler analog filter. If you want to sample at 44.1 kHz or even 48 kHz, and capture a decent range of the audio spectrum without aliasing, you need a very steep "brick wall" filter at the Nyquist frequency. But if you sample at 192 kHz (with an aim to capturing the same spectrum), the filter doesn't need to be that steep. You still roll off past 20 kHz, but less aggressively. Not only is that simpler and cheaper, but the filter can be designed with better properties in regard to phase shift and group delay, and flatter response near the threshold. Of course, the idea is then to immediately reduce the data from the sampler to a lower rate. It's like moving much of the filter into the digital domain.