Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
quantize_options.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019-2021 Alexandros Theodotou <alex at zrythm dot org>
3 *
4 * This file is part of Zrythm
5 *
6 * Zrythm is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Zrythm is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26#ifndef __AUDIO_QUANTIZE_OPTIONS_H__
27#define __AUDIO_QUANTIZE_OPTIONS_H__
28
29#include "dsp/position.h"
30#include "dsp/snap_grid.h"
31#include "utils/yaml.h"
32
39#define QUANTIZE_OPTIONS_SCHEMA_VERSION 1
40
41#define QUANTIZE_OPTIONS_IS_EDITOR(qo) \
42 (PROJECT->quantize_opts_editor == qo)
43#define QUANTIZE_OPTIONS_IS_TIMELINE(qo) \
44 (PROJECT->quantize_opts_timeline == qo)
45#define QUANTIZE_OPTIONS_TIMELINE \
46 (PROJECT->quantize_opts_timeline)
47#define QUANTIZE_OPTIONS_EDITOR \
48 (PROJECT->quantize_opts_editor)
49
50#define MAX_SNAP_POINTS 120096
51
52typedef struct QuantizeOptions
53{
54 int schema_version;
55
57 NoteLength note_length;
58
61
63 float amount;
64
68
72
74 float swing;
75
77 double rand_ticks;
78
88 Position q_points[MAX_SNAP_POINTS];
89 int num_q_points;
91
92static const cyaml_schema_field_t quantize_options_fields_schema[] = {
93 YAML_FIELD_INT (QuantizeOptions, schema_version),
94 YAML_FIELD_ENUM (
96 note_length,
97 note_length_strings),
98 YAML_FIELD_ENUM (QuantizeOptions, note_type, note_type_strings),
99 YAML_FIELD_FLOAT (QuantizeOptions, amount),
100 YAML_FIELD_INT (QuantizeOptions, adj_start),
101 YAML_FIELD_INT (QuantizeOptions, adj_end),
102 YAML_FIELD_FLOAT (QuantizeOptions, swing),
103 YAML_FIELD_FLOAT (QuantizeOptions, rand_ticks),
104
105 CYAML_FIELD_END
106};
107
108static const cyaml_schema_value_t quantize_options_schema = {
111 quantize_options_fields_schema),
112};
113
114void
115quantize_options_init (
116 QuantizeOptions * self,
117 NoteLength note_length);
118
122void
124 QuantizeOptions * self);
125
126float
127quantize_options_get_swing (QuantizeOptions * self);
128
129float
130quantize_options_get_amount (QuantizeOptions * self);
131
132float
133quantize_options_get_randomization (QuantizeOptions * self);
134
135void
136quantize_options_set_swing (
137 QuantizeOptions * self,
138 float swing);
139
140void
141quantize_options_set_amount (
142 QuantizeOptions * self,
143 float amount);
144
145void
146quantize_options_set_randomization (
147 QuantizeOptions * self,
148 float randomization);
149
155char *
157 NoteLength note_length,
158 NoteType note_type);
159
171double
173 QuantizeOptions * self,
174 Position * pos);
175
181
183quantize_options_new (void);
184
188void
190
195#endif
Snap/grid information.
void quantize_options_update_quantize_points(QuantizeOptions *self)
Updates snap points.
NoteType
Definition snap_grid.h:67
void quantize_options_free(QuantizeOptions *self)
Free's the QuantizeOptions.
QuantizeOptions * quantize_options_clone(const QuantizeOptions *src)
Clones the QuantizeOptions.
double quantize_options_quantize_position(QuantizeOptions *self, Position *pos)
Quantizes the given Position using the given QuantizeOptions.
char * quantize_options_stringize(NoteLength note_length, NoteType note_type)
Returns the grid intensity as a human-readable string.
#define YAML_VALUE_PTR(cc, fields_schema)
Schema to be used as a pointer.
Definition yaml.h:221
Position struct and API.
A Position is made up of bars.beats.sixteenths.ticks.
Definition position.h:137
NoteLength note_length
See SnapGrid.
float amount
Percentage to apply quantize (0-100).
int adj_start
Adjust start position or not (only applies to objects with length.
NoteType note_type
See SnapGrid.
float swing
Swing amount (0-100).
double rand_ticks
Number of ticks for randomization.
int adj_end
Adjust end position or not (only applies to objects with length.
Position q_points[MAX_SNAP_POINTS]
Quantize points.
YAML utils.