]> git.cworth.org Git - scherzo/blobdiff - score.c
Avoid duplicating notes within note_group_t and score_staff_t
[scherzo] / score.c
diff --git a/score.c b/score.c
index e319af0c238abaf594afee0088bc8c580de6f59e..ac0d346522715896fc3c2e478a3a215a2b32619e 100644 (file)
--- a/score.c
+++ b/score.c
@@ -538,6 +538,18 @@ score_add_note (score_staff_t *staff,
 {
     score_note_t *note;
     double line;
+    int i;
+
+    /* Return existing note if already present. */
+    for (i = 0; i < staff->num_notes; i++) {
+       note = staff->notes[i];
+       if (note->pitch == pitch &&
+           note->octave == octave &&
+           note->duration == duration)
+       {
+           return note;
+       }
+    }
 
     note = talloc (staff, score_note_t);
     if (note == NULL)