X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=score.h;h=ea363538b95d47a5c75bf4dc78882f017a9797df;hb=e1b42d290d7e53d454b6e71e36acc4f10652f186;hp=98dd26f89cb9f20f216e84afcd43de872a7e8d5b;hpb=f6b8f7f23bb8a4a5b30bfde8242578cca90ddacf;p=scherzo diff --git a/score.h b/score.h index 98dd26f..ea36353 100644 --- a/score.h +++ b/score.h @@ -26,7 +26,6 @@ typedef struct score score_t; typedef struct score_staff score_staff_t; -typedef struct score_note score_note_t; #define SCORE_PITCH_ACCIDENTAL_MASK 0x07 #define SCORE_PITCH_ACCIDENTAL_SHIFT 0 @@ -47,33 +46,21 @@ typedef enum score_pitch_accidental typedef enum score_pitch_name { - SCORE_PITCH_NAME_C = 0 << SCORE_PITCH_NAME_SHIFT, - SCORE_PITCH_NAME_D = 1 << SCORE_PITCH_NAME_SHIFT, - SCORE_PITCH_NAME_E = 2 << SCORE_PITCH_NAME_SHIFT, - SCORE_PITCH_NAME_F = 3 << SCORE_PITCH_NAME_SHIFT, - SCORE_PITCH_NAME_G = 4 << SCORE_PITCH_NAME_SHIFT, - SCORE_PITCH_NAME_A = 5 << SCORE_PITCH_NAME_SHIFT, - SCORE_PITCH_NAME_B = 6 << SCORE_PITCH_NAME_SHIFT + 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_ACCIDENTAL_##accidental)) +#define SCORE_PITCH_VALUE(name, accidental) ((SCORE_PITCH_NAME_##name << SCORE_PITCH_NAME_SHIFT) + (SCORE_PITCH_ACCIDENTAL_##accidental)) typedef enum score_pitch { - 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_Cff = SCORE_PITCH_VALUE (C, DOUBLE_FLAT), SCORE_PITCH_Cf = SCORE_PITCH_VALUE (C, FLAT), SCORE_PITCH_C = SCORE_PITCH_VALUE (C, NATURAL), @@ -103,6 +90,18 @@ typedef enum score_pitch 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; typedef enum score_duration @@ -127,6 +126,28 @@ typedef enum score_duration #define SCORE_BUILD_NOTE(pitch, octave, duration) SCORE_PITCH_##pitch, (octave), SCORE_DURATION_##duration +typedef struct score_note +{ + score_staff_t *staff; + score_pitch_t pitch; + int octave; + score_duration_t duration; + + struct { + double r; + double g; + double b; + } color; +} score_note_t; + +typedef struct score_chord +{ + score_staff_t *staff; + + char *name; + double width; +} score_chord_t; + typedef enum score_clef { SCORE_CLEF_G, @@ -173,10 +194,40 @@ score_add_staff (score_t *score, score_clef_t clef); * QUARTER=4, EIGHTH=8, etc.) */ score_note_t * -score_staff_add_note (score_staff_t *staff, - score_pitch_t pitch, - int octave, - score_duration_t); +score_add_note (score_staff_t *staff, + score_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. + */ +score_chord_t * +score_add_chord (score_staff_t *staff, + const char * name); + +/* Remove the given chord from its staff. */ +void +score_remove_chord (score_chord_t *chord); + +/* Remove the given note from its staff. */ +void +score_remove_note (score_note_t *note); + +void +score_set_note_color_rgb (score_note_t *note, + double r, + double g, + double b); + +/* Return the first note on the given staff with the given pitch, + * 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, + int octave, + score_duration_t duration); /* Draw the given score_t onto the given cairo_t. *