Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
recordable_track.h
1// SPDX-FileCopyrightText: © 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "dsp/parameter.h"
7#include "dsp/processor_base.h"
8
9#include <QtQmlIntegration>
10
11namespace zrythm::structure::tracks
12{
16class RecordableTrackMixin : public QObject
17{
18 Q_OBJECT
19 Q_PROPERTY (
20 bool recording READ recording WRITE setRecording NOTIFY recordingChanged)
21 QML_ELEMENT
22 QML_UNCREATABLE ("")
23
24public:
25 using NameProvider = std::function<utils::Utf8String ()>;
26
27 RecordableTrackMixin (
29 NameProvider name_provider,
30 QObject * parent = nullptr);
31 ~RecordableTrackMixin () override = default;
32 Z_DISABLE_COPY_MOVE (RecordableTrackMixin)
33
34 // ========================================================================
35 // QML Interface
36 // ========================================================================
37
38 [[gnu::hot]] bool recording () const
39 {
40 const auto &recording_param = get_recording_param ();
41 return recording_param.range ().is_toggled (recording_param.baseValue ());
42 }
43 void setRecording (bool recording);
44 Q_SIGNAL void recordingChanged (bool recording);
45
46 // ========================================================================
47
48 dsp::ProcessorParameter &get_recording_param () const
49 {
50 return *recording_id_.get_object_as<dsp::ProcessorParameter> ();
51 }
52
53private:
54 static constexpr auto kRecordingIdKey = "recordingId"sv;
55 static constexpr auto kRecordSetAutomaticallyKey = "recordSetAutomatically"sv;
56 friend void to_json (nlohmann::json &j, const RecordableTrackMixin &track)
57 {
58 j[kRecordingIdKey] = track.recording_id_;
59 j[kRecordSetAutomaticallyKey] = track.record_set_automatically_;
60 }
61 friend void from_json (const nlohmann::json &j, RecordableTrackMixin &track)
62 {
63 track.recording_id_ = { track.dependencies_.param_registry_ };
64 j.at (kRecordingIdKey).get_to (track.recording_id_);
65 j.at (kRecordSetAutomaticallyKey).get_to (track.record_set_automatically_);
66 }
67
68 friend void init_from (
69 RecordableTrackMixin &obj,
70 const RecordableTrackMixin &other,
71 utils::ObjectCloneType clone_type)
72 {
73 obj.recording_id_ = other.recording_id_;
75 }
76
77private:
79
80 // Used for debugging.
81 NameProvider name_provider_;
82
84 dsp::ProcessorParameterUuidReference recording_id_;
85
86public:
95 bool record_set_automatically_ = false;
96};
97}
Processor parameter that accepts automation and modulation sources and integrates with QML and the DS...
Definition parameter.h:225
bool record_set_automatically_
Whether record was set automatically when the channel was selected.
Lightweight UTF-8 string wrapper with safe conversions.
Definition utf8_string.h:38