|
Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
|
Per-track recording state with a lock-free SPSC queue. More...
#include <src/controllers/recording_session.h>
Public Types | |
| enum class | State : uint8_t { Armed , Capturing , Finalizing } |
| using | PacketType = Packet |
Public Member Functions | |
| RecordingSession (units::sample_u32_t max_block_length) | |
| void | prepare_for_processing (units::sample_u32_t block_length) |
| Prepares internal buffers for processing at the given block length. | |
| void | write (units::sample_t timeline_position, bool transport_recording, std::span< const float > l_data, std::span< const float > r_data) noexcept |
| RT-safe: writes audio data into the ring buffer. | |
| void | write (units::sample_t timeline_position, bool transport_recording, std::span< const dsp::MidiEvent > midi_events, units::sample_u32_t nframes) noexcept |
| RT-safe: writes MIDI events into the ring buffer. | |
| std::vector< Packet > | drain_pending () |
| Non-RT: drains all pending packets from the ring buffer. | |
| auto | state () const |
| void | finalize () noexcept |
| Transitions to Finalizing state, rejecting further writes. | |
| void | reset () |
| Resets the session to Armed state for reuse. | |
| uint64_t | dropped_packets () const |
Static Public Attributes | |
| static constexpr size_t | kFifoCapacity = 1024 |
Per-track recording state with a lock-free SPSC queue.
The RT thread writes packets into pre-allocated slots and pushes slot indices onto a farbot SPSC fifo. The non-RT timer drains pending indices and reads the corresponding slot data into Packet objects.
| Packet | The packet type (RecordingAudioPacket or RecordingMidiPacket). Must provide static copy_from(slot, source) and resize(slot, block_length). |
Thread contracts:
Definition at line 43 of file recording_session.h.
| using zrythm::controllers::RecordingSession< Packet >::PacketType = Packet |
Definition at line 60 of file recording_session.h.
|
strong |
Definition at line 46 of file recording_session.h.
|
nodiscard |
Non-RT: drains all pending packets from the ring buffer.
Called from the timer thread. Reads slot indices from the SPSC fifo and copies the slot data into Packet objects.
|
inlinenodiscard |
Definition at line 119 of file recording_session.h.
| void zrythm::controllers::RecordingSession< Packet >::prepare_for_processing | ( | units::sample_u32_t | block_length | ) |
Prepares internal buffers for processing at the given block length.
Must be called before audio processing starts (not concurrently with write() or drain_pending()).
|
inlinenodiscard |
Definition at line 104 of file recording_session.h.
|
noexcept |
RT-safe: writes MIDI events into the ring buffer.
Called from the audio thread. No allocations — copies events into pre-allocated slot memory and pushes the slot index onto the SPSC fifo.
|
noexcept |
RT-safe: writes audio data into the ring buffer.
Called from the audio thread. No allocations — copies data into pre-allocated slot memory and pushes the slot index onto the SPSC fifo.
|
staticconstexpr |
Definition at line 58 of file recording_session.h.