Zrythm v2.0.0-alpha.1
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 (
29 const dsp::TempoMapWrapper &tempo_map_wrapper,
30 QObject * parent = nullptr);
31
32 dsp::TimelinePosition * position () const override
33 {
34 return static_cast<dsp::TimelinePosition *> (ArrangerObject::position ());
35 }
36
37 // =========================================================
38 // QML Interface
39 // =========================================================
40
41 double tempo () const { return tempo_; }
42 void setTempo (double tempo);
43 Q_SIGNAL void tempoChanged (double tempo);
44
45 CurveType curve () const { return curve_; }
46 void setCurve (CurveType curve);
47 Q_SIGNAL void curveChanged (CurveType curve);
48
49 // =========================================================
50
51private:
52 friend void init_from (
53 TempoObject &obj,
54 const TempoObject &other,
55 utils::ObjectCloneType clone_type);
56
57 static constexpr auto kTempoKey = "tempo"sv;
58 static constexpr auto kCurveTypeKey = "curveType"sv;
59 friend void to_json (nlohmann::json &j, const TempoObject &so);
60 friend void from_json (const nlohmann::json &j, TempoObject &so);
61
62private:
63 double tempo_{ DEFAULT_TEMPO };
64 CurveType curve_{ CurveType::Constant };
65
66 BOOST_DESCRIBE_CLASS (TempoObject, (ArrangerObject), (), (), (tempo_))
67};
68
69} // namespace zrythm::structure::arrangement
A Position whose ticks are absolute timeline ticks.
Definition position.h:97
ArrangerObject(Type type, const dsp::TempoMapWrapper &tempo_map_wrapper, ArrangerObjectFeatures features, QObject *parent=nullptr) noexcept
Construct a new ArrangerObject.