Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
arranger_object_all.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/audio_region.h"
7#include "structure/arrangement/audio_source_object.h"
8#include "structure/arrangement/automation_region.h"
9#include "structure/arrangement/chord_object.h"
10#include "structure/arrangement/chord_region.h"
11#include "structure/arrangement/marker.h"
12#include "structure/arrangement/midi_control_event.h"
13#include "structure/arrangement/midi_note.h"
14#include "structure/arrangement/midi_region.h"
15#include "structure/arrangement/scale_object.h"
16#include "structure/arrangement/tempo_object.h"
17#include "structure/arrangement/time_signature_object.h"
18
19namespace zrythm::structure::arrangement
20{
21
22template <FinalArrangerObjectSubclass ObjT>
23bool
24is_arranger_object_deletable (const ObjT &obj)
25{
26 if constexpr (std::is_same_v<ObjT, Marker>)
27 {
28 return obj.markerType () == Marker::MarkerType::Custom;
29 }
30 else
31 {
32 return true;
33 }
34}
35
36// Currently unused
37#if 0
46template <RegionObject ObjectT>
47[[gnu::nonnull]] std::pair<int64_t, bool>
48get_frames_till_next_loop_or_end (
49 const ObjectT &obj,
50 int64_t timeline_frames)
51{
52 const auto * loop_range = obj.loopRange ();
53 const auto loop_size = loop_range->get_loop_length_in_frames ();
54 assert (loop_size > 0);
55 const auto object_position_frames = obj.position ()->samples ();
56 const int64_t loop_end_frames =
57 loop_range->loopEndPosition ()->samples ();
58 const int64_t clip_start_frames =
59 loop_range->clipStartPosition ()->samples ();
60
61 int64_t local_frames = timeline_frames - object_position_frames;
62 local_frames += clip_start_frames;
63 while (local_frames >= loop_end_frames)
64 {
65 local_frames -= loop_size;
66 }
67
68 const int64_t frames_till_next_loop = loop_end_frames - local_frames;
69 const int64_t frames_till_end =
70 obj.bounds ()->get_end_position_samples (true) - timeline_frames;
71
72 return std::make_pair (
73 std::min (frames_till_end, frames_till_next_loop),
74 frames_till_next_loop < frames_till_end);
75}
76#endif
77
78inline auto
79get_object_tick_range (const ArrangerObject * obj)
80{
81 return std::make_pair (
82 obj->position ()->ticks (),
83 obj->position ()->ticks ()
84 + (obj->bounds () != nullptr ? obj->bounds ()->length ()->ticks () : 0));
85}
86}
Base class for all objects in the arranger.