Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
automation_point.h
1// SPDX-FileCopyrightText: © 2018-2022, 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "dsp/curve.h"
7#include "structure/arrangement/arranger_object.h"
8#include "utils/icloneable.h"
9
10namespace zrythm::structure::arrangement
11{
15class AutomationPoint final : public ArrangerObject
16{
17 Q_OBJECT
18 Q_PROPERTY (float value READ value WRITE setValue NOTIFY valueChanged)
19 Q_PROPERTY (dsp::CurveOptionsQmlAdapter * curveOpts READ curveOpts CONSTANT)
20 QML_ELEMENT
21 QML_UNCREATABLE ("")
22
23public:
24 AutomationPoint (
25 const dsp::TempoMapWrapper &tempo_map_wrapper,
26 QObject * parent = nullptr);
27 Q_DISABLE_COPY_MOVE (AutomationPoint)
28 ~AutomationPoint () override;
29
30 dsp::ContentPosition * position () const override
31 {
32 return qobject_cast<dsp::ContentPosition *> (ArrangerObject::position ());
33 }
34
35 // ========================================================================
36 // QML Interface
37 // ========================================================================
38
39 float value () const { return normalized_value_; }
40 void setValue (float dval)
41 {
42 const auto val = dval;
43 if (qFuzzyCompare (normalized_value_, val))
44 return;
45
46 normalized_value_ = val;
47 Q_EMIT valueChanged (dval);
48 }
49 Q_SIGNAL void valueChanged (float);
50
51 dsp::CurveOptionsQmlAdapter * curveOpts () const
52 {
53 return curve_opts_adapter_.get ();
54 }
55
56 // ========================================================================
57
58private:
59 friend void init_from (
60 AutomationPoint &obj,
61 const AutomationPoint &other,
62 utils::ObjectCloneType clone_type);
63
64 static constexpr auto kNormalizedValueKey = "normalizedValue"sv;
65 static constexpr auto kCurveOptionsKey = "curveOptions"sv;
66 friend void to_json (nlohmann::json &j, const AutomationPoint &point);
67 friend void from_json (const nlohmann::json &j, AutomationPoint &point);
68
69private:
71 float normalized_value_ = 0.f;
72
73 dsp::CurveOptions curve_opts_;
75
76 BOOST_DESCRIBE_CLASS (
77 AutomationPoint,
79 (),
80 (),
81 (normalized_value_, curve_opts_))
82};
83
84} // namespace zrythm::structure::arrangement
A Position whose ticks are content-space (clip-local) ticks.
Definition position.h:118
QML adapter for CurveOptions.
Definition curve.h:131
Curve options.
Definition curve.h:23
ArrangerObject(Type type, const dsp::TempoMapWrapper &tempo_map_wrapper, ArrangerObjectFeatures features, QObject *parent=nullptr) noexcept
Construct a new ArrangerObject.
A unique pointer for QObject objects that also works with QObject-based ownership.
Definition qt.h:36