This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.sound.midi
class Sequence

java.lang.Object extended by javax.sound.midi.Sequence

Most common way to construct:

File myMidiFile = …;

Sequence mySeq = MidiSystem.getSequence(myMidiFile);

Based on 26 examples


public class Sequence
extends Object

A Sequence is a data structure containing musical information (often an entire song or composition) that can be played back by a {@link Sequencer} object. Specifically, the Sequence contains timing information and one or more tracks. Each {@link Track 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 {@link MidiSystem}. A sequence can also be built from scratch by adding new Tracks to an empty Sequence, and adding {@link MidiEvent} objects to these Tracks.


Field Summary
protected float divisionType
          The timing division type of the sequence.
static 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 float SMPTE_24
          The SMPTE-based timing type with 24 frames per second (resolution is expressed in ticks per frame).
static float SMPTE_25
          The SMPTE-based timing type with 25 frames per second (resolution is expressed in ticks per frame).
static float SMPTE_30
          The SMPTE-based timing type with 30 frames per second (resolution is expressed in ticks per frame).
static float SMPTE_30DROP
          The SMPTE-based timing type with 29.97 frames per second (resolution is expressed in ticks per frame).
protected Vector tracks
          The MIDI tracks in this sequence.
 
Constructor Summary
Sequence(float divisionType, int resolution)

          Constructs a new MIDI sequence with the specified timing division type and timing resolution.
Sequence(float divisionType, int resolution, int numTracks)

          Constructs a new MIDI sequence with the specified timing division type, timing resolution, and number of tracks.
 
Method Summary
 Track

          Creates a new, initially empty track as part of this sequence.
 boolean

          Removes the specified track from the sequence.
 float

          Obtains the timing division type for this sequence.
 long

          Obtains the duration of this sequence, expressed in microseconds.
 Patch[]

          Obtains a list of patches referenced in this sequence.
 int

          Obtains the timing resolution for this sequence.
 long

          Obtains the duration of this sequence, expressed in MIDI ticks.
 Track[]

          Obtains an array containing all the tracks in this sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

divisionType

protected float divisionType
The timing division type of the sequence.

PPQ

public static final float PPQ
The tempo-based timing type, for which the resolution is expressed in pulses (ticks) per quarter note.

resolution

protected int resolution
The timing resolution of the sequence.

SMPTE_24

public static final float SMPTE_24
The SMPTE-based timing type with 24 frames per second (resolution is expressed in ticks per frame).

SMPTE_25

public static final float SMPTE_25
The SMPTE-based timing type with 25 frames per second (resolution is expressed in ticks per frame).

SMPTE_30

public static final float SMPTE_30
The SMPTE-based timing type with 30 frames per second (resolution is expressed in ticks per frame).

SMPTE_30DROP

public static final float SMPTE_30DROP
The SMPTE-based timing type with 29.97 frames per second (resolution is expressed in ticks per frame).

tracks

protected Vector tracks
The MIDI tracks in this sequence.
Constructor Detail

Sequence

public Sequence(float divisionType,
                int resolution)
         throws InvalidMidiDataException
Constructs a new MIDI sequence with the specified timing division type and timing resolution. The division type must be one of the recognized MIDI timing types. For tempo-based timing, 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 {@link #createTrack} and {@link #deleteTrack}.

Parameters:
divisionType - the timing division type (PPQ or one of the SMPTE types)
resolution - the timing resolution
Throws:
InvalidMidiDataException - if divisionType is not valid

Sequence

public Sequence(float divisionType,
                int resolution,
                int numTracks)
         throws InvalidMidiDataException
Constructs a new MIDI sequence with the specified timing division type, timing resolution, and number of tracks. The division type must be one of the recognized MIDI timing types. For tempo-based timing, 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 {@link #getTracks} method. Additional tracks may be added, or existing tracks removed, using {@link #createTrack} and {@link #deleteTrack}.

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 - if divisionType is not valid
Method Detail

createTrack

public Track createTrack()
Creates a new, initially empty track as part of this sequence. The track initially contains the meta-event End of Track. The newly created track is returned. All tracks in the sequence may be retrieved using {@link #getTracks}. Tracks may be removed from the sequence using {@link #deleteTrack}.

Returns:
the newly created track

deleteTrack

public boolean deleteTrack(Track track)
Removes the specified track from the sequence.

Parameters:
track - the track to remove
Returns:
true if the track existed in the track and was removed, otherwise false.

getDivisionType

public float getDivisionType()
Obtains the timing division type for this sequence.

Returns:
the division type (PPQ or one of the SMPTE types)

getMicrosecondLength

public long getMicrosecondLength()
Obtains the duration of this sequence, expressed in microseconds.

Returns:
this sequence's duration in microseconds.

getPatchList

public Patch[] getPatchList()
Obtains a list of patches referenced in this sequence. This patch list may be used to load the required {@link Instrument} objects into a {@link Synthesizer}.

Returns:
an array of {@link Patch} objects used in this sequence

getResolution

public int getResolution()
Obtains the timing resolution for this sequence. If the sequence's division type is PPQ, the resolution is specified in ticks per beat. For SMTPE timing, the resolution is specified in ticks per frame.

Returns:
the number of ticks per beat (PPQ) or per frame (SMPTE)

getTickLength

public long getTickLength()
Obtains the duration of this sequence, expressed in MIDI ticks.

Returns:
this sequence's length in ticks

getTracks

public Track[] getTracks()
Obtains an array containing all the tracks in this sequence. If the sequence contains no tracks, an array of length 0 is returned.

Returns:
the array of tracks


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.