- int found = 0;
- int target_midi = _pitch_and_octave_to_midi (pitch, octave);
- int note_midi;
-
- for (i = scherzo->notes_pressed.num_notes - 1; i >=0; i--) {
- note = scherzo->notes_pressed.notes[i];
- note_midi = _pitch_and_octave_to_midi (note->pitch, note->octave);
- if (note_midi == target_midi) {
- found = 1;
- if (! scherzo->pedal_pressed)
- score_remove_note (note);
- note_group_remove_note_at (&scherzo->notes_pressed, i);
- }
+
+ /* Do nothing if this note is already pressed. */
+ for (i = 0; i < scherzo->notes_pressed.num_pitches; i++)
+ if (scherzo->notes_pressed.pitches[i] == pitch)
+ return;
+
+ pitch_group_add_pitch (&scherzo->notes_pressed, pitch);
+
+ if (scherzo->pedal_pressed)
+ pitch_group_add_pitch (&scherzo->notes_pedaled, pitch);
+
+ /* Remove all notes from score, then add current notes. */
+ score_remove_notes (scherzo->score);
+
+ for (i = 0; i < scherzo->notes_pressed.num_pitches; i++)
+ {
+ score_add_note (scherzo->score, scherzo->notes_pressed.pitches[i],
+ SCORE_DURATION_WHOLE);