Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
scale.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2018-2022 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
12#ifndef __AUDIO_SCALE_H__
13#define __AUDIO_SCALE_H__
14
15#include <cstdint>
16
18
19#include <glib/gi18n.h>
20
27#define SCALE_SCHEMA_VERSION 2
28
33{
36
37 /* --- popular scales --- */
38
39 SCALE_MAJOR,
40
43
46
47 SCALE_DORIAN,
48 SCALE_PHRYGIAN,
49 SCALE_LYDIAN,
50 SCALE_MIXOLYDIAN,
51
54
55 SCALE_LOCRIAN,
56 SCALE_MELODIC_MINOR,
57 SCALE_HARMONIC_MINOR,
58 SCALE_WHOLE_TONE,
59 SCALE_MAJOR_PENTATONIC,
60 SCALE_MINOR_PENTATONIC,
61 SCALE_OCTATONIC_HALF_WHOLE,
62 SCALE_OCTATONIC_WHOLE_HALF,
63
64 /* --- exotic scales --- */
65
68
69 SCALE_HARMONIC_MAJOR,
70 SCALE_PHRYGIAN_DOMINANT,
71 SCALE_MAJOR_LOCRIAN,
72 SCALE_ALGERIAN,
73 SCALE_AUGMENTED,
74 SCALE_DOUBLE_HARMONIC,
75 SCALE_CHINESE,
76 SCALE_DIMINISHED,
77 SCALE_DOMINANT_DIMINISHED,
78 SCALE_EGYPTIAN,
79 SCALE_EIGHT_TONE_SPANISH,
80 SCALE_ENIGMATIC,
81 SCALE_GEEZ,
82 SCALE_HINDU,
83 SCALE_HIRAJOSHI,
84 SCALE_HUNGARIAN_GYPSY,
85 SCALE_INSEN,
86 SCALE_NEAPOLITAN_MAJOR,
87 SCALE_NEAPOLITAN_MINOR,
88 SCALE_ORIENTAL,
89 SCALE_ROMANIAN_MINOR,
90 SCALE_ALTERED,
91 SCALE_MAQAM,
92 SCALE_YO,
93 SCALE_BEBOP_LOCRIAN,
94 SCALE_BEBOP_DOMINANT,
95 SCALE_BEBOP_MAJOR,
96 SCALE_SUPER_LOCRIAN,
97 SCALE_ENIGMATIC_MINOR,
98 SCALE_COMPOSITE,
99 SCALE_BHAIRAV,
100 SCALE_HUNGARIAN_MINOR,
101 SCALE_PERSIAN,
102 SCALE_IWATO,
103 SCALE_KUMOI,
104 SCALE_PELOG,
105 SCALE_PROMETHEUS,
106 SCALE_PROMETHEUS_NEAPOLITAN,
107 SCALE_PROMETHEUS_LISZT,
108 SCALE_BALINESE,
109 SCALE_RAGATODI,
110 SCALE_JAPANESE1,
111 SCALE_JAPANESE2,
112
113 /* --- TODO unimplemented --- */
114
115 SCALE_BLUES,
116 SCALE_FLAMENCO,
117 SCALE_GYPSY,
118 SCALE_HALF_DIMINISHED,
119 SCALE_IN,
120 SCALE_ISTRIAN,
121 SCALE_LYDIAN_AUGMENTED,
122 SCALE_TRITONE,
123 SCALE_UKRANIAN_DORIAN,
124};
125
129typedef struct MusicalScale
130{
133
135 MusicalNote root_key;
137
142musical_scale_new (MusicalScaleType type, MusicalNote root);
143
151const bool *
152musical_scale_get_notes (MusicalScaleType scale_type, bool ascending);
153
165RETURNS_NONNULL
166const ChordType *
168
174
175const char *
176musical_scale_type_to_string (const MusicalScaleType type);
177
183char *
185
190void
191musical_scale_strcpy (MusicalScale * scale, char * buf);
192
196static inline int
197musical_scale_is_equal (MusicalScale * a, MusicalScale * b)
198{
199 return a->type == b->type && a->root_key == b->root_key;
200}
201
206bool
208 const MusicalScale * const scale,
209 const ChordDescriptor * const chord);
210
214int
216 MusicalScale * scale,
217 MusicalNote chord_root,
218 ChordType type,
219 ChordAccent chord_accent);
220
227bool
228musical_scale_contains_note (const MusicalScale * scale, MusicalNote note);
229
235char *
237
241void
243
248#endif
Descriptors for chords.
bool musical_scale_contains_note(const MusicalScale *scale, MusicalNote note)
Returns if the given key is in the given MusicalScale.
bool musical_scale_contains_chord(const MusicalScale *const scale, const ChordDescriptor *const chord)
Returns if all of the chord's notes are in the scale.
char * musical_scale_as_string(MusicalScale *scale)
Returns the scale in human readable string.
char * musical_scale_to_string(const MusicalScale *const self)
Prints the MusicalScale to a string.
ChordAccent
Chord accents.
void musical_scale_strcpy(MusicalScale *scale, char *buf)
Same as above but uses a buffer instead of allocating.
MusicalScale * musical_scale_new(MusicalScaleType type, MusicalNote root)
Creates new scale using type and root note.
RETURNS_NONNULL const ChordType * musical_scale_get_triad_types(MusicalScaleType scale_type, bool ascending)
Returns the triads in the given scale.
void musical_scale_free(MusicalScale *scale)
Frees the MusicalScale.
const bool * musical_scale_get_notes(MusicalScaleType scale_type, bool ascending)
Returns the notes in the given scale.
int musical_scale_is_accent_in_scale(MusicalScale *scale, MusicalNote chord_root, ChordType type, ChordAccent chord_accent)
Returns if the accent is in the scale.
MusicalScale * musical_scale_clone(MusicalScale *src)
Clones the scale.
MusicalScaleType
Scale type (name) eg Aeolian.
Definition scale.h:33
ChordType
Chord type.
@ SCALE_AEOLIAN
Natural minor (same as SCALE_MINOR).
@ SCALE_CHROMATIC
All keys.
@ SCALE_MINOR
Natural minor.
@ SCALE_IONIAN
Major (same as SCALE_MAJOR).
@ SCALE_ACOUSTIC
Lydian dominant.
A ChordDescriptor describes a chord and is not linked to any specific object by itself.
Musical scale descriptor.
Definition scale.h:130
MusicalScaleType type
Identification of the scale (e.g.
Definition scale.h:132
MusicalNote root_key
Root key of the scale.
Definition scale.h:135