Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
midi_region.h
1// SPDX-FileCopyrightText: © 2019-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "dsp/midi_event.h"
7#include "structure/arrangement/arranger_object_owner.h"
8#include "structure/arrangement/midi_note.h"
9
10namespace zrythm::structure::arrangement
11{
19class MidiRegion final : public ArrangerObject, public ArrangerObjectOwner<MidiNote>
20{
21 Q_OBJECT
22 DEFINE_ARRANGER_OBJECT_OWNER_QML_PROPERTIES (MidiRegion, midiNotes, MidiNote)
23 Q_PROPERTY (int minVisiblePitch READ minVisiblePitch NOTIFY contentChanged)
24 Q_PROPERTY (int maxVisiblePitch READ maxVisiblePitch NOTIFY contentChanged)
25 QML_ELEMENT
26 QML_UNCREATABLE ("")
27
28 friend class ArrangerObjectFactory;
29
30public:
31 MidiRegion (
32 const dsp::TempoMap &tempo_map,
33 ArrangerObjectRegistry &object_registry,
34 dsp::FileAudioSourceRegistry &file_audio_source_registry,
35 QObject * parent = nullptr);
36
37 // ========================================================================
38 // QML Interface
39 // ========================================================================
40
41 int minVisiblePitch () const;
42 int maxVisiblePitch () const;
43 Q_SIGNAL void contentChanged ();
44
45 // ========================================================================
46
47 std::string get_field_name_for_serialization (const MidiNote *) const override
48 {
49 return "midiNotes";
50 }
51
52private:
53 friend void init_from (
54 MidiRegion &obj,
55 const MidiRegion &other,
56 utils::ObjectCloneType clone_type);
57
58 friend void to_json (nlohmann::json &j, const MidiRegion &region)
59 {
60 to_json (j, static_cast<const ArrangerObject &> (region));
61 to_json (j, static_cast<const ArrangerObjectOwner &> (region));
62 }
63 friend void from_json (const nlohmann::json &j, MidiRegion &region)
64 {
65 from_json (j, static_cast<ArrangerObject &> (region));
66 from_json (j, static_cast<ArrangerObjectOwner &> (region));
67 }
68
69private:
70 BOOST_DESCRIBE_CLASS (
71 MidiRegion,
72 (ArrangerObject, ArrangerObjectOwner<MidiNote>),
73 (),
74 (),
75 ())
76};
77}
ArrangerObject(Type type, const dsp::TempoMap &tempo_map, ArrangerObjectFeatures features, QObject *parent=nullptr) noexcept
Construct a new ArrangerObject.
A MIDI note inside a Region shown in the piano roll.
Definition midi_note.h:20