Class Track
A 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
individual tracks.
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 constructor.
The Track class provides methods to edit the track by adding or
removing 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:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a new event to the track.get(int index) Obtains the event at the specified index.booleanRemoves the specified event from the track.intsize()Obtains the number of events in this track.longticks()Obtains the length of the track, expressed in MIDI ticks.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Method Details
-
add
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.- Parameters:
event- the event to add- Returns:
trueif the event did not already exist in the track and was added, otherwisefalse
-
remove
Removes the specified event from the track.- Parameters:
event- the event to remove- Returns:
trueif the event existed in the track and was removed, otherwisefalse
-
get
Obtains the event at the specified index.- Parameters:
index- the location of the desired event in the event vector- Returns:
- the event at the specified index
- Throws:
ArrayIndexOutOfBoundsException- if the specified index is negative or not less than the current size of this track- See Also:
-
size
public int size()Obtains the number of events in this track.- Returns:
- the size of the track's event vector
-
ticks
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 of theSequencecontaining this track, and also by the tempo of the music as set by the sequencer.)- Returns:
- the duration, in ticks
- See Also:
-