10#ifndef __AUDIO_SNAP_GRID_H__
11#define __AUDIO_SNAP_GRID_H__
17#include <glib/gi18n.h>
25#define SNAP_GRID_SCHEMA_VERSION 1
27#define SNAP_GRID_TIMELINE (PROJECT->snap_grid_timeline)
28#define SNAP_GRID_EDITOR (PROJECT->snap_grid_editor)
30#define SNAP_GRID_IS_EDITOR(sg) (SNAP_GRID_EDITOR == sg)
31#define SNAP_GRID_IS_TIMELINE(sg) (SNAP_GRID_TIMELINE == sg)
33#define SNAP_GRID_ANY_SNAP(sg) \
34 (sg->snap_to_grid || sg->snap_to_events)
35#define SNAP_GRID_DEFAULT_MAX_BAR 10000
37typedef enum NoteLength
52static const cyaml_strval_t note_length_strings[] = {
53 {N_ (
"bar"), NOTE_LENGTH_BAR },
54 { N_ (
"beat"), NOTE_LENGTH_BEAT },
55 {
"2/1", NOTE_LENGTH_2_1 },
56 {
"1/1", NOTE_LENGTH_1_1 },
57 {
"1/2", NOTE_LENGTH_1_2 },
58 {
"1/4", NOTE_LENGTH_1_4 },
59 {
"1/8", NOTE_LENGTH_1_8 },
60 {
"1/16", NOTE_LENGTH_1_16 },
61 {
"1/32", NOTE_LENGTH_1_32 },
62 {
"1/64", NOTE_LENGTH_1_64 },
63 {
"1/128", NOTE_LENGTH_1_128},
73static const cyaml_strval_t note_type_strings[] = {
74 {N_ (
"normal"), NOTE_TYPE_NORMAL },
83static const cyaml_strval_t note_type_short_strings[] = {
84 {
"", NOTE_TYPE_NORMAL },
101static const cyaml_strval_t note_length_type_strings[] = {
112 SNAP_GRID_TYPE_TIMELINE,
113 SNAP_GRID_TYPE_EDITOR,
116static const cyaml_strval_t snap_grid_type_strings[] = {
117 {
"timeline", SNAP_GRID_TYPE_TIMELINE},
118 {
"editor", SNAP_GRID_TYPE_EDITOR },
176static const cyaml_schema_field_t snap_grid_fields_schema[] = {
177 YAML_FIELD_INT (
SnapGrid, schema_version),
178 YAML_FIELD_ENUM (
SnapGrid, type, snap_grid_type_strings),
182 note_length_strings),
183 YAML_FIELD_ENUM (
SnapGrid, snap_note_type, note_type_strings),
184 YAML_FIELD_INT (
SnapGrid, snap_adaptive),
188 note_length_strings),
193 YAML_FIELD_INT (
SnapGrid, default_adaptive),
197 note_length_type_strings),
198 YAML_FIELD_INT (
SnapGrid, snap_to_grid),
199 YAML_FIELD_INT (
SnapGrid, snap_to_grid_keep_offset),
200 YAML_FIELD_INT (
SnapGrid, snap_to_events),
205static const cyaml_schema_value_t snap_grid_schema = {
206 CYAML_VALUE_MAPPING (
209 snap_grid_fields_schema),
216 NoteLength note_length,
220snap_grid_get_ticks_from_length_and_type (
231snap_grid_get_snap_frames (
const SnapGrid * self);
247 NoteLength note_length,
276 const bool return_prev);
NONNULL int snap_grid_get_snap_ticks(const SnapGrid *self)
Gets a snap point's length in ticks.
char * snap_grid_stringize(SnapGrid *self)
Returns the grid intensity as a human-readable string.
SnapGridType
Snap grid type.
int snap_grid_get_default_ticks(SnapGrid *self)
Gets a the default length in ticks.
char * snap_grid_stringize_length_and_type(NoteLength note_length, NoteType note_type)
Returns the grid intensity as a human-readable string.
NONNULL bool snap_grid_get_nearby_snap_point(Position *ret_pos, const SnapGrid *const self, const Position *pos, const bool return_prev)
Returns the next or previous SnapGrid point.
@ NOTE_TYPE_DOTTED
2/3 of its original size
@ NOTE_TYPE_TRIPLET
3/2 of its original size
@ NOTE_LENGTH_LINK
Link length with snap setting.
@ NOTE_LENGTH_CUSTOM
Custom length.
@ NOTE_LENGTH_LAST_OBJECT
Use last created object's length.
A Position is made up of bars.beats.sixteenths.ticks.
bool default_adaptive
If this is on, the default note length will be determined automatically based on the current zoom lev...
bool snap_to_grid_keep_offset
Whether to keep the offset when moving items.
NoteLengthType length_type
See NoteLengthType.
NoteType snap_note_type
Snap note type.
bool snap_to_grid
Whether to snap to the grid.
NoteLength snap_note_length
Snap note length.
bool snap_adaptive
If this is on, the snap note length will be determined automatically based on the current zoom level.
bool snap_to_events
Whether to snap to events.
NoteType default_note_type
Default note type.
NoteLength default_note_length
Default note length.