|
Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
|
Lock-free SPSC buffer for MIDI events between the MIDI device thread and the audio thread. More...
#include <src/dsp/midi_device_buffer.h>
Public Member Functions | |
| MidiDeviceBuffer (const MidiDeviceBuffer &)=delete | |
| MidiDeviceBuffer & | operator= (const MidiDeviceBuffer &)=delete |
| MidiDeviceBuffer (MidiDeviceBuffer &&)=delete | |
| MidiDeviceBuffer & | operator= (MidiDeviceBuffer &&)=delete |
| bool | push (juce::MidiMessage &&message) |
| Push a MIDI message onto the queue. | |
| bool | push (const juce::MidiMessage &message) |
| void | drain (juce::MidiBuffer &output, units::sample_rate_t sample_rate, units::sample_u32_t nframes, std::optional< units::precise_second_t > block_start_time=std::nullopt) noexcept |
Drain all queued events into output, converting timestamps to sample offsets within the current audio block. | |
| void | clear () noexcept |
| Discard all pending events without processing. | |
Static Public Attributes | |
| static constexpr size_t | kCapacity = 4096 |
Lock-free SPSC buffer for MIDI events between the MIDI device thread and the audio thread.
MIDI thread calls push() with juce::MidiMessage objects carrying JUCE timestamps (seconds from Time::getMillisecondCounterHiRes() * 0.001).
Audio thread calls drain() to convert timestamps to sample offsets and append events to a juce::MidiBuffer.
Definition at line 25 of file midi_device_buffer.h.
|
noexcept |
Discard all pending events without processing.
Called from the audio thread. RT-safe.
|
noexcept |
Drain all queued events into output, converting timestamps to sample offsets within the current audio block.
Called from the audio thread. RT-safe.
When block_start_time is provided, all events are offset relative to that wall-clock time, giving sample-accurate positioning within the block. When not provided, the first event is placed at sample 0 and subsequent events are offset relative to it.
| output | Target MidiBuffer to append events to. |
| sample_rate | Current sample rate. |
| nframes | Number of frames in the current audio block. |
| block_start_time | Wall-clock time at block start, if available. |
|
inline |
Definition at line 48 of file midi_device_buffer.h.
| bool zrythm::dsp::MidiDeviceBuffer::push | ( | juce::MidiMessage && | message | ) |
Push a MIDI message onto the queue.
Called from the MIDI device thread. Not necessarily RT-safe.
| message | MIDI message with a JUCE timestamp (seconds). |
|
staticconstexpr |
Definition at line 28 of file midi_device_buffer.h.