Class Sequence
public class Sequence extends Object
Sequence
is a data structure containing musical information (often an entire song or composition) that can be played back by a Sequencer
object. Specifically, the Sequence
contains timing information and one or more tracks. Each track
consists of a series of MIDI events (such as note-ons, note-offs, program changes, and meta-events). The sequence's timing information specifies the type of unit that is used to time-stamp the events in the sequence. A Sequence
can be created from a MIDI file by reading the file into an input stream and invoking one of the getSequence
methods of MidiSystem
. A sequence can also be built from scratch by adding new Tracks
to an empty Sequence
, and adding MidiEvent
objects to these Tracks
.
Field Summary
Modifier and Type | Field | Description |
---|---|---|
protected float |
divisionType |
The timing division type of the sequence. |
static final float |
PPQ |
The tempo-based timing type, for which the resolution is expressed in pulses (ticks) per quarter note. |
protected int |
resolution |
The timing resolution of the sequence. |
static final float |
SMPTE_24 |
The SMPTE-based timing type with 24 frames per second (resolution is expressed in ticks per frame). |
static final float |
SMPTE_25 |
The SMPTE-based timing type with 25 frames per second (resolution is expressed in ticks per frame). |
static final float |
SMPTE_30 |
The SMPTE-based timing type with 30 frames per second (resolution is expressed in ticks per frame). |
static final float |
SMPTE_30DROP |
The SMPTE-based timing type with 29.97 frames per second (resolution is expressed in ticks per frame). |
protected Vector<Track> |
tracks |
The MIDI tracks in this sequence. |
Constructor Summary
Constructor | Description |
---|---|
Sequence |
Constructs a new MIDI sequence with the specified timing division type and timing resolution. |
Sequence |
Constructs a new MIDI sequence with the specified timing division type, timing resolution, and number of tracks. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
Track |
createTrack() |
Creates a new, initially empty track as part of this sequence. |
boolean |
deleteTrack |
Removes the specified track from the sequence. |
float |
getDivisionType() |
Obtains the timing division type for this sequence. |
long |
getMicrosecondLength() |
Obtains the duration of this sequence, expressed in microseconds. |
Patch[] |
getPatchList() |
Obtains a list of patches referenced in this sequence. |
int |
getResolution() |
Obtains the timing resolution for this sequence. |
long |
getTickLength() |
Obtains the duration of this sequence, expressed in MIDI ticks. |
Track[] |
getTracks() |
Obtains an array containing all the tracks in this sequence. |
Field Details
PPQ
public static final float PPQ
- See Also:
SMPTE_24
public static final float SMPTE_24
- See Also:
SMPTE_25
public static final float SMPTE_25
- See Also:
SMPTE_30DROP
public static final float SMPTE_30DROP
- See Also:
SMPTE_30
public static final float SMPTE_30
- See Also:
divisionType
protected float divisionType
- See Also:
resolution
protected int resolution
- See Also:
tracks
protected Vector<Track> tracks
- See Also:
Constructor Details
Sequence
public Sequence(float divisionType, int resolution) throws InvalidMidiDataException
divisionType
is PPQ (pulses per quarter note) and the resolution is specified in ticks per beat. For SMTPE timing, divisionType
specifies the number of frames per second and the resolution is specified in ticks per frame. The sequence will contain no initial tracks. Tracks may be added to or removed from the sequence using createTrack()
and deleteTrack(javax.sound.midi.Track)
.- Parameters:
-
divisionType
- the timing division type (PPQ or one of the SMPTE types) -
resolution
- the timing resolution - Throws:
-
InvalidMidiDataException
- ifdivisionType
is not valid - See Also:
Sequence
public Sequence(float divisionType, int resolution, int numTracks) throws InvalidMidiDataException
divisionType
is PPQ (pulses per quarter note) and the resolution is specified in ticks per beat. For SMTPE timing, divisionType
specifies the number of frames per second and the resolution is specified in ticks per frame. The sequence will be initialized with the number of tracks specified by numTracks
. These tracks are initially empty (i.e. they contain only the meta-event End of Track). The tracks may be retrieved for editing using the getTracks()
method. Additional tracks may be added, or existing tracks removed, using createTrack()
and deleteTrack(javax.sound.midi.Track)
.- Parameters:
-
divisionType
- the timing division type (PPQ or one of the SMPTE types) -
resolution
- the timing resolution -
numTracks
- the initial number of tracks in the sequence - Throws:
-
InvalidMidiDataException
- ifdivisionType
is not valid - See Also:
Method Details
getDivisionType
public float getDivisionType()
- Returns:
- the division type (PPQ or one of the SMPTE types)
- See Also:
getResolution
public int getResolution()
- Returns:
- the number of ticks per beat (PPQ) or per frame (SMPTE)
- See Also:
createTrack
public Track createTrack()
getTracks()
. Tracks may be removed from the sequence using deleteTrack(javax.sound.midi.Track)
.- Returns:
- the newly created track
deleteTrack
public boolean deleteTrack(Track track)
- Parameters:
-
track
- the track to remove - Returns:
-
true
if the track existed in the track and was removed, otherwisefalse
- See Also:
getTracks
public Track[] getTracks()
- Returns:
- the array of tracks
- See Also:
getMicrosecondLength
public long getMicrosecondLength()
- Returns:
- this sequence's duration in microseconds
getTickLength
public long getTickLength()
- Returns:
- this sequence's length in ticks
- See Also:
getPatchList
public Patch[] getPatchList()
Instrument
objects into a Synthesizer
.- Returns:
- an array of
Patch
objects used in this sequence - See Also:
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/sound/midi/Sequence.html