Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
quantize_options.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2019-2021 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __AUDIO_QUANTIZE_OPTIONS_H__
11#define __AUDIO_QUANTIZE_OPTIONS_H__
12
13#include "dsp/position.h"
14#include "dsp/snap_grid.h"
15#include "utils/yaml.h"
16
23#define QUANTIZE_OPTIONS_SCHEMA_VERSION 1
24
25#define QUANTIZE_OPTIONS_IS_EDITOR(qo) (PROJECT->quantize_opts_editor == qo)
26#define QUANTIZE_OPTIONS_IS_TIMELINE(qo) (PROJECT->quantize_opts_timeline == qo)
27#define QUANTIZE_OPTIONS_TIMELINE (PROJECT->quantize_opts_timeline)
28#define QUANTIZE_OPTIONS_EDITOR (PROJECT->quantize_opts_editor)
29
30#define MAX_SNAP_POINTS 120096
31
32typedef struct QuantizeOptions
33{
34 int schema_version;
35
37 NoteLength note_length;
38
41
43 float amount;
44
48
52
54 float swing;
55
57 double rand_ticks;
58
68 Position q_points[MAX_SNAP_POINTS];
69 int num_q_points;
71
72static const cyaml_schema_field_t quantize_options_fields_schema[] = {
73 YAML_FIELD_INT (QuantizeOptions, schema_version),
74 YAML_FIELD_ENUM (QuantizeOptions, note_length, note_length_strings),
75 YAML_FIELD_ENUM (QuantizeOptions, note_type, note_type_strings),
76 YAML_FIELD_FLOAT (QuantizeOptions, amount),
77 YAML_FIELD_INT (QuantizeOptions, adj_start),
78 YAML_FIELD_INT (QuantizeOptions, adj_end),
79 YAML_FIELD_FLOAT (QuantizeOptions, swing),
80 YAML_FIELD_FLOAT (QuantizeOptions, rand_ticks),
81
82 CYAML_FIELD_END
83};
84
85static const cyaml_schema_value_t quantize_options_schema = {
86 YAML_VALUE_PTR (QuantizeOptions, quantize_options_fields_schema),
87};
88
89void
90quantize_options_init (QuantizeOptions * self, NoteLength note_length);
91
95void
97
98float
99quantize_options_get_swing (QuantizeOptions * self);
100
101float
102quantize_options_get_amount (QuantizeOptions * self);
103
104float
105quantize_options_get_randomization (QuantizeOptions * self);
106
107void
108quantize_options_set_swing (QuantizeOptions * self, float swing);
109
110void
111quantize_options_set_amount (QuantizeOptions * self, float amount);
112
113void
114quantize_options_set_randomization (QuantizeOptions * self, float randomization);
115
121char *
122quantize_options_stringize (NoteLength note_length, NoteType note_type);
123
135double
137
143
145quantize_options_new (void);
146
150void
152
157#endif
Snap/grid information.
void quantize_options_update_quantize_points(QuantizeOptions *self)
Updates snap points.
NoteType
Definition snap_grid.h:66
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:202
Position struct and API.
A Position is made up of bars.beats.sixteenths.ticks.
Definition position.h:129
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.