public MidiEvent [ ] getMidiEventsFor ( Tuplet tuplet , KeySignature key , long elapsedTime ) throws InvalidMidiDataException { float totalTupletLength = tuplet . getTotalRelativeLength ( ) ; Vector tupletAsVector = tuplet . getNotesAsVector ( ) ; int notesNb = tupletAsVector . size ( ) ; MidiEvent [ ] events = new MidiEvent [ 3 * notesNb ] ; for ( int j = 0 ; j < tupletAsVector . size ( ) ; j ++ ) { Note note = null ; // to be fixed : this can be a note or a multi note. //if (tupletAsVector.elementAt(j) instanceof Note) note = ( Note ) ( tupletAsVector . elementAt ( j ) ) ; //else // note = (Note)((MultiNote)tupletAsVector.elementAt(j)).getNotesAsVector().elementAt(0); long noteLength = getNoteLengthInTicks ( note ) ; //, defaultLength); noteLength = ( long ) ( noteLength * totalTupletLength / notesNb ) ; if ( ! note . isRest ( ) ) { ShortMessage myNoteOn = new ShortMessage ( ) ; myNoteOn . setMessage ( ShortMessage . NOTE_ON , getMidiNoteNumber ( note , key ) , 50 ) ; events [ 3 * j ] = new MidiEvent ( myNoteOn , elapsedTime ) ; events [ 3 * j + 1 ] = new MidiEvent ( new NotationMarkerMessage ( ( Note ) note ) , elapsedTime ) ; ShortMessage myNoteOff = new ShortMessage ( ) ; myNoteOff . setMessage ( ShortMessage . NOTE_OFF , getMidiNoteNumber ( note , key ) , 50 ) ; elapsedTime += noteLength ; events [ 3 * j + 2 ] = new MidiEvent ( myNoteOff , elapsedTime ) ; } /* else if (tupletAsVector.elementAt(j) instanceof MultiNote) { events = getMidiEventsFor((MultiNote)tupletAsVector.elementAt(j), key, elapsedTime); long noteLength = events[1+(events.length-1)/2].getTick()-events[0].getTick(); noteLength = (long)(noteLength * totalTupletLength / tuplet.countNotes()); for (int i=0; i<(events.length-1)/2-1; i++) { events[i].setTick(elapsedTime); events[2*i+1].setTick(elapsedTime+noteLength); } }*/ } return events ; }
Returns the corresponding midi events for a tuplet .