Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
curve.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2020, 2023 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
12#ifndef __AUDIO_CURVE_H__
13#define __AUDIO_CURVE_H__
14
15#include <stdbool.h>
16
17#include "utils/yaml.h"
18
19#include <glib/gi18n.h>
20
27#define CURVE_OPTIONS_SCHEMA_VERSION 1
28
30#define CURVE_SUPERELLIPSE_CURVINESS_BOUND 0.82
31#define CURVE_EXPONENT_CURVINESS_BOUND 0.95
32#define CURVE_VITAL_CURVINESS_BOUND 1.00
33
96
97static const cyaml_strval_t curve_algorithm_strings[] = {
98 {N_ ("Exponent"), CURVE_ALGORITHM_EXPONENT },
99 { N_ ("Superellipse"), CURVE_ALGORITHM_SUPERELLIPSE},
100 { N_ ("Vital"), CURVE_ALGORITHM_VITAL },
101 { N_ ("Pulse"), CURVE_ALGORITHM_PULSE },
102 { N_ ("Logarithmic"), CURVE_ALGORITHM_LOGARITHMIC },
103};
104
108typedef struct CurveOptions
109{
110 int schema_version;
111
114
117 double curviness;
119
120static const cyaml_schema_field_t curve_options_fields_schema[] = {
121 YAML_FIELD_INT (CurveOptions, schema_version),
122 YAML_FIELD_ENUM (CurveOptions, algo, curve_algorithm_strings),
123 YAML_FIELD_FLOAT (CurveOptions, curviness),
124
125 CYAML_FIELD_END
126};
127
128static const cyaml_schema_value_t curve_options_schema = {
129 CYAML_VALUE_MAPPING (
130 CYAML_FLAG_POINTER,
132 curve_options_fields_schema),
133};
134
135typedef struct CurveFadePreset
136{
137 char * id;
138 char * label;
139 CurveOptions opts;
141
142NONNULL void
143curve_opts_init (CurveOptions * opts);
144
148RETURNS_NONNULL
149GPtrArray *
151
156void
158
159gboolean
160curve_algorithm_get_g_settings_mapping (
161 GValue * value,
162 GVariant * variant,
163 gpointer user_data);
164
165GVariant *
166curve_algorithm_set_g_settings_mapping (
167 const GValue * value,
168 const GVariantType * expected_type,
169 gpointer user_data);
170
178HOT NONNULL double
179curve_get_normalized_y (double x, CurveOptions * opts, int start_higher);
180
181PURE bool
182curve_options_are_equal (const CurveOptions * a, const CurveOptions * b);
183
188#endif
void curve_algorithm_get_localized_name(CurveAlgorithm algo, char *buf)
Stores the localized name of the algorithm in buf.
CurveAlgorithm
The algorithm to use for curves.
Definition curve.h:40
HOT NONNULL double curve_get_normalized_y(double x, CurveOptions *opts, int start_higher)
Returns the Y value on a curve specified by algo.
RETURNS_NONNULL GPtrArray * curve_get_fade_presets(void)
Returns an array of CurveFadePreset.
@ CURVE_ALGORITHM_VITAL
(e^(nx) - 1) / (e^n - 1) -10 <= n <= 10 where positive tilts down and negative tilts up (when startin...
Definition curve.h:72
@ CURVE_ALGORITHM_LOGARITHMIC
a = log (n) b = 1 / (log (1 + (1 / n)))
Definition curve.h:92
@ CURVE_ALGORITHM_PULSE
Pulse (square).
Definition curve.h:77
@ CURVE_ALGORITHM_SUPERELLIPSE
y = 1 - (1 - x^n)^(1/n) 0 < n <= 1, where the whole thing is tilting up and 0 is full tilt and 1 is s...
Definition curve.h:60
@ CURVE_ALGORITHM_EXPONENT
y = x^n 0 < n <= 1, where the whole thing is tilting up and 0 is full tilt and 1 is straight line (wh...
Definition curve.h:48
Curve options.
Definition curve.h:109
double curviness
Curviness between -1 and 1, where < 0 tils downwards, > 0 tilts upwards and 0 is a straight line.
Definition curve.h:117
CurveAlgorithm algo
Curve algorithm to use.
Definition curve.h:113
YAML utils.