7#include "dsp/position.h"
8#include "gui/dsp/arranger_object.h"
9#include "gui/dsp/bounded_object.h"
10#include "gui/dsp/control_port.h"
11#include "gui/dsp/region_owned_object.h"
12#include "utils/icloneable.h"
13#include "utils/math.h"
20using namespace zrythm;
33 public RegionOwnedObject,
34 public ICloneable<AutomationPoint>
39 Q_PROPERTY (
double value READ getValue WRITE setValue NOTIFY valueChanged)
41 using RegionT = AutomationRegion;
51 double getValue ()
const {
return fvalue_; }
53 void setValue (
double dval)
55 const auto val =
static_cast<float> (dval);
59 Q_EMIT valueChanged (dval);
62 Q_SIGNAL
void valueChanged (
double);
120 ArrangerObjectPtrVariant
133 return a.index_ < b.index_;
140 friend bool operator== (
const AutomationPoint &a,
const AutomationPoint &b)
150 static constexpr std::string_view kValueKey =
"value";
151 static constexpr std::string_view kNormalizedValueKey =
"normalized_value";
152 static constexpr std::string_view kCurveOptionsKey =
"curve_options";
153 friend void to_json (nlohmann::json &j,
const AutomationPoint &point)
155 to_json (j,
static_cast<const ArrangerObject &
> (point));
156 to_json (j,
static_cast<const RegionOwnedObject &
> (point));
159 j[kCurveOptionsKey] = point.curve_opts_;
161 friend void from_json (
const nlohmann::json &j, AutomationPoint &point)
163 from_json (j,
static_cast<ArrangerObject &
> (point));
164 from_json (j,
static_cast<RegionOwnedObject &
> (point));
165 j.at (kValueKey).get_to (point.
fvalue_);
167 j.at (kCurveOptionsKey).get_to (point.curve_opts_);
189 NUM_AUTOMATION_MODES,
192constexpr size_t NUM_AUTOMATION_MODES =
193 static_cast<size_t> (AutomationMode::NUM_AUTOMATION_MODES);
195DEFINE_ENUM_FORMATTER (
207 "AutomationPoint [{}]: val {}, normalized val {}", ap.
get_position (),
auto get_position() const
Getter.
PositionProxy * pos_
Position (or start Position if the object has length).
An automation point inside an AutomationTrack.
AutomationTrack * get_automation_track() const
Convenience function to return the AutomationTrack that this AutomationPoint is in.
void set_curviness(curviness_t curviness)
Sets the curviness of the AutomationPoint.
std::string get_fvalue_as_string() const
String getter for the value.
ControlPort * get_port() const
Convenience function to return the control port that this AutomationPoint is for.
ArrangerObjectPtrVariant add_clone_to_project(bool fire_events) const override
Appends the ArrangerObject to where it belongs in the project (eg, a Track), without taking into acco...
void set_fvalue_with_action(const std::string &fval_str)
String setter.
float fvalue_
Float value (real).
bool validate(bool is_project, dsp::FramesPerTick frames_per_tick) const override
Validates the arranger object.
void init_after_cloning(const AutomationPoint &other, ObjectCloneType clone_type) override
Initializes the cloned object.
bool curves_up() const
Returns if the curve of the AutomationPoint curves upwards as you move right on the x axis.
void set_fvalue(float real_val, bool is_normalized)
Sets the value from given real or normalized value and notifies interested parties.
ArrangerObjectPtrVariant insert_clone_to_project() const override
Inserts the object where it belongs in the project (eg, a Track).
double get_normalized_value_in_curve(AutomationRegion *region, double x) const
The function to return a point on the curve.
float normalized_val_
Normalized value (0 to 1) used as a cache.
Represents an automation region, which contains a collection of automation points.
The Port class represents a port in the audio processing graph.
AutomationMode
FIXME: move to a more appropriate place.
#define DEFINE_OBJECT_FORMATTER(obj_type, function_prefix, formatter_func)
Defines a formatter for the given object type.
constexpr bool floats_equal(T a, T b)
Checks if 2 floating point numbers are equal.
constexpr bool floats_near(T a, T b, T e)
Returns whether 2 floating point numbers are equal.