]> git.cworth.org Git - scherzo/blobdiff - scherzo.c
Avoid duplicating notes within note_group_t and score_staff_t
[scherzo] / scherzo.c
index 0b0a97f77e9ed2049f82422d1069300525e0fa39..3fcae5cfb9e3e291f367b9cac94726ad6c7f4b7a 100644 (file)
--- a/scherzo.c
+++ b/scherzo.c
@@ -585,6 +585,17 @@ note_group_init (void *ctx, note_group_t *group)
 static void
 note_group_add_note (note_group_t *group, score_note_t *note)
 {
+    int i;
+
+    /* Do nothing if note is already in group. */
+    for (i = 0; i < group->num_notes; i++) {
+       if (group->notes[i]->pitch == note->pitch &&
+           group->notes[i]->octave == note->octave)
+       {
+           return;
+       }
+    }
+
     group->num_notes++;
 
     if (group->num_notes > group->size) {