Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::engine::session::RecordingManager Class Reference

Handles the recording logic for the application. More...

#include <src/engine/session/recording_manager.h>

Inheritance diagram for zrythm::engine::session::RecordingManager:
Collaboration diagram for zrythm::engine::session::RecordingManager:

Public Types

using AutomationTrack = structure::tracks::AutomationTrack
using AutomationRegion = structure::arrangement::AutomationRegion
using AutomationPoint = structure::arrangement::AutomationPoint

Public Member Functions

 RecordingManager (QObject *parent=nullptr)
 Creates the event queue and starts the event loop.
void handle_recording (structure::tracks::TrackPtrVariant track_var, const EngineProcessTimeInfo &time_nfo, const dsp::MidiEventVector *midi_events, std::optional< structure::tracks::TrackProcessor::ConstStereoPortPair > stereo_ports)
 Handles the recording logic inside the process cycle.
Q_SLOT void process_events ()
void start_unended_note (structure::arrangement::MidiRegion &mr, double start_pos, std::optional< double > end_pos, int pitch, int vel)
 Starts an unended note with the given pitch and velocity and adds it to midi_notes_.
structure::arrangement::MidiNotepop_unended_note (structure::arrangement::MidiRegion &mr, int pitch)
 Returns the midi note with the given pitch from the unended notes.
void get_aps_since_last_recorded (const structure::arrangement::AutomationRegion &ar, signed_frame_t pos, std::vector< AutomationPoint * > &aps) const
 Returns the automation points since the last recorded automation point (if the last recorded automation point was before the current pos).

Data Fields

int num_active_recordings_ = 0
 Number of recordings currently in progress.
MPMCQueue< RecordingEvent * > event_queue_
 Event queue.
ObjectPool< RecordingEventevent_obj_pool_
 Memory pool of event structs to avoid real time allocation.
std::vector< structure::arrangement::ArrangerObjectPtrVariant > objects_before_start_
 Cloned objects before starting recording.
std::vector< structure::arrangement::ArrangerObject::Uuidrecorded_ids_
 Recorded region identifiers, to be used for creating the undoable actions.
std::unordered_map< structure::arrangement::ArrangerObjectUuid, std::vector< QPointer< structure::arrangement::MidiNote > > > unended_notes_per_region_
 Unended notes started in recording with MIDI NOTE ON signal but haven't received a NOTE OFF yet.
std::unordered_map< structure::tracks::Track::Uuid, std::vector< QPointer< AutomationTrack > > > ats_in_record_mode_
 Cache of automation tracks in record mode, used to avoid looping over all automation tracks.
std::unordered_map< structure::arrangement::ArrangerObjectUuid, QPointer< AutomationPoint > > last_recorded_aps_per_region_
 Last recorded automation points.
std::unordered_map< structure::tracks::Track::Uuid, structure::arrangement::ArrangerObject::Uuidrecording_region_per_track_
 Region currently recording on.
std::unordered_set< structure::tracks::Track::Uuidtracks_recording_stop_was_sent_to_
 Tracks that recording stop event was sent.
std::unordered_set< structure::tracks::Track::Uuidtracks_recording_start_was_sent_to_
std::unordered_set< structure::tracks::Track::Uuidtracks_recording_was_paused_
 This must only be set by the RecordingManager when temporarily pausing recording, eg when looping or leaving the punch range.
std::vector< structure::arrangement::AutomationPoint * > pending_aps_
 Pending recorded automation points.
bool currently_processing_ = false
std::binary_semaphore processing_sem_ { 1 }
bool freeing_ = false

Detailed Description

Handles the recording logic for the application.

This class is responsible for managing the recording process, including handling recording events, creating new regions, and managing automation points. It uses a queue to process recording events in a separate thread, and provides methods for starting, pausing, and stopping recording.

The class is designed to be thread-safe, with a binary semaphore to ensure that only one thread can access the recording logic at a time.

Definition at line 39 of file recording_manager.h.

Member Typedef Documentation

◆ AutomationPoint

using zrythm::engine::session::RecordingManager::AutomationPoint = structure::arrangement::AutomationPoint

Definition at line 44 of file recording_manager.h.

◆ AutomationRegion

using zrythm::engine::session::RecordingManager::AutomationRegion = structure::arrangement::AutomationRegion

Definition at line 43 of file recording_manager.h.

◆ AutomationTrack

using zrythm::engine::session::RecordingManager::AutomationTrack = structure::tracks::AutomationTrack

Definition at line 42 of file recording_manager.h.

Constructor & Destructor Documentation

◆ RecordingManager()

zrythm::engine::session::RecordingManager::RecordingManager ( QObject * parent = nullptr)

Creates the event queue and starts the event loop.

Must be called from a GTK thread.

Member Function Documentation

◆ handle_recording()

void zrythm::engine::session::RecordingManager::handle_recording ( structure::tracks::TrackPtrVariant track_var,
const EngineProcessTimeInfo & time_nfo,
const dsp::MidiEventVector * midi_events,
std::optional< structure::tracks::TrackProcessor::ConstStereoPortPair > stereo_ports )

Handles the recording logic inside the process cycle.

The MidiEvents are already dequeued at this point.

Parameters
g_frames_startGlobal start frames.
nframesNumber of frames to process. If this is zero, a pause will be added. See RECORDING_EVENT_TYPE_PAUSE_TRACK_RECORDING and RECORDING_EVENT_TYPE_PAUSE_AUTOMATION_RECORDING.

◆ pop_unended_note()

structure::arrangement::MidiNote * zrythm::engine::session::RecordingManager::pop_unended_note ( structure::arrangement::MidiRegion & mr,
int pitch )

Returns the midi note with the given pitch from the unended notes.

Used when recording.

Parameters
pitchThe pitch. If -1, it returns any unended note. This is useful when the loop point is met and we want to end them all.

◆ start_unended_note()

void zrythm::engine::session::RecordingManager::start_unended_note ( structure::arrangement::MidiRegion & mr,
double start_pos,
std::optional< double > end_pos,
int pitch,
int vel )

Starts an unended note with the given pitch and velocity and adds it to midi_notes_.

Parameters
start_posPosition in ticks.
end_posIf this is nullopt, it will be set to 1 tick after the start_pos.

Field Documentation

◆ ats_in_record_mode_

std::unordered_map< structure::tracks::Track::Uuid, std::vector<QPointer<AutomationTrack> > > zrythm::engine::session::RecordingManager::ats_in_record_mode_

Cache of automation tracks in record mode, used to avoid looping over all automation tracks.

Definition at line 236 of file recording_manager.h.

◆ currently_processing_

bool zrythm::engine::session::RecordingManager::currently_processing_ = false

Definition at line 281 of file recording_manager.h.

◆ event_obj_pool_

ObjectPool<RecordingEvent> zrythm::engine::session::RecordingManager::event_obj_pool_

Memory pool of event structs to avoid real time allocation.

FIXME: just use another filled MPMCQueue and delete this hacky ObjectPool implementation.

Definition at line 209 of file recording_manager.h.

◆ event_queue_

MPMCQueue<RecordingEvent *> zrythm::engine::session::RecordingManager::event_queue_

Event queue.

Definition at line 201 of file recording_manager.h.

◆ freeing_

bool zrythm::engine::session::RecordingManager::freeing_ = false

Definition at line 284 of file recording_manager.h.

◆ last_recorded_aps_per_region_

std::unordered_map< structure::arrangement::ArrangerObjectUuid, QPointer<AutomationPoint> > zrythm::engine::session::RecordingManager::last_recorded_aps_per_region_

Last recorded automation points.

Definition at line 242 of file recording_manager.h.

◆ num_active_recordings_

int zrythm::engine::session::RecordingManager::num_active_recordings_ = 0

Number of recordings currently in progress.

Definition at line 198 of file recording_manager.h.

◆ objects_before_start_

std::vector<structure::arrangement::ArrangerObjectPtrVariant> zrythm::engine::session::RecordingManager::objects_before_start_

Cloned objects before starting recording.

Definition at line 213 of file recording_manager.h.

◆ pending_aps_

std::vector<structure::arrangement::AutomationPoint *> zrythm::engine::session::RecordingManager::pending_aps_

Pending recorded automation points.

Definition at line 279 of file recording_manager.h.

◆ processing_sem_

std::binary_semaphore zrythm::engine::session::RecordingManager::processing_sem_ { 1 }

Definition at line 282 of file recording_manager.h.

◆ recorded_ids_

std::vector<structure::arrangement::ArrangerObject::Uuid> zrythm::engine::session::RecordingManager::recorded_ids_

Recorded region identifiers, to be used for creating the undoable actions.

Definition at line 218 of file recording_manager.h.

◆ recording_region_per_track_

std::unordered_map< structure::tracks::Track::Uuid, structure::arrangement::ArrangerObject::Uuid> zrythm::engine::session::RecordingManager::recording_region_per_track_

Region currently recording on.

This must only be set when processing an event.

Definition at line 252 of file recording_manager.h.

◆ tracks_recording_start_was_sent_to_

std::unordered_set<structure::tracks::Track::Uuid> zrythm::engine::session::RecordingManager::tracks_recording_start_was_sent_to_

Definition at line 268 of file recording_manager.h.

◆ tracks_recording_stop_was_sent_to_

std::unordered_set<structure::tracks::Track::Uuid> zrythm::engine::session::RecordingManager::tracks_recording_stop_was_sent_to_

Tracks that recording stop event was sent.

Ported from RecordableTrack. Below are old docs:

This is a flag to let the recording manager know that a STOP signal was already sent for recording.i

This is because recording_region_ takes a cycle or 2 to become NULL.

Definition at line 265 of file recording_manager.h.

◆ tracks_recording_was_paused_

std::unordered_set<structure::tracks::Track::Uuid> zrythm::engine::session::RecordingManager::tracks_recording_was_paused_

This must only be set by the RecordingManager when temporarily pausing recording, eg when looping or leaving the punch range.

See RECORDING_EVENT_TYPE_PAUSE_TRACK_RECORDING.

Definition at line 276 of file recording_manager.h.

◆ unended_notes_per_region_

std::unordered_map< structure::arrangement::ArrangerObjectUuid, std::vector<QPointer<structure::arrangement::MidiNote> > > zrythm::engine::session::RecordingManager::unended_notes_per_region_

Unended notes started in recording with MIDI NOTE ON signal but haven't received a NOTE OFF yet.

Definition at line 227 of file recording_manager.h.


The documentation for this class was generated from the following file: