Audio block / vector size? Midi time frame? Scheduler?

I’m wondering how the VCV-Rack standalone application schedules audio and midi internaly and in connection with Alsa, Jack or the operation system? Does Rack compute the real-time audio stream with a fixed block-size of samples?

Is there some buffering and latency happening between the modules in the Rack? How does VCV handle DSP feedback loops in-between modules?

And how is Midi handeled? How often are external inputs read out and when does a Midi buffer get flushed? What is RTmidi in VCV compared to normal Midi? What priotity does Midi have in comparison to audio and other tasks, such as the GUI?

Particularly asking for a Linux Jack enviroment. But also interested in Windows.

Where can I find the scheduler in the source code?

Would be thankful if we could sort this out or approach it.

All audio drivers send/request a block of audio to/from the application that uses their API. Rack is no different. The block size requested by the audio driver can change at any time. Rack can handle it.

Yes, each cable has one sample of latency.

Rack plugins can use Rack’s MIDI API at any time. As soon as a module’s source code calls rack::midi::Output::sendMessage(), the MIDI message is sent to the MIDI driver’s API. At this point, it’s up to the MIDI driver what happens next.

When a MIDI message is sent from a device to your computer, the MIDI driver calls an application’s callback function. For Rack, this message is passed to virtual void rack::midi::Input::onMessage() on the same thread. It’s up to the Rack plugin to subclass midi::Input and override this method to do something with it. A helper class, midi::InputQueue is available if you prefer “pulling” MIDI messages when you’re ready, rather than MIDI messages being “pushed” to you. All of VCV’s MIDI modules use this helper class in order to check and pull new MIDI messages in their rack::engine::Module::process() method.

Rack v2 adds timestamps to MIDI messages, so when a plugin sends a MIDI message, a worker thread waits until it is ready to be sent and then sends it. And similarly, when a MIDI message is received, it is “stamped” with the current timestamp. VCV’s MIDI modules wait until the timestamp corresponding to the audio frame is greater than the timestamp of the MIDI message.

I think your other questions can be answered by understanding the above.

4 Likes