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.
Sequencer#setTrackMute, Sequencer#setTrackSolo
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final MidiEvent | |
| private final ArrayList | eventsList
The list containing the events. |
| private final HashSet | set
Use a hashset to detect duplicate events in add(MidiEvent). |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public MidiEvent | Returns: the event at the specified indexthe location of the desired event in the event vector index)Obtains the event at the specified index. |
| public boolean | |
| public int | |
| public long |
| eotEvent | back to summary |
|---|---|
| private final MidiEvent eotEvent | |
| eventsList | back to summary |
|---|---|
| private final ArrayList<MidiEvent> eventsList The list containing the events. | |
| set | back to summary |
|---|---|
| private final HashSet<MidiEvent> set Use a hashset to detect duplicate events in add(MidiEvent). | |
| Track | back to summary |
|---|---|
| pack-priv Track() Package-private constructor. Constructs a new, empty Track object, which initially contains one event, the meta-event End of Track. | |
| add | back to summary |
|---|---|
| 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.
| |
| get | back to summary |
|---|---|
| public MidiEvent get(int index) throws ArrayIndexOutOfBoundsException Obtains the event at the specified index.
| |
| remove | back to summary |
|---|---|
| public boolean remove(MidiEvent event) Removes the specified event from the track.
| |
| size | back to summary |
|---|---|
| public int size() Obtains the number of events in this track.
| |
| ticks | back to summary |
|---|---|
| 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 the
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | setMessage(int type, byte[] data, int length)
Overrides javax. Sets the message parameters for a |
| ImmutableEndOfTrack | back to summary |
|---|---|
| private ImmutableEndOfTrack() | |
| setMessage | back to summary |
|---|---|
| public void setMessage(int type, byte[] data, int length) throws InvalidMidiDataException Overrides javax. Doc from javax. Sets the message parameters for a
The
| |