|
Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
|
Orchestrates the recording lifecycle across all armed tracks. More...
#include <src/controllers/recording_coordinator.h>


Signals | |
| void | audioDataReady (structure::tracks::TrackUuid track_id, std::vector< RecordingAudioPacket > packets) |
| Emitted when recorded audio data has been drained from a session. | |
| void | recordingSessionEnded () |
| Emitted when a recording take has been finalized. | |
Public Member Functions | |
| RecordingCoordinator (QObject *parent=nullptr) | |
| void | arm_track (structure::tracks::TrackUuid track_id, units::sample_u32_t max_block_length) |
| Arms a track for recording. | |
| void | disarm_track (structure::tracks::TrackUuid track_id) |
| Disarms a track. | |
| bool | has_session (structure::tracks::TrackUuid track_id) const |
| Returns whether a session exists for the given track. | |
| void | process_pending () |
| Drains all active sessions and processes pending deletions. | |
| Q_SLOT void | finalizeAllSessions () |
| Finalizes the current recording take and resets sessions for reuse. | |
| AudioRecordingSession * | session_for_track (structure::tracks::TrackUuid track_id) const noexcept |
| Gets the session for a track (for RT callback access). | |
| void | prepare_for_processing (units::sample_u32_t block_length) |
| Prepares all active sessions for processing at the given block length. | |
Static Public Attributes | |
| static constexpr auto | kDrainInterval = std::chrono::milliseconds (100) |
Orchestrates the recording lifecycle across all armed tracks.
Owns per-track AudioRecordingSession objects and runs a periodic timer that drains recorded audio from each session's ring buffer for region creation.
Session access from RT threads is mediated by an atomic snapshot pointer (rt_snapshot_). The non-RT thread publishes new snapshots via atomic exchange after arm/disarm operations; RT threads read via atomic load. This guarantees lock-free, allocation-free RT reads and supports multiple concurrent RT readers (the DSP graph processes nodes in parallel).
Old snapshots are deferred: publish_snapshot() moves the previous snapshot to a pending-deletion list. process_pending() clears that list, which runs at least kDrainInterval (100 ms) after the last publish. Since audio callbacks complete in ~1-10 ms, all RT threads have long since loaded a newer snapshot before any old snapshot is destroyed.
Definition at line 45 of file recording_coordinator.h.
| void zrythm::controllers::RecordingCoordinator::arm_track | ( | structure::tracks::TrackUuid | track_id, |
| units::sample_u32_t | max_block_length ) |
Arms a track for recording.
Creates an AudioRecordingSession.
Must be called from the non-RT thread.
|
signal |
Emitted when recorded audio data has been drained from a session.
Connected consumers (e.g. RecordingMaterializer) use this to create or expand regions from the recorded audio packets.
| void zrythm::controllers::RecordingCoordinator::disarm_track | ( | structure::tracks::TrackUuid | track_id | ) |
Disarms a track.
Moves session to pending deletion.
Must be called from the non-RT thread.
| Q_SLOT void zrythm::controllers::RecordingCoordinator::finalizeAllSessions | ( | ) |
Finalizes the current recording take and resets sessions for reuse.
Drains all pending audio data from active sessions, emits audioDataReady for each track with data, then emits recordingSessionEnded to finalize the undo macro. Sessions are reset to Armed state rather than destroyed, so they accept new writes when recording resumes (e.g., after transport restart).
Intended to be called when transport stops. Sessions are only destroyed via disarm_track().
Must be called from the non-RT thread.
|
nodiscard |
Returns whether a session exists for the given track.
Must be called from the same non-RT thread as arm_track()/disarm_track().
| void zrythm::controllers::RecordingCoordinator::prepare_for_processing | ( | units::sample_u32_t | block_length | ) |
Prepares all active sessions for processing at the given block length.
Buffers are only grown, never shrunk. Must be called before audio processing starts (not concurrently with write_samples() or drain_pending()).
| void zrythm::controllers::RecordingCoordinator::process_pending | ( | ) |
Drains all active sessions and processes pending deletions.
Called by the internal timer. May be called manually only when no RT processing is occurring simultaneously (e.g., engine stopped).
|
signal |
Emitted when a recording take has been finalized.
Fires from finalizeAllSessions() after all pending audio data is drained and sessions are reset to Armed state. Consumers should finalize any open recording context (e.g. closing an undo macro) when this signal is received — no more audio data will arrive for this take. Sessions remain alive and can accept new writes when recording resumes.
|
nodiscardnoexcept |
Gets the session for a track (for RT callback access).
Safe to call from multiple RT threads concurrently. Returns nullptr if no session exists.
|
staticconstexpr |
Definition at line 50 of file recording_coordinator.h.