JavaTM 2 Platform Std. Ed. v1.5.0
public class Track
- extends Object
A MIDI track is an independent stream of MIDI events (time-stamped MIDI
data) that can be stored along with other tracks in a standard MIDI file.
The MIDI specification allows only 16 channels of MIDI data, but tracks
are a way to get around this limitation. A MIDI file can contain any number
of tracks, each containing its own stream of up to 16 channels of MIDI data.
Track occupies a middle level in the hierarchy of data played
: sequencers play sequences, which contain tracks,
which contain MIDI events. A sequencer may provide controls that mute
or solo individual tracks.
The timing information and resolution for a track is controlled by and stored
in the sequence containing the track. A given
is considered to belong to the particular
maintains its timing. For this reason, a new (empty) track is created by calling the
method, rather than by directly invoking a
Track class provides methods to edit the track by adding
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.
- See Also:
Adds a new event to the track.
Obtains the event at the specified index.
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.
|Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public 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
true if the event did not already exist in the
track and was added, otherwise
public boolean remove(MidiEvent event)
- Removes the specified event from the track.
event - the event to remove
true if the event existed in the track and was removed,
public MidiEvent get(int index)
- Obtains the event at the specified index.
index - the location of the desired event in the event vector
- if the
specified index is negative or not less than the current size of
- See Also:
public int size()
- Obtains the number of events in this track.
- the size of the track's event vector
public 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
Sequence containing this track, and also by
the tempo of the music as set by the sequencer.)
- the duration, in ticks
- See Also:
Copyright 2003 Sun Microsystems, Inc. All rights reserved