8#include "engine/session/recording_event.h"
9#include "structure/arrangement/automation_point.h"
10#include "structure/tracks/track_all.h"
11#include "utils/mpmc_queue.h"
12#include "utils/object_pool.h"
13#include "utils/types.h"
15namespace zrythm::structure::tracks
20#define RECORDING_MANAGER (gZrythm->recording_manager_)
22namespace zrythm::engine::session
25QT_WARNING_DISABLE_DEPRECATED
67 structure::tracks::TrackPtrVariant track_var,
70 std::optional<structure::tracks::TrackProcessor::ConstStereoPortPair>
73 Q_SLOT
void process_events ();
86 std::optional<double> end_pos,
108 std::vector<AutomationPoint *> &aps)
const;
111 void handle_start_recording (
const RecordingEvent &ev,
bool is_automation);
146 AutomationPoint * create_automation_point (
147 AutomationTrack * at,
148 AutomationRegion ®ion,
150 float normalized_val,
153 void handle_stop_recording (
bool is_automation);
162 void delete_automation_points (
163 AutomationTrack * at,
164 AutomationRegion ®ion,
187 "{} - lane {} - recording", track_name,
192 std::optional<structure::arrangement::ArrangerObjectPtrVariant>
193 get_recording_region_for_track (
212 std::vector<structure::arrangement::ArrangerObjectPtrVariant>
225 structure::arrangement::ArrangerObjectUuid,
226 std::vector<QPointer<structure::arrangement::MidiNote>>>
235 std::vector<QPointer<AutomationTrack>>>
240 structure::arrangement::ArrangerObjectUuid,
241 QPointer<AutomationPoint>>
264 std::unordered_set<structure::tracks::Track::Uuid>
267 std::unordered_set<structure::tracks::Track::Uuid>
268 tracks_recording_start_was_sent_to_;
281 bool currently_processing_ =
false;
282 std::binary_semaphore processing_sem_{ 1 };
284 bool freeing_ =
false;
290 std::unique_ptr<juce::TimeSliceThread> time_slice_thread_;
Multiple Producer Multiple Consumer lock-free queue.
Thread-safe, realtime-safe object pool.
A lock-free thread-safe vector of MidiEvents.
std::vector< structure::arrangement::ArrangerObject::Uuid > recorded_ids_
Recorded region identifiers, to be used for creating the undoable actions.
int num_active_recordings_
Number of recordings currently in progress.
std::unordered_set< structure::tracks::Track::Uuid > tracks_recording_stop_was_sent_to_
Tracks that recording stop event was sent.
ObjectPool< RecordingEvent > event_obj_pool_
Memory pool of event structs to avoid real time allocation.
std::unordered_map< structure::arrangement::ArrangerObjectUuid, QPointer< AutomationPoint > > last_recorded_aps_per_region_
Last recorded automation points.
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_.
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.
structure::arrangement::MidiNote * pop_unended_note(structure::arrangement::MidiRegion &mr, int pitch)
Returns the midi note with the given pitch from the unended notes.
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.
RecordingManager(QObject *parent=nullptr)
Creates the event queue and starts the event loop.
MPMCQueue< RecordingEvent * > event_queue_
Event queue.
std::vector< structure::arrangement::AutomationPoint * > pending_aps_
Pending recorded automation points.
std::vector< structure::arrangement::ArrangerObjectPtrVariant > objects_before_start_
Cloned objects before starting recording.
std::unordered_set< structure::tracks::Track::Uuid > tracks_recording_was_paused_
This must only be set by the RecordingManager when temporarily pausing recording, eg when looping or ...
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.
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 automati...
std::unordered_map< structure::tracks::Track::Uuid, structure::arrangement::ArrangerObject::Uuid > recording_region_per_track_
Region currently recording on.
An automation point inside an AutomationTrack.
Represents an automation region, which contains a collection of automation points.
A MIDI note inside a Region shown in the piano roll.
A Region containing MIDI events.
A TrackProcessor is a standalone processor that is used as the first step when processing a track in ...
Lightweight UTF-8 string wrapper with safe conversions.
static constexpr Utf8String from_utf8_encoded_string(std::string_view str)
Construct from a std::string_view that we are 100% sure is UTF8-encoded.
int_fast64_t signed_frame_t
Signed type for frame index.
Common struct to pass around during processing to avoid repeating the data in function arguments.