Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
track.h
1// SPDX-FileCopyrightText: © 2018-2022, 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "dsp/modulator_macro_processor.h"
7#include "structure/tracks/automation_tracklist.h"
8#include "structure/tracks/channel.h"
9#include "structure/tracks/piano_roll_track.h"
10#include "structure/tracks/recordable_track.h"
11#include "structure/tracks/track_fwd.h"
12#include "structure/tracks/track_lane_list.h"
13#include "structure/tracks/track_processor.h"
14#include "utils/format.h"
15#include "utils/playback_cache_scheduler.h"
16
17#include <QColor>
18#include <QtQmlIntegration>
19
20namespace zrythm::dsp
21{
22class MidiPlaybackCache;
23class TempoMapWrapper;
24}
25
26namespace zrythm::structure::tracks
27{
28using SoloedTracksExistGetter = GenericBoolGetter;
29
31{
32 const dsp::TempoMapWrapper &tempo_map_;
33 dsp::FileAudioSourceRegistry &file_audio_source_registry_;
34 plugins::PluginRegistry &plugin_registry_;
35 dsp::PortRegistry &port_registry_;
36 dsp::ProcessorParameterRegistry &param_registry_;
37 arrangement::ArrangerObjectRegistry &obj_registry_;
38 const dsp::ITransport &transport_;
39 SoloedTracksExistGetter soloed_tracks_exist_getter_;
40};
41
53class Track : public QObject, public utils::UuidIdentifiableObject<Track>
54{
55 Q_OBJECT
56 Q_PROPERTY (Type type READ type CONSTANT)
57 Q_PROPERTY (
58 zrythm::structure::tracks::AutomationTracklist * automationTracklist READ
59 automationTracklist CONSTANT)
60 Q_PROPERTY (QString name READ name WRITE setName NOTIFY nameChanged)
61 Q_PROPERTY (QColor color READ color WRITE setColor NOTIFY colorChanged)
62 Q_PROPERTY (
63 QString comment READ comment WRITE setComment NOTIFY commentChanged)
64 Q_PROPERTY (QString icon READ icon WRITE setIcon NOTIFY iconChanged)
65 Q_PROPERTY (bool visible READ visible WRITE setVisible NOTIFY visibleChanged)
66 Q_PROPERTY (bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
67 Q_PROPERTY (double height READ height WRITE setHeight NOTIFY heightChanged)
68 Q_PROPERTY (
69 double fullVisibleHeight READ fullVisibleHeight NOTIFY
70 fullVisibleHeightChanged)
71 Q_PROPERTY (zrythm::structure::tracks::Channel * channel READ channel CONSTANT)
72 Q_PROPERTY (zrythm::plugins::PluginGroup * modulators READ modulators CONSTANT)
73 Q_PROPERTY (
74 zrythm::structure::tracks::TrackLaneList * lanes READ lanes CONSTANT)
75 Q_PROPERTY (
76 zrythm::structure::tracks::RecordableTrackMixin * recordableTrackMixin READ
77 recordableTrackMixin CONSTANT)
78 Q_PROPERTY (
79 zrythm::structure::tracks::PianoRollTrackMixin * pianoRollTrackMixin READ
80 pianoRollTrackMixin CONSTANT)
81 Q_PROPERTY (
82 bool clipLauncherMode READ clipLauncherMode WRITE setClipLauncherMode NOTIFY
83 clipLauncherModeChanged)
84 QML_ELEMENT
85 QML_UNCREATABLE ("")
86public:
87 using Plugin = plugins::Plugin;
88 using PluginUuid = Plugin::Uuid;
89 using PortType = dsp::PortType;
90 using PluginRegistry = plugins::PluginRegistry;
91 using PluginPtrVariant = PluginRegistry::VariantType;
92 using PluginSlot = plugins::PluginSlot;
94 using ArrangerObjectPtrVariant =
95 structure::arrangement::ArrangerObjectPtrVariant;
96 using ArrangerObjectRegistry = structure::arrangement::ArrangerObjectRegistry;
97 using Color = utils::Color;
98
99 enum class Type : basic_enum_base_type_t
100 {
106
111 Audio,
112
116 Master,
117
122 Chord,
123
128
132 Modulator,
133
139 AudioBus,
147
151
152 Midi,
153
155 MidiBus,
156
158 MidiGroup,
159
161 Folder,
162 };
163 Q_ENUM (Type)
164
165 static constexpr int MIN_HEIGHT = 26;
166 static constexpr int DEF_HEIGHT = 52;
167
168 static bool
169 type_can_have_region_type (Type type, ArrangerObject::Type region_type)
170 {
171 switch (region_type)
172 {
173 case ArrangerObject::Type::AudioRegion:
174 return type == Type::Audio;
175 case ArrangerObject::Type::MidiRegion:
176 return type == Type::Midi || type == Type::Instrument;
177 case ArrangerObject::Type::ChordRegion:
178 return type == Type::Chord;
179 case ArrangerObject::Type::AutomationRegion:
180 return true;
181 default:
182 throw std::runtime_error ("Invalid region type");
183 }
184 }
185
186 static constexpr bool type_is_foldable (Type type)
187 {
188 return type == Type::Folder || type == Type::AudioGroup
189 || type == Type::MidiGroup;
190 }
191
192 static constexpr bool type_is_copyable (Type type)
193 {
194 return type != Type::Master && type != Type::Chord
195 && type != Type::Modulator && type != Type::Marker;
196 }
197
201 static constexpr bool type_is_deletable (Type type)
202 {
203 return type_is_copyable (type);
204 }
205
206 static Type type_get_from_plugin_descriptor (
208
209 static consteval bool type_has_mono_compat_switch (const Type tt)
210 {
211 return tt == Type::AudioGroup || tt == Type::Master;
212 }
213
216 */
217 static constexpr bool
218 type_is_compatible_for_moving (const Type type1, const Type type2)
219 {
220 return type1 == type2 || (type1 == Type::Midi && type2 == Type::Instrument)
221 || (type1 == Type::Instrument && type2 == Type::Midi);
222 }
223
224 /**
225 * Returns if the Track should have a piano roll.
226 */
227 [[gnu::const]]
228 static constexpr bool type_has_piano_roll (const Type type)
229 {
230 return type == Type::Midi || type == Type::Instrument;
231 }
232
236 static constexpr bool type_has_inputs (const Type type)
237 {
238 return type == Type::Midi || type == Type::Instrument || type == Type::Audio;
239 }
240
241
248 static constexpr bool type_can_be_group_target (const Type type)
249 {
250 return type == Type::AudioGroup || type == Type::MidiGroup
251 || type == Type::Instrument || type == Type::Master;
252 }
253
254 static constexpr bool type_can_have_automation (const Type type)
255 {
256 return type == Type::Instrument || type == Type::Audio
257 || type == Type::Master || type == Type::Chord
258 || type == Type::Modulator || type == Type::AudioBus
259 || type == Type::AudioGroup || type == Type::Midi
260 || type == Type::MidiBus || type == Type::MidiGroup;
261 }
262
263 static constexpr bool type_can_have_lanes (const Type type)
264 {
265 return type == Type::Instrument || type == Type::Audio || type == Type::Midi;
266 }
267
268 template <typename T> static consteval Type get_type_for_class ()
269 {
270 if constexpr (std::is_same_v<T, MidiTrack>)
271 return Type::Midi;
272 else if constexpr (std::is_same_v<T, AudioTrack>)
273 return Type::Audio;
274 else if constexpr (std::is_same_v<T, ChordTrack>)
275 return Type::Chord;
276 else if constexpr (std::is_same_v<T, InstrumentTrack>)
277 return Type::Instrument;
278 else if constexpr (std::is_same_v<T, AudioBusTrack>)
279 return Type::AudioBus;
280 else if constexpr (std::is_same_v<T, MidiBusTrack>)
281 return Type::MidiBus;
282 else if constexpr (std::is_same_v<T, MasterTrack>)
283 return Type::Master;
284 else if constexpr (std::is_same_v<T, ModulatorTrack>)
285 return Type::Modulator;
286 else if constexpr (std::is_same_v<T, MarkerTrack>)
287 return Type::Marker;
288 else if constexpr (std::is_same_v<T, FolderTrack>)
289 return Type::Folder;
290 else if constexpr (std::is_same_v<T, AudioGroupTrack>)
291 return Type::AudioGroup;
292 else if constexpr (std::is_same_v<T, MidiGroupTrack>)
293 return Type::MidiGroup;
294 else
295 {
296 static_assert (dependent_false_v<T>, "Unknown track type");
297 }
298 }
299
300public:
301 ~Track () override;
302 Z_DISABLE_COPY_MOVE (Track)
303
304protected:
305 enum class TrackFeatures : std::uint8_t
306 {
307 Modulators = 1 << 0,
308 Automation = 1 << 1,
309 Lanes = 1 << 2,
310 Recording = 1 << 3,
311 PianoRoll = 1 << 4,
312 };
313
317 Track (
318 Type type,
319 PortType in_signal_type,
320 PortType out_signal_type,
321 TrackFeatures enabled_features,
322 BaseTrackDependencies dependencies);
323
324public:
325 bool has_piano_roll () const { return type_has_piano_roll (type_); }
326
327 bool is_folder () const { return type_ == Type::Folder; }
328 bool is_audio_group () const { return type_ == Type::AudioGroup; }
329 bool is_midi_group () const { return type_ == Type::MidiGroup; }
330 bool is_audio_bus () const { return type_ == Type::AudioBus; }
331 bool is_midi_bus () const { return type_ == Type::MidiBus; }
332 bool is_modulator () const { return type_ == Type::Modulator; }
333 bool is_chord () const { return type_ == Type::Chord; }
334 bool is_marker () const { return type_ == Type::Marker; }
335 bool is_audio () const { return type_ == Type::Audio; }
336 bool is_instrument () const { return type_ == Type::Instrument; }
337 bool is_midi () const { return type_ == Type::Midi; }
338 bool is_master () const { return type_ == Type::Master; }
339
340 // ========================================================================
341 // QML Interface
342 // ========================================================================
343
344 Type type () const { return type_; }
345
346 AutomationTracklist * automationTracklist () const
347 {
348 return automation_tracklist_.get ();
349 }
350
351 QString name () const { return name_.to_qstring (); }
352 void setName (const QString &name)
353 {
354 const auto name_str = utils::Utf8String::from_qstring (name);
355 if (name_ == name_str)
356 return;
357
358 name_ = name_str;
359 Q_EMIT nameChanged (name);
360 }
361 Q_SIGNAL void nameChanged (const QString &name);
362
363 QColor color () const { return color_.to_qcolor (); }
364 void setColor (const QColor &color)
365 {
366 if (color_.to_qcolor () == color)
367 return;
368
369 color_ = color;
370 Q_EMIT colorChanged (color);
371 }
372 Q_SIGNAL void colorChanged (const QColor &color);
373
374 QString comment () const { return comment_.to_qstring (); }
375 void setComment (const QString &comment)
376 {
377 const auto comment_str = utils::Utf8String::from_qstring (comment);
378 if (comment_ == comment_str)
379 return;
380
381 comment_ = comment_str;
382 Q_EMIT commentChanged (comment);
383 }
384 Q_SIGNAL void commentChanged (const QString &comment);
385
386 bool visible () const { return visible_; }
387 void setVisible (bool visible)
388 {
389 if (visible_ == visible)
390 return;
391
392 visible_ = visible;
393 Q_EMIT visibleChanged (visible);
394 }
395 Q_SIGNAL void visibleChanged (bool visible);
396
397 bool enabled () const { return enabled_; }
398 void setEnabled (bool enabled)
399 {
400 if (enabled_ == enabled)
401 return;
402 enabled_ = enabled;
403 Q_EMIT enabledChanged (enabled);
404 }
405 Q_SIGNAL void enabledChanged (bool enabled);
406
407 double height () const { return main_height_; }
408 void setHeight (double height)
409 {
411 return;
412
413 height = std::max (static_cast<double> (Track::MIN_HEIGHT), height);
414 main_height_ = height;
415 Q_EMIT heightChanged (height);
416 }
417 Q_SIGNAL void heightChanged (double height);
418
419 double fullVisibleHeight () const { return get_full_visible_height (); }
420 Q_SIGNAL void fullVisibleHeightChanged ();
421
422 QString icon () const { return icon_name_.to_qstring (); }
423 void setIcon (const QString &icon)
424 {
425 const auto icon_str = utils::Utf8String::from_qstring (icon);
426 if (icon_name_ == icon_str)
427 {
428 return;
429 }
430 icon_name_ = icon_str;
431 Q_EMIT iconChanged (icon);
432 }
433 Q_SIGNAL void iconChanged (const QString &icon);
434
435 Channel * channel () const { return channel_.get (); }
436
437 plugins::PluginGroup * modulators () const { return modulators_.get (); }
438
439 TrackLaneList * lanes () const { return lanes_.get (); }
440
441 RecordableTrackMixin * recordableTrackMixin () const
442 {
443 return recordable_track_mixin_.get ();
444 }
445
446 PianoRollTrackMixin * pianoRollTrackMixin () const
447 {
448 return piano_roll_track_mixin_.get ();
449 }
451 bool clipLauncherMode () const { return clip_launcher_mode_; }
452 void setClipLauncherMode (bool mode);
453 Q_SIGNAL void clipLauncherModeChanged (bool mode);
454
461 Q_INVOKABLE void
463
464 // ========================================================================
465
466 // bool has_lanes () const { return type_has_lanes (type_); }
467
468 bool is_deletable () const { return type_is_deletable (type_); }
469 bool is_copyable () const { return type_is_copyable (type_); }
470 bool has_automation () const { return automationTracklist () != nullptr; }
471
476 double get_full_visible_height () const;
477
478 bool multiply_heights (double multiplier, bool visible_only, bool check_only);
479
480 bool can_be_group_target () const { return type_can_be_group_target (type_); }
481
482 template <arrangement::RegionObject RegionT>
483 auto generate_name_for_region (
484 const RegionT &region,
485 AutomationTrack * automation_track = nullptr)
486 {
487 auto ret = get_name ();
488 if constexpr (std::is_same_v<RegionT, arrangement::AutomationRegion>)
490 assert (automation_track != nullptr);
492 fmt::format (
493 "{} - {}", get_name (), automation_track->parameter ()->label ()));
494 }
495 return ret;
496 }
502 std::vector<ArrangerObjectPtrVariant> &objects) const;
503
504 bool contains_uninstantiated_plugin () const;
505
509 utils::Utf8String get_name () const { return name_; };
510
511 auto get_input_signal_type () const { return in_signal_type_; }
512 auto get_output_signal_type () const { return out_signal_type_; }
513
518 uint8_t get_midi_ch (const arrangement::MidiRegion &midi_region) const;
519
523 void collect_plugins (std::vector<plugins::PluginPtrVariant> &plugins) const;
524
530 const plugins::PluginDescriptor &descr,
531 zrythm::plugins::PluginSlotType slot_type,
532 Track::Type track_type);
533
538 void set_caches (CacheType types);
539
540 utils::Utf8String get_full_designation_for_port (const dsp::Port &port) const;
541
550
551 auto &get_plugin_registry () const
552 {
553 return base_dependencies_.plugin_registry_;
554 }
555 auto &get_plugin_registry () { return base_dependencies_.plugin_registry_; }
556 auto &get_port_registry () const { return base_dependencies_.port_registry_; }
557 auto &get_port_registry () { return base_dependencies_.port_registry_; }
558 auto &get_param_registry () const
559 {
560 return base_dependencies_.param_registry_;
561 }
562 auto &get_param_registry () { return base_dependencies_.param_registry_; }
563 auto &get_object_registry () const
564 {
565 return base_dependencies_.obj_registry_;
566 }
567 auto &get_object_registry () { return base_dependencies_.obj_registry_; }
568
569 TrackProcessor * get_track_processor () const { return processor_.get (); }
571 auto get_icon_name () const { return icon_name_; }
572
573protected:
574 friend void
575 init_from (Track &obj, const Track &other, utils::ObjectCloneType clone_type);
576
582 virtual void set_playback_caches () { }
583
584 void generate_automation_tracks_for_processor (
586 const dsp::ProcessorBase &processor)
587 {
588 structure::tracks::generate_automation_tracks_for_processor (
589 ats, processor, base_dependencies_.tempo_map_,
590 base_dependencies_.file_audio_source_registry_,
591 base_dependencies_.obj_registry_);
592 }
593
598 std::optional<TrackProcessor::FillEventsCallback> fill_events_cb =
599 std::nullopt,
600 std::optional<TrackProcessor::TransformMidiInputsFunc>
601 transform_midi_inputs_func = std::nullopt,
602 std::optional<TrackProcessor::AppendMidiInputsToOutputsFunc>
603 append_midi_inputs_to_outputs_func = std::nullopt);
604
610 std::vector<ArrangerObjectPtrVariant> &objects) const
611 {
612 }
613
614private:
615 static constexpr auto kTypeKey = "type"sv;
616 static constexpr auto kNameKey = "name"sv;
617 static constexpr auto kIconNameKey = "iconName"sv;
618 static constexpr auto kVisibleKey = "visible"sv;
619 static constexpr auto kMainHeightKey = "mainHeight"sv;
620 static constexpr auto kEnabledKey = "enabled"sv;
621 static constexpr auto kColorKey = "color"sv;
622 static constexpr auto kInputSignalTypeKey = "inSignalType"sv;
623 static constexpr auto kOutputSignalTypeKey = "outSignalType"sv;
624 static constexpr auto kCommentKey = "comment"sv;
625 static constexpr auto kFrozenClipIdKey = "frozenClipId"sv;
626 static constexpr auto kProcessorKey = "processor"sv;
627 static constexpr auto kAutomationTracklistKey = "automationTracklist"sv;
628 static constexpr auto kChannelKey = "channel"sv;
629 static constexpr auto kModulatorsKey = "modulators"sv;
630 static constexpr auto kModulatorMacroProcessorsKey = "modulatorMacros"sv;
631 static constexpr auto kTrackLanesKey = "lanes"sv;
632 static constexpr auto kRecordableTrackMixinKey = "recordableTrackMixin"sv;
633 static constexpr auto kPianoRollTrackMixinKey = "pianoRollTrackMixin"sv;
634 friend void to_json (nlohmann::json &j, const Track &track)
635 {
636 to_json (j, static_cast<const UuidIdentifiableObject &> (track));
637 j[kTypeKey] = track.type_;
638 j[kNameKey] = track.name_;
639 j[kIconNameKey] = track.icon_name_;
640 j[kVisibleKey] = track.visible_;
641 j[kMainHeightKey] = track.main_height_;
642 j[kEnabledKey] = track.enabled_;
643 j[kColorKey] = track.color_;
644 j[kInputSignalTypeKey] = track.in_signal_type_;
645 j[kOutputSignalTypeKey] = track.out_signal_type_;
646 j[kCommentKey] = track.comment_;
647 j[kFrozenClipIdKey] = track.frozen_clip_id_;
648 j[kProcessorKey] = track.processor_;
649 j[kAutomationTracklistKey] = track.automation_tracklist_;
650 j[kChannelKey] = track.channel_;
651 j[kModulatorsKey] = track.modulators_;
652 j[kModulatorMacroProcessorsKey] = track.modulator_macro_processors_;
653 j[kTrackLanesKey] = track.lanes_;
654 j[kRecordableTrackMixinKey] = track.recordable_track_mixin_;
655 j[kPianoRollTrackMixinKey] = track.piano_roll_track_mixin_;
656 }
657 friend void from_json (const nlohmann::json &j, Track &track);
658
660 make_automation_tracklist ();
661 [[nodiscard]] utils::QObjectUniquePtr<Channel> make_channel ();
663 make_modulators ();
664 [[nodiscard]] utils::QObjectUniquePtr<TrackLaneList> make_lanes ();
666 make_recordable_track_mixin ();
668 make_piano_roll_track_mixin ();
669
670protected:
671 BaseTrackDependencies base_dependencies_;
672
674 Type type_{};
675
676 TrackFeatures features_{};
677
680
683
685 bool visible_ = true;
686
688 double main_height_{ DEF_HEIGHT };
689
696 bool enabled_ = true;
697
703 Color color_;
708 PortType in_signal_type_ = {};
709
713 PortType out_signal_type_ = {};
714
717
723 std::optional<dsp::FileAudioSourceUuidReference> frozen_clip_id_;
724
729
739
744
747
749 std::vector<utils::QObjectUniquePtr<dsp::ModulatorMacroProcessor>>
751
753
754 utils::QObjectUniquePtr<RecordableTrackMixin> recordable_track_mixin_;
755
756 utils::QObjectUniquePtr<PianoRollTrackMixin> piano_roll_track_mixin_;
757
763
764 bool clip_launcher_mode_{};
765
766 BOOST_DESCRIBE_CLASS (
767 Track,
769 (),
770 (type_,
771 name_,
772 visible_,
774 enabled_,
775 color_,
778 comment_,
781 channel_,
784 lanes_,
785 recordable_track_mixin_,
786 piano_roll_track_mixin_,
787 clip_launcher_mode_),
788 ())
789};
790
792using TrackRegistryRef = std::reference_wrapper<TrackRegistry>;
793using TrackUuidReference = utils::UuidReference<TrackRegistry>;
794
795struct FinalTrackDependencies : public BaseTrackDependencies
796{
797 FinalTrackDependencies (
798 const dsp::TempoMapWrapper &tempo_map,
799 dsp::FileAudioSourceRegistry &file_audio_source_registry,
800 plugins::PluginRegistry &plugin_registry,
801 dsp::PortRegistry &port_registry,
802 dsp::ProcessorParameterRegistry &param_registry,
803 arrangement::ArrangerObjectRegistry &obj_registry,
804 TrackRegistry &track_registry,
805 const dsp::ITransport &transport,
806 SoloedTracksExistGetter soloed_tracks_exist_getter)
808 tempo_map,
809 file_audio_source_registry,
810 plugin_registry,
811 port_registry,
812 param_registry,
813 obj_registry,
814 transport,
815 std::move (soloed_tracks_exist_getter)),
816 track_registry_ (track_registry)
817 {
818 }
819
820 TrackRegistry &track_registry_;
821
822 BaseTrackDependencies to_base_dependencies ()
823 {
824 return static_cast<BaseTrackDependencies> (*this); // NOLINT
825 }
826};
827
828} // namespace zrythm::structure::tracks
829
830DEFINE_ENUM_FORMATTER (
832 Track_Type,
833 QT_TR_NOOP_UTF8 ("Instrument"),
834 QT_TR_NOOP_UTF8 ("Audio"),
835 QT_TR_NOOP_UTF8 ("Master"),
836 QT_TR_NOOP_UTF8 ("Chord"),
837 QT_TR_NOOP_UTF8 ("Marker"),
838 QT_TR_NOOP_UTF8 ("Modulator"),
839 QT_TR_NOOP_UTF8 ("Audio FX"),
840 QT_TR_NOOP_UTF8 ("Audio Group"),
841 QT_TR_NOOP_UTF8 ("MIDI"),
842 QT_TR_NOOP_UTF8 ("MIDI FX"),
843 QT_TR_NOOP_UTF8 ("MIDI Group"),
844 QT_TR_NOOP_UTF8 ("Folder"));
Interface for transport.
Definition itransport.h:17
A base class for ports used for connecting processors in the DSP graph.
Definition port.h:30
A base class for processors in the DSP graph.
Wrapper over a Uuid registry that provides (slow) lookup by unique ID.
Definition parameter.h:522
The PluginDescriptor class provides a set of static utility functions and member functions to work wi...
A flexible container for plugins and nested plugin groups.
DSP processing plugin.
Definition plugin.h:30
Base class for all objects in the arranger.
A Region containing MIDI events.
Definition midi_region.h:20
A container that manages a list of automation tracks.
Represents a channel strip on the mixer.
Definition channel.h:57
Mixin for a piano roll-based track.
Mixin class for a track that can record events (excluding automation).
Represents a track in the project.
Definition track.h:54
utils::QObjectUniquePtr< plugins::PluginGroup > modulators_
Modulators.
Definition track.h:734
@ Marker
Marker Track's contain named markers at specific Position's in the song.
Definition track.h:115
@ AudioGroup
Group Tracks are used for grouping audio signals, for example routing multiple drum tracks to a "Drum...
Definition track.h:134
@ AudioBus
Buses are channels that receive audio input and have effects on their channel strip.
Definition track.h:127
@ Modulator
Special track to contain global Modulator's.
Definition track.h:120
@ Midi
Midi tracks can only have MIDI effects in the strip and produce MIDI output that can be routed to ins...
Definition track.h:140
@ Instrument
Instrument tracks must have an Instrument plugin at the first slot and they produce audio output.
Definition track.h:93
@ Folder
Foldable track used for visual grouping.
Definition track.h:149
@ Audio
Audio tracks can record and contain audio clips.
Definition track.h:99
@ MidiGroup
Same with audio group but for MIDI signals.
Definition track.h:146
@ MidiBus
Same with audio bus but for MIDI signals.
Definition track.h:143
@ Chord
The chord track contains chords that can be used to modify midi in real time or to color the piano ro...
Definition track.h:110
@ Master
The master track is a special type of group track.
Definition track.h:104
static constexpr bool type_has_inputs(const Type type)
Returns if the Track should have an inputs selector.
Definition track.h:224
uint8_t get_midi_ch(const arrangement::MidiRegion &midi_region) const
Returns the MIDI channel that this region should be played on, starting from 1.
utils::QObjectUniquePtr< TrackProcessor > processor_
The TrackProcessor, used for processing.
Definition track.h:726
bool enabled_
Active (enabled) or not.
Definition track.h:684
static bool is_plugin_descriptor_valid_for_slot_type(const plugins::PluginDescriptor &descr, zrythm::plugins::PluginSlotType slot_type, Track::Type track_type)
Returns if descr can be dropped at slot_type in a track of type track_type.
std::optional< dsp::FileAudioSourceUuidReference > frozen_clip_id_
Pool ID of the clip if track is frozen (unset if not frozen).
Definition track.h:711
utils::Utf8String name_
Track name, used in channel too.
Definition track.h:667
Track(Type type, PortType in_signal_type, PortType out_signal_type, TrackFeatures enabled_features, BaseTrackDependencies dependencies)
Constructor to be used by subclasses.
static constexpr bool type_is_compatible_for_moving(const Type type1, const Type type2)
Returns if regions in tracks from type1 can be moved to type2.
Definition track.h:206
void generate_basic_automation_tracks()
Adds basic automation tracks.
double main_height_
Height of the main part (without lanes).
Definition track.h:676
static constexpr bool type_has_piano_roll(const Type type)
Returns if the Track should have a piano roll.
Definition track.h:216
utils::Utf8String get_name() const
Getter for the track name.
Definition track.h:497
utils::QObjectUniquePtr< utils::PlaybackCacheScheduler > playable_content_cache_request_debouncer_
Debouncer/scheduler of audio/MIDI cache requests.
Definition track.h:750
utils::QObjectUniquePtr< AutomationTracklist > automation_tracklist_
Automation tracks, if track is automatable.
Definition track.h:716
Type type_
The type of track this is.
Definition track.h:662
utils::Utf8String comment_
User comments.
Definition track.h:704
utils::QObjectUniquePtr< Channel > channel_
Channel for this track, if any.
Definition track.h:731
utils::QObjectUniquePtr< TrackProcessor > make_track_processor(std::optional< TrackProcessor::FillEventsCallback > fill_events_cb=std::nullopt, std::optional< TrackProcessor::TransformMidiInputsFunc > transform_midi_inputs_func=std::nullopt, std::optional< TrackProcessor::AppendMidiInputsToOutputsFunc > append_midi_inputs_to_outputs_func=std::nullopt)
Implementations with a processor must call this in their constructor.
std::vector< utils::QObjectUniquePtr< dsp::ModulatorMacroProcessor > > modulator_macro_processors_
Modulator macros.
Definition track.h:738
double get_full_visible_height() const
Returns the full visible height (main height + height of all visible automation tracks + height of al...
virtual void set_playback_caches()
Set the playback caches for a track.
Definition track.h:570
virtual void collect_additional_timeline_objects(std::vector< ArrangerObjectPtrVariant > &objects) const
Called by collect_timeline_objects to collect any additional objects not handled by this class (such ...
Definition track.h:597
PortType out_signal_type_
The output signal type (eg midi tracks have MIDI output signals).
Definition track.h:701
static constexpr bool type_is_deletable(Type type)
Returns whether a track of the given type should be deletable by the user.
Definition track.h:189
PortType in_signal_type_
The input signal type (eg audio bus tracks have audio input signals).
Definition track.h:696
Color color_
Track color.
Definition track.h:691
void collect_plugins(std::vector< plugins::PluginPtrVariant > &plugins) const
Fills in the given array with all plugins in the track.
bool visible_
Whole Track is visible or not.
Definition track.h:673
void collect_timeline_objects(std::vector< ArrangerObjectPtrVariant > &objects) const
Appends all the timeine objects in the track to objects.
Q_INVOKABLE void regeneratePlaybackCaches(utils::ExpandableTickRange affectedRange)
To be connected to to notify of any changes to the playable content, like MIDI or audio events.
utils::Utf8String icon_name_
Icon name of the track.
Definition track.h:670
void set_caches(CacheType types)
Set various caches (snapshots, track name hash, plugin input/output ports, etc).
static constexpr bool type_can_be_group_target(const Type type)
Returns if the Track can be a direct route target.
Definition track.h:236
A registry that owns and manages objects identified by a UUID.
A unique pointer for QObject objects that also works with QObject-based ownership.
Definition qt.h:38
Lightweight UTF-8 string wrapper with safe conversions.
Definition utf8_string.h:38
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.
Definition utf8_string.h:81
Base class for objects that need to be uniquely identified by UUID.
A reference-counted RAII wrapper for a UUID in a registry.
constexpr bool values_equal_for_qproperty_type(const T &a, const T &b)
Helper that checks if 2 values are equal.
Definition qt.h:20