Return a vector containing all the notes from all Notes that are playing at tick in MIDI. - Java javax.sound.midi

Java examples for javax.sound.midi:MidiSystem

Description

Return a vector containing all the notes from all Notes that are playing at tick in MIDI.

Demo Code


import javax.sound.midi.ShortMessage;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.MidiEvent;
import javax.sound.midi.Sequencer;
import javax.sound.midi.Track;
import javax.sound.midi.Sequence;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MetaMessage;
import java.util.Vector;

public class Main{
    /**/*ww  w  .j  av  a 2 s  .c  o  m*/
     * Return a vector containing all the notes from allNotes that are playing at tick.
     */
    public static Vector<Note> getNotesPlayingAtTick(Vector<Note> allNotes,
            long tick) {
        Vector<Note> playingNotes = new Vector<Note>();

        for (Note n : allNotes) {
            if (tick >= n.getStartTick() && tick < n.getEndTick()) {
                playingNotes.add(n);
            }
        }

        return playingNotes;
    }
}

Related Tutorials