public class Track extends Object
Track occupies a middle level in the hierarchy of data played by a
Sequencer: sequencers play sequences, which contain tracks, which
contain MIDI events. A sequencer may provide controls that mute or solo
The timing information and resolution for a track is controlled by and stored
in the sequence containing the track. A given
Track is considered to
belong to the particular
Sequence that maintains its timing. For this
reason, a new (empty) track is created by calling the
Sequence.createTrack() method, rather than by directly invoking a
Track class provides methods to edit the track by adding or
MidiEvent objects from it. These operations keep the event
list in the correct time order. Methods are also included to obtain the
track's size, in terms of either the number of events it contains or its
duration in ticks.
Modifier and Type Method Description
MidiEvent event)(Adds a new event to the track.
(int index)Obtains the event at the specified index.
MidiEvent event)(Removes the specified event from the track.
()Obtains the number of events in this track.
()Obtains the length of the track, expressed in MIDI ticks.
addpublic boolean add(MidiEvent event)Adds a new event to the track. However, if the event is already contained in the track, it is not added again. The list of events is kept in time order, meaning that this event inserted at the appropriate place in the list, not necessarily at the end.
event- the event to add
trueif the event did not already exist in the track and was added, otherwise
removepublic boolean remove(MidiEvent event)Removes the specified event from the track.
event- the event to remove
trueif the event existed in the track and was removed, otherwise
getObtains the event at the specified index.
sizepublic int size()Obtains the number of events in this track.
- the size of the track's event vector
tickspublic long ticks()Obtains the length of the track, expressed in MIDI ticks. (The duration of a tick in seconds is determined by the timing resolution of the
Sequencecontaining this track, and also by the tempo of the music as set by the sequencer.)