- /* if this pith already in queue */
- if (stop_note_queue[i].val->get_semitone_pitch () == note->get_semitone_pitch ())
- {
- if (stop_note_queue[i].key < stop_mom)
- {
- /* let stopnote in queue be ignored,
- new stop note wins */
- stop_note_queue[i].ignore_b_ = true;
- /* don't replay start note, */
- play_start = false;
- break;
- }
- else
- {
- /* skip this stopnote,
- don't play the start note */
- delete note;
- note = 0;
- break;
- }
- }
+ /* if this pitch already in queue, and is not already ignored */
+ if (!stop_note_queue[i].ignore_ &&
+ stop_note_queue[i].val->get_semitone_pitch ()
+ == note->get_semitone_pitch ())
+ {
+ int queued_ticks
+ = stop_note_queue[i].val->audio_->audio_column_->ticks ();
+ // If the two notes started at the same time, or option is set,
+ if (now_ticks == queued_ticks || merge_unisons_)
+ {
+ // merge them.
+ if (stop_note_queue[i].key < stop_ticks)
+ {
+ Midi_note_event e;
+ e.val = stop_note_queue[i].val;
+ e.key = stop_ticks;
+ stop_note_queue[i].ignore_ = true;
+ stop_note_queue.insert (e);
+ }
+ note = 0;
+ break;
+ }
+ else
+ {
+ // A note was played that interruped a played note.
+ // Stop the old note, and continue to the greatest moment
+ // between the two.
+ if (stop_note_queue[i].key > stop_ticks)
+ {
+ stop_ticks = stop_note_queue[i].key;
+ }
+ output_event (now_ticks, stop_note_queue[i].val);
+ stop_note_queue[i].ignore_ = true;
+ break;
+ }
+ }