]> git.cworth.org Git - scherzo/blobdiff - score.c
Make score_note_t entirely private to score.c
[scherzo] / score.c
diff --git a/score.c b/score.c
index ba27844fb02e9fc6835188f1409cd36e0442b5d2..4e2a5f3b62667a5c91c96d8486394938458c1975 100644 (file)
--- a/score.c
+++ b/score.c
 
 #include "score.h"
 
+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;
+
 struct score_staff
 {
     score_clef_t clef;
@@ -605,7 +618,7 @@ score_remove_chord (score_chord_t *chord)
     staff->num_chords -= 1;
 }
 
-score_note_t *
+void
 score_staff_add_note (score_staff_t *staff,
                      pitch_t pitch,
                      score_duration_t duration)
@@ -620,13 +633,13 @@ score_staff_add_note (score_staff_t *staff,
        if (note->pitch == pitch &&
            note->duration == duration)
        {
-           return note;
+           return;
        }
     }
 
     note = talloc (staff, score_note_t);
     if (note == NULL)
-       return NULL;
+       return;
 
     note->staff = staff;
     note->pitch = pitch;
@@ -654,15 +667,13 @@ score_staff_add_note (score_staff_t *staff,
                                   staff->num_notes);
     if (staff->notes == NULL) {
        staff->num_notes = 0;
-       return NULL;
+       return;
     }
 
     staff->notes[staff->num_notes - 1] = note;
-
-    return note;
 }
 
-score_note_t *
+void
 score_add_note (score_t *score, pitch_t pitch, score_duration_t duration)
 {
     score_staff_t *staff, *nearest_staff = NULL;
@@ -671,7 +682,7 @@ score_add_note (score_t *score, pitch_t pitch, score_duration_t duration)
 
     /* Nothing to do if we have no staff, (there's no place to add a note) . */
     if (score->num_staves == 0)
-       return NULL;
+       return;
 
     /* Find the staff where the note will be closest to the center of
      * the staff. */
@@ -684,35 +695,7 @@ score_add_note (score_t *score, pitch_t pitch, score_duration_t duration)
        }
     }
 
-    return score_staff_add_note (nearest_staff, pitch, duration);
-}
-
-void
-score_remove_note (score_note_t *note)
-{
-    score_staff_t *staff = note->staff;
-    int i;
-
-    for (i = 0; i < staff->num_notes; i++)
-       if (staff->notes[i] == note)
-           break;
-
-    if (i == staff->num_notes)
-       return;
-
-    if (i < staff->num_notes - 1)
-    {
-       memmove (staff->notes + i,
-                staff->notes + i + 1, 
-                (staff->num_notes - 1 - i) * sizeof (score_note_t *));
-    }
-
-    staff->num_notes -= 1;
-
-    if (staff->num_notes == 0) {
-       staff->upper_ledger_lines = 0;
-       staff->lower_ledger_lines = 0;
-    }
+    score_staff_add_note (nearest_staff, pitch, duration);
 }
 
 void
@@ -731,31 +714,3 @@ score_remove_notes (score_t *score)
     for (i = 0; i < score->num_staves; i++)
        score_staff_remove_notes (score->staves[i]);
 }
-
-void
-score_set_note_color_rgb (score_note_t *note,
-                         double r,
-                         double g,
-                         double b)
-{
-    note->color.r = r;
-    note->color.g = g;
-    note->color.b = b;
-}
-
-score_note_t *
-score_staff_find_note (score_staff_t *staff,
-                      pitch_t pitch,
-                      score_duration_t duration)
-{
-    int i;
-    score_note_t *note;
-
-    for (i = 0; i < staff->num_notes; i++) {
-       note = staff->notes[i];
-       if (note->pitch == pitch && note->duration == duration)
-           return note;
-    }
-
-    return NULL;
-}