]> git.cworth.org Git - scherzo/blobdiff - score.h
Fix scherzo to use pitch_t rather than score_note_t for computation
[scherzo] / score.h
diff --git a/score.h b/score.h
index 25d558329eb4c05923b924119daac08e8b8041e1..b8791f67f1caa5f8dd0ab9257efa9997d312fb46 100644 (file)
--- a/score.h
+++ b/score.h
 #include <talloc.h>
 #include <cairo.h>
 
-typedef struct score score_t;
-typedef struct score_staff score_staff_t;
-typedef struct score_note score_note_t;
-
-typedef enum score_pitch
-{
-    SCORE_PITCH_Aff,
-    SCORE_PITCH_Af,
-    SCORE_PITCH_A,
-    SCORE_PITCH_As,
-    SCORE_PITCH_Ass,
-
-    SCORE_PITCH_Bff,
-    SCORE_PITCH_Bf,
-    SCORE_PITCH_B,
-    SCORE_PITCH_Bs,
-    SCORE_PITCH_Bss,
-
-    SCORE_PITCH_Cff,
-    SCORE_PITCH_Cf,
-    SCORE_PITCH_C,
-    SCORE_PITCH_Cs,
-    SCORE_PITCH_Css,
-
-    SCORE_PITCH_Dff,
-    SCORE_PITCH_Df,
-    SCORE_PITCH_D,
-    SCORE_PITCH_Ds,
-    SCORE_PITCH_Dss,
-
-    SCORE_PITCH_Eff,
-    SCORE_PITCH_Ef,
-    SCORE_PITCH_E,
-    SCORE_PITCH_Es,
-    SCORE_PITCH_Ess,
-
-    SCORE_PITCH_Fff,
-    SCORE_PITCH_Ff,
-    SCORE_PITCH_F,
-    SCORE_PITCH_Fs,
-    SCORE_PITCH_Fss,
-
-    SCORE_PITCH_Gff,
-    SCORE_PITCH_Gf,
-    SCORE_PITCH_G,
-    SCORE_PITCH_Gs,
-    SCORE_PITCH_Gss
-} score_pitch_t;
+#include "pitch.h"
 
 typedef enum score_duration
 {
@@ -95,10 +48,36 @@ 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;
+    pitch_t pitch;
+    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,
-    SCORE_CLEF_F
+    SCORE_CLEF_TREBLE = SCORE_CLEF_G,
+    SCORE_CLEF_F,
+    SCORE_CLEF_BASS = SCORE_CLEF_F
 } score_clef_t;
 
 /* Allocate a new, empty score object, (with optional ctx as talloc
@@ -129,10 +108,7 @@ score_add_brace (score_t *score, int staves);
 score_staff_t *
 score_add_staff (score_t *score, score_clef_t clef);
 
-/* Add a note to a staff of the given pitch, octave, and duration.
- *
- * Octave numbers are ISO octave numbers [0:8], (so Octave 4 is from
- * middle C to the B above middle C).
+/* Add a note to a staff of the given pitch and duration.
  *
  * Duration values can be symbolic (SCORE_DURATION_WHOLE, _QUARTER,
  * _EIGHTH, etc.) or numerical as simply the denominator (WHOLE=1,
@@ -140,9 +116,53 @@ score_add_staff (score_t *score, score_clef_t clef);
  */
 score_note_t *
 score_staff_add_note (score_staff_t *staff,
-                     score_pitch_t pitch,
-                     int octave,
-                     score_duration_t);
+                     pitch_t pitch,
+                     score_duration_t duration);
+
+/* Add a note to the score, (automatically selecting the nearest
+ * staff) */
+score_note_t *
+score_add_note (score_t *score, pitch_t pitch, score_duration_t duration);
+
+/* 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,
+                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);
+
+/* Remove all notes from the given staff. */
+void
+score_staff_remove_notes (score_staff_t *staff);
+
+/* Remove all notes from the score. */
+void
+score_remove_notes (score_t *score);
+
+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,
+                      pitch_t pitch,
+                      score_duration_t duration);
 
 /* Draw the given score_t onto the given cairo_t.
  *