]> git.cworth.org Git - scherzo/blobdiff - score.h
Simplify chord-signature matching by dropping duplicates first
[scherzo] / score.h
diff --git a/score.h b/score.h
index 531710348a6a2caad7b1222e622fc8b8d8146cb6..ea363538b95d47a5c75bf4dc78882f017a9797df 100644 (file)
--- a/score.h
+++ b/score.h
@@ -46,18 +46,18 @@ 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
 {
@@ -132,8 +132,22 @@ typedef struct score_note
     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,
@@ -185,10 +199,28 @@ score_add_note (score_staff_t *staff,
                int octave,
                score_duration_t);
 
-/* Remove the given note from the given staff. */
+/* 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 *