X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=score.h;h=5dd61887d340da2bbb5ca5420af8dc23bd968bc4;hb=41e993a65ab55db1f3297003fe65dd556a15f85f;hp=ea363538b95d47a5c75bf4dc78882f017a9797df;hpb=05713bff8bc084c401d58b1b9526d83d9a42b641;p=scherzo diff --git a/score.h b/score.h index ea36353..5dd6188 100644 --- a/score.h +++ b/score.h @@ -24,85 +24,7 @@ #include #include -typedef struct score score_t; -typedef struct score_staff score_staff_t; - -#define SCORE_PITCH_ACCIDENTAL_MASK 0x07 -#define SCORE_PITCH_ACCIDENTAL_SHIFT 0 - -typedef enum score_pitch_accidental -{ - SCORE_PITCH_ACCIDENTAL_DOUBLE_FLAT, - SCORE_PITCH_ACCIDENTAL_FLAT, - SCORE_PITCH_ACCIDENTAL_NATURAL, - SCORE_PITCH_ACCIDENTAL_SHARP, - SCORE_PITCH_ACCIDENTAL_DOUBLE_SHARP -} score_pitch_accidental_t; - -#define SCORE_PITCH_ACCIDENTAL(pitch) (((pitch) & SCORE_PITCH_ACCIDENTAL_MASK) >> SCORE_PITCH_ACCIDENTAL_SHIFT) - -#define SCORE_PITCH_NAME_MASK 0x38 -#define SCORE_PITCH_NAME_SHIFT 3 - -typedef enum score_pitch_name -{ - SCORE_PITCH_NAME_C, - SCORE_PITCH_NAME_D, - SCORE_PITCH_NAME_E, - SCORE_PITCH_NAME_F, - SCORE_PITCH_NAME_G, - SCORE_PITCH_NAME_A, - SCORE_PITCH_NAME_B, -} score_pitch_name_t; - -#define SCORE_PITCH_NAME(pitch) (((pitch) & SCORE_PITCH_NAME_MASK) >> SCORE_PITCH_NAME_SHIFT) - -#define SCORE_PITCH_VALUE(name, accidental) ((SCORE_PITCH_NAME_##name << SCORE_PITCH_NAME_SHIFT) + (SCORE_PITCH_ACCIDENTAL_##accidental)) - -typedef enum score_pitch -{ - SCORE_PITCH_Cff = SCORE_PITCH_VALUE (C, DOUBLE_FLAT), - SCORE_PITCH_Cf = SCORE_PITCH_VALUE (C, FLAT), - SCORE_PITCH_C = SCORE_PITCH_VALUE (C, NATURAL), - SCORE_PITCH_Cs = SCORE_PITCH_VALUE (C, SHARP), - SCORE_PITCH_Css = SCORE_PITCH_VALUE (C, DOUBLE_SHARP), - - SCORE_PITCH_Dff = SCORE_PITCH_VALUE (D, DOUBLE_FLAT), - SCORE_PITCH_Df = SCORE_PITCH_VALUE (D, FLAT), - SCORE_PITCH_D = SCORE_PITCH_VALUE (D, NATURAL), - SCORE_PITCH_Ds = SCORE_PITCH_VALUE (D, SHARP), - SCORE_PITCH_Dss = SCORE_PITCH_VALUE (D, DOUBLE_SHARP), - - SCORE_PITCH_Eff = SCORE_PITCH_VALUE (E, DOUBLE_FLAT), - SCORE_PITCH_Ef = SCORE_PITCH_VALUE (E, FLAT), - SCORE_PITCH_E = SCORE_PITCH_VALUE (E, NATURAL), - SCORE_PITCH_Es = SCORE_PITCH_VALUE (E, SHARP), - SCORE_PITCH_Ess = SCORE_PITCH_VALUE (E, DOUBLE_SHARP), - - SCORE_PITCH_Fff = SCORE_PITCH_VALUE (F, DOUBLE_FLAT), - SCORE_PITCH_Ff = SCORE_PITCH_VALUE (F, FLAT), - SCORE_PITCH_F = SCORE_PITCH_VALUE (F, NATURAL), - SCORE_PITCH_Fs = SCORE_PITCH_VALUE (F, SHARP), - SCORE_PITCH_Fss = SCORE_PITCH_VALUE (F, DOUBLE_SHARP), - - SCORE_PITCH_Gff = SCORE_PITCH_VALUE (G, DOUBLE_FLAT), - SCORE_PITCH_Gf = SCORE_PITCH_VALUE (G, FLAT), - SCORE_PITCH_G = SCORE_PITCH_VALUE (G, NATURAL), - SCORE_PITCH_Gs = SCORE_PITCH_VALUE (G, SHARP), - SCORE_PITCH_Gss = SCORE_PITCH_VALUE (G, DOUBLE_SHARP), - - SCORE_PITCH_Aff = SCORE_PITCH_VALUE (A, DOUBLE_FLAT), - SCORE_PITCH_Af = SCORE_PITCH_VALUE (A, FLAT), - SCORE_PITCH_A = SCORE_PITCH_VALUE (A, NATURAL), - SCORE_PITCH_As = SCORE_PITCH_VALUE (A, SHARP), - SCORE_PITCH_Ass = SCORE_PITCH_VALUE (A, DOUBLE_SHARP), - - SCORE_PITCH_Bff = SCORE_PITCH_VALUE (B, DOUBLE_FLAT), - SCORE_PITCH_Bf = SCORE_PITCH_VALUE (B, FLAT), - SCORE_PITCH_B = SCORE_PITCH_VALUE (B, NATURAL), - SCORE_PITCH_Bs = SCORE_PITCH_VALUE (B, SHARP), - SCORE_PITCH_Bss = SCORE_PITCH_VALUE (B, DOUBLE_SHARP) -} score_pitch_t; +#include "pitch.h" typedef enum score_duration { @@ -126,10 +48,13 @@ typedef enum score_duration #define SCORE_BUILD_NOTE(pitch, octave, duration) SCORE_PITCH_##pitch, (octave), SCORE_DURATION_##duration +typedef struct score score_t; +typedef struct score_staff score_staff_t; + typedef struct score_note { score_staff_t *staff; - score_pitch_t pitch; + pitch_t pitch; int octave; score_duration_t duration; @@ -195,13 +120,16 @@ score_add_staff (score_t *score, score_clef_t clef); */ score_note_t * score_add_note (score_staff_t *staff, - score_pitch_t pitch, + pitch_t pitch, int octave, score_duration_t); /* Add a chord symbol of 'name' to a staff. * * For now, the chord symbols are free-form names. + * + * The chord name must be a talloc'ed string, which the returned + * score_chord_t will talloc_steal. */ score_chord_t * score_add_chord (score_staff_t *staff, @@ -225,7 +153,7 @@ score_set_note_color_rgb (score_note_t *note, * octave, and durations. Returns NULL if no match is found. */ score_note_t * score_staff_find_note (score_staff_t *staff, - score_pitch_t pitch, + pitch_t pitch, int octave, score_duration_t duration);