Skip to main content

Crate oxurack_rt

Crate oxurack_rt 

Source
Expand description

Real-time MIDI clock and I/O thread for oxurack.

oxurack-rt runs on a dedicated OS thread elevated to real-time priority. It handles:

  • Clock generation (master mode) at a configurable tempo, producing 24-PPQN MIDI clock ticks.
  • Clock tracking (slave mode) using a PLL-based tempo estimator locked to an external MIDI clock source.
  • Clock passthrough (passthrough mode) forwarding an external clock to output ports with optional multiplication/division.
  • MIDI I/O via midir, forwarding input messages to the ECS world and sending output messages on command.
  • Lock-free communication with the ECS world through bounded SPSC queues (rtrb).

§Architecture

┌────────────────────┐     rtrb queues     ┌──────────────────┐
│   ECS world        │◄═══ RtEvent ═══════►│   RT thread      │
│ (RtHandles)        │════ EcsCommand ════►│ (rt_thread_main) │
└────────────────────┘                     └──────────────────┘

The caller creates a Runtime via Runtime::start, receiving RtHandles for queue access. Dropping the Runtime (or calling Runtime::stop) shuts down the thread gracefully.

Modules§

clock
Clock subsystem: master clock generation, slave clock tracking, and shared scheduling types.

Structs§

MidiInputConfig
Configuration for a MIDI input port connection.
MidiOutputConfig
Configuration for a MIDI output port connection.
RtHandles
The ECS-side handles for communicating with the RT thread.
Runtime
Handle to the running RT thread.
RuntimeConfig
Full configuration for starting the RT runtime.

Enums§

ClockMode
Selects how the RT thread generates or tracks MIDI clock.
EcsCommand
A command sent from the ECS world to the RT thread.
Error
Errors that can occur during real-time MIDI operations.
RtErrorCode
Error codes for non-fatal conditions reported by the RT thread.
RtEvent
An event produced by the RT thread for consumption by the ECS world.
TransportEvent
Transport state change events.

Functions§

list_midi_input_ports
Lists the names of all available MIDI input ports on the system.
list_midi_output_ports
Lists the names of all available MIDI output ports on the system.

Type Aliases§

MidiMessage
A compact MIDI message representation.