Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
arranger_object.h
1// SPDX-FileCopyrightText: © 2019-2022, 2024-2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <string_view>
7#include <vector>
8
9#include "dsp/position.h"
10#include "dsp/tempo_map_qml_adapter.h"
11#include "structure/arrangement/arranger_object_fwd.h"
12#include "structure/arrangement/colored_object.h"
13#include "structure/arrangement/muteable_object.h"
14#include "structure/arrangement/named_object.h"
15#include "utils/enum_utils.h"
16#include "utils/typed_uuid_reference.h"
17#include "utils/units.h"
18
19#include <QtQmlIntegration/qqmlintegration.h>
20
21using std::literals::string_view_literals::operator""sv;
22
23namespace zrythm::structure::arrangement
24{
25
35class ArrangerObject : public utils::UuidIdentifiableObject<ArrangerObject>
36{
37 Q_OBJECT
38 QML_ELEMENT
39 Q_PROPERTY (
41 parentObject WRITE setParentObject NOTIFY parentObjectChanged)
42 Q_PROPERTY (
44 Q_PROPERTY (zrythm::dsp::Position * position READ position CONSTANT)
45 Q_PROPERTY (zrythm::dsp::ContentPosition * length READ length CONSTANT)
46 Q_PROPERTY (
48 Q_PROPERTY (
50 CONSTANT)
51 Q_PROPERTY (
53 mute CONSTANT)
54 QML_UNCREATABLE ("")
55
56public:
60 enum class Type : std::uint8_t
61 {
70 Marker,
75 };
76 Q_ENUM (Type)
77
78public:
79 ~ArrangerObject () noexcept override;
80 Q_DISABLE_COPY_MOVE (ArrangerObject)
81
82 // ========================================================================
83 // QML Interface
84 // ========================================================================
85
86 auto type () const { return type_; }
87
88 virtual dsp::Position * position () const { return position_.get (); }
89
90 dsp::ContentPosition * length () const { return length_.get (); }
91 ArrangerObjectName * name () const { return name_.get (); }
92 ArrangerObjectColor * color () const { return color_.get (); }
93 ArrangerObjectMuteFunctionality * mute () const { return mute_.get (); }
94
98 Q_SIGNAL void propertiesChanged ();
99
100 ArrangerObject * parentObject () const { return parent_object_; }
101 void setParentObject (ArrangerObject * object);
102 Q_SIGNAL void parentObjectChanged (QObject * parentObject);
103
104 // ========================================================================
105
106 // Convenience getter
107 const dsp::TempoMap &get_tempo_map () const;
108 const dsp::TempoMapWrapper &get_tempo_map_wrapper () const
109 {
110 return tempo_map_wrapper_;
111 }
112
113 virtual std::vector<ArrangerObjectListModel *> get_child_list_models () const
114 {
115 return {};
116 }
117
118protected:
119 enum class ArrangerObjectFeatures : std::uint8_t
120 {
121 Bounds = 1 << 0,
122 Name = 1 << 1,
123 Color = 1 << 2,
124 Mute = 1 << 3,
125 ClipOwned = 1 << 4,
126 };
127
136 Type type,
137 const dsp::TempoMapWrapper &tempo_map_wrapper,
138 ArrangerObjectFeatures features,
139 QObject * parent = nullptr) noexcept;
140
141 friend void init_from (
142 ArrangerObject &obj,
143 const ArrangerObject &other,
144 utils::ObjectCloneType clone_type);
145
146private:
147 static constexpr auto kPositionKey = "position"sv;
148 static constexpr auto kLengthKey = "length"sv;
149 static constexpr auto kNameKey = "name"sv;
150 static constexpr auto kColorKey = "color"sv;
151 static constexpr auto kMuteKey = "mute"sv;
152 friend void
153 to_json (nlohmann::json &j, const ArrangerObject &arranger_object);
154 friend void
155 from_json (const nlohmann::json &j, ArrangerObject &arranger_object);
156
157private:
158 Type type_;
159
160 const dsp::TempoMapWrapper &tempo_map_wrapper_;
161
163 utils::QObjectUniquePtr<dsp::Position> position_;
164
165 utils::QObjectUniquePtr<dsp::ContentPosition> length_;
166 utils::QObjectUniquePtr<ArrangerObjectName> name_;
167 utils::QObjectUniquePtr<ArrangerObjectColor> color_;
168 utils::QObjectUniquePtr<ArrangerObjectMuteFunctionality> mute_;
169
177 QPointer<ArrangerObject> parent_object_;
178
179 BOOST_DESCRIBE_CLASS (
181 (UuidIdentifiableObject<ArrangerObject>),
182 (),
183 (),
184 (type_, length_, mute_, color_, name_))
185};
186
187using ArrangerObjectUuidReference = utils::TypedUuidReference<ArrangerObject>;
188
189template <typename T>
191 std::derived_from<T, ArrangerObject> && utils::CompleteType<T>;
192}
A Position whose ticks are content-space (clip-local) ticks.
Definition position.h:118
An observable, serializable musical position stored as ticks.
Definition position.h:33
Name functionality for arranger objects.
Base class for all objects in the arranger.
Q_SIGNAL void propertiesChanged()
Emitted when any of the properties of the object changed.
ArrangerObject(Type type, const dsp::TempoMapWrapper &tempo_map_wrapper, ArrangerObjectFeatures features, QObject *parent=nullptr) noexcept
Construct a new ArrangerObject.
A clip for playing back audio samples.
Definition audio_clip.h:24
Represents an automation clip, which contains a collection of automation points.
An automation point inside an AutomationTrack.
A chord placed inside a ChordClip on the chord track.
Marker for the MarkerTrack.
Definition marker.h:18
A Clip containing MIDI events.
Definition midi_clip.h:26
A MIDI note inside a Clip shown in the piano roll.
Definition midi_note.h:23
CRTP base that adds a typed UUID strong-typedef to a class hierarchy.
String utilities.