Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
lane_owned_object.h
1// SPDX-FileCopyrightText: © 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "structure/arrangement/timeline_object.h"
7#include "structure/tracks/track_lane_fwd.h"
8
9namespace zrythm::structure::tracks
10{
11class MidiLane;
12class AudioLane;
13class TrackLane;
14}
15
16namespace zrythm::structure::arrangement
17{
18class LaneOwnedObject : virtual public TimelineObject
19{
20public:
21 using MidiLane = structure::tracks::MidiLane;
22 using AudioLane = structure::tracks::AudioLane;
23
24 // = default deletes it for some reason on gcc
25 LaneOwnedObject () noexcept { };
26 ~LaneOwnedObject () noexcept override = default;
27 Z_DISABLE_COPY_MOVE (LaneOwnedObject);
28
29 bool is_inserted_in_lane () const { return owner_lane_.has_value (); }
30
31 template <typename SelfT>
32 MidiLane &get_lane (this const SelfT &self)
33 requires std::is_same_v<SelfT, MidiRegion>
34 {
35 return *std::get<MidiLane *> (*self.owner_lane_);
36 }
37
38 template <typename SelfT>
39 AudioLane &get_lane (this const SelfT &self)
40 requires std::is_same_v<SelfT, AudioRegion>
41 {
42 return *std::get<AudioLane *> (*self.owner_lane_);
43 }
44
45 template <typename SelfT> auto get_lane_index (this const SelfT &self)
46 {
47 return self.get_lane ().get_index_in_track ();
48 }
49
53 void set_lane (structure::tracks::TrackLanePtrVariant lane)
54 {
55 owner_lane_ = lane;
56 }
57
58 friend void init_from (
59 LaneOwnedObject &obj,
60 const LaneOwnedObject &other,
61 utils::ObjectCloneType clone_type)
62 {
64 }
65
66private:
68 std::optional<structure::tracks::TrackLanePtrVariant> owner_lane_;
69
70public:
80 std::optional<int> index_in_prev_lane_;
81
82 BOOST_DESCRIBE_CLASS (LaneOwnedObject, (TimelineObject), (), (), ())
83};
84
85class MidiRegion;
86class AudioRegion;
87using LaneOwnedObjectVariant = std::variant<MidiRegion, AudioRegion>;
88using LaneOwnedObjectPtrVariant = to_pointer_variant<LaneOwnedObjectVariant>;
89
90}
An AudioRegion represents a region of audio within a Track.
std::optional< int > index_in_prev_lane_
Object's index in the previous lane (before being moved to a new lane/track).
void set_lane(structure::tracks::TrackLanePtrVariant lane)
Sets the track lane.
A Region containing MIDI events.
Definition midi_region.h:33
A TrackLane belongs to a Track (can have many TrackLanes in a Track) and contains Regions.
Definition track_lane.h:70