- Moment stop_mom = note_l->duration() + ptr()->audio_column_l_->at_mom();
- for ( int i=0; i < stop_note_queue.size(); i++ ) {
- if ( stop_note_queue[ i ].val->pitch_i() == note_l->pitch_i() ) {
- if ( stop_note_queue[ i ].key < stop_mom )
- stop_note_queue[ i ].ignore_b_ = true;
- else // skip the stopnote
- return;
- }
+ 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 */
+ if (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;
+ }
+ }