UART MIDI latency optimization and dynamics

Writing software for systems that use VLSI Solution's devices as slave codecs to a host microcontroller.
Post Reply
Musician
User
Posts: 1
Joined: Sun 2024-09-29 21:32

UART MIDI latency optimization and dynamics

Post by Musician »

Hello,

I'm trying to construct an electronic instrument with the VS1053 as MIDI synthesizer. Currently I'm using it mounted on a Adafruit board (id 3357) together with an RP2040 MCU (mounted on Adafruits RP2040 "scorpio" feather), but the plan is to design a custom PCB in the future with possibly smaller MCU and VLSI chip if there are any which still supports MIDI over UART.

I have two main issues: latency and dynamics.

Latency: I have measured my device to have approximately 15 us input lag from user input until it starts sending the UART frame. After this, it takes approximately 10-20 ms until I see any change on the headphone output. I have read that the different virtual instruments have different attack, which can roughly be described as the rise time of the sound signal envelope. Currently I'm using instrument #21, "reed organ". Is this amount of delay expected, do you have any advice on any other instrument which might have less delay until the output starts to change, or any other advice how to minimize the delay?

Dynamics: I'm trying to achieve the possibility to hold a tone for an arbitrary amount of time while adjusting the volume, similar to what is achievable with a violin, an accordion or a flute. How is this best done? I have tried to continuously send channel volume update commands, but they need to come very often and be small for the human ear to not interpret them as discrete steps. I also suspect the chip's RX buffer might overflow from commands being sent too fast. Do you have any command for general volume adjustment or volume adjustment for all channels at once? Or do you have any other advice?
I'm thinking of feeding the output signal to a summarizing OP amp circuit or similar, feeding the other input with a volume adjustment signal from a DAC in the MCU, but this adds complexity with uncertain result.

I'm grateful for any help, thanks in advance!
User avatar
pasi
VLSI Staff
Posts: 2164
Joined: Thu 2010-07-15 16:04

Re: UART MIDI latency optimization and dynamics

Post by pasi »

For Real-Time MIDI latency, see: viewtopic.php?p=16081

You're right that the UART FIFO has a chance of being overrun with the ROM code when a lot of notes are active (but see the above for a patch).

The MIDI decoder generates output in 64-sample blocks. Volume changes that are given through MIDI commands are interpreted and applied at the 64-sample boundary, and the output is faded from the start to the end of the block. This may be why small changes are undetectable.

Note's volume is a combination of note velocity, channel volume, channel expression, and master volume. Master volume adjusts everything at once. Also see www.vsdsp-forum.com/phpbb/viewtopic.php?p=15251

If you had access to the Serial Control Bus (SCI), you could give volume commands directly to the DAC instead.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
Post Reply