- Moment stop = note_l->duration() + ptr()->when();
- for(int i=0; i < stop_notes.size(); i++) {
- if (stop_notes[i].val->melodic()->pitch() ==
- note_l->pitch()) {
- if ( stop_notes[i].key < stop){
- stop_notes[i].ignore_b_=true;
- }
- else
- return; // skip the stop note
- }
+ Audio_item *ptr = items_[index_];
+ assert (note->audio_ == ptr);
+ int now_ticks = ptr->audio_column_->ticks ();
+ int stop_ticks = int (moment_to_real (note->audio_->length_mom_) *
+ Real (384 * 4)) + now_ticks;
+ for (vsize i = 0; i < stop_note_queue.size (); i++)
+ {
+ /* 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;
+ }
+ }