Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
tempo_object.h
1// SPDX-FileCopyrightText: © 2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "dsp/tempo_map_qml_adapter.h"
7#include "structure/arrangement/arranger_object.h"
8#include "utils/icloneable.h"
9
10namespace zrythm::structure::arrangement
11{
12
13class TempoObject final : public ArrangerObject
14{
15 Q_OBJECT
16 Q_PROPERTY (double tempo READ tempo WRITE setTempo NOTIFY tempoChanged)
17 Q_PROPERTY (
18 zrythm::dsp::TempoEventWrapper::CurveType curve READ curve WRITE setCurve
19 NOTIFY curveChanged)
20 QML_ELEMENT
21 QML_UNCREATABLE ("")
22
23public:
24 using CurveType = dsp::TempoEventWrapper::CurveType;
25 static constexpr double DEFAULT_TEMPO = 120.0;
26
27public:
28 TempoObject (const dsp::TempoMap &tempo_map, QObject * parent = nullptr);
29
30 // =========================================================
31 // QML Interface
32 // =========================================================
33
34 double tempo () const { return tempo_; }
35 void setTempo (double tempo);
36 Q_SIGNAL void tempoChanged (double tempo);
37
38 CurveType curve () const { return curve_; }
39 void setCurve (CurveType curve);
40 Q_SIGNAL void curveChanged (CurveType curve);
41
42 // =========================================================
43
44private:
45 friend void init_from (
46 TempoObject &obj,
47 const TempoObject &other,
48 utils::ObjectCloneType clone_type);
49
50 static constexpr auto kTempoKey = "tempo"sv;
51 static constexpr auto kCurveTypeKey = "curveType"sv;
52 friend void to_json (nlohmann::json &j, const TempoObject &so);
53 friend void from_json (const nlohmann::json &j, TempoObject &so);
54
55private:
56 double tempo_{ DEFAULT_TEMPO };
57 CurveType curve_{ CurveType::Constant };
58
59 BOOST_DESCRIBE_CLASS (TempoObject, (ArrangerObject), (), (), (tempo_))
60};
61
62} // namespace zrythm::structure::arrangement
ArrangerObject(Type type, const dsp::TempoMap &tempo_map, ArrangerObjectFeatures features, QObject *parent=nullptr) noexcept
Construct a new ArrangerObject.