- java.lang.Object
-
- javax.sound.midi.Track
-
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.A
Track
occupies a middle level in the hierarchy of data played by a
: sequencers play sequences, which contain tracks, which contain MIDI events. A sequencer may provide controls that mute or solo individual tracks.Sequencer
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
that maintains its timing. For this reason, a new (empty) track is created by calling theSequence
method, rather than by directly invoking aSequence.createTrack()
Track
constructor.The
Track
class provides methods to edit the track by adding or removingMidiEvent
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.
-
-
Method Summary
Methods Modifier and Type Method and Description boolean
add(MidiEvent event)
Adds a new event to the track.MidiEvent
get(int index)
Obtains the event at the specified index.boolean
remove(MidiEvent event)
Removes the specified event from the track.int
size()
Obtains the number of events in this track.long
ticks()
Obtains the length of the track, expressed in MIDI ticks.
-
-
-
Method Detail
-
add
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.- Parameters:
event
- the event to add- Returns:
true
if the event did not already exist in the track and was added, otherwisefalse
-
remove
public boolean remove(MidiEvent event)
Removes the specified event from the track.- Parameters:
event
- the event to remove- Returns:
true
if the event existed in the track and was removed, otherwisefalse
-
get
public MidiEvent get(int index) throws ArrayIndexOutOfBoundsException
Obtains the event at the specified index.- Parameters:
index
- the location of the desired event in the event vector- Throws:
- if the specified index is negative or not less than the current size of this track.ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsException
- See Also:
size()
-
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 theSequence
containing this track, and also by the tempo of the music as set by the sequencer.)- Returns:
- the duration, in ticks
- See Also:
Sequence.Sequence(float, int)
,Sequencer.setTempoInBPM(float)
,Sequencer.getTickPosition()
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
05/11/2024 17:45:24 Cette version de la page est en cache (à la date du 05/11/2024 17:45:24) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 29/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/sound/midi/Track.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.