javax.sound.midi

Interface Sequencer

public interface Sequencer extends MidiDevice

A Sequencer object plays MIDI sequences described as Sequence objects. This class provides methods for loading and unloading sequences, as well as basic transport controls.

Since: 1.3

Nested Class Summary
static classSequencer.SyncMode
A SyncMode object represents the mechanism by which a MIDI sequencer synchronizes time with a master or slave device.
Method Summary
int[]addControllerEventListener(ControllerEventListener listener, int[] controllers)
Add a controller event listening object to this sequencer.
booleanaddMetaEventListener(MetaEventListener listener)
Add a meta event listening object to this sequencer.
Sequencer.SyncModegetMasterSyncMode()
Get the source of timing information.
Sequencer.SyncMode[]getMasterSyncModes()
Get an array of timing sources supported by this sequencer.
longgetMicrosecondLength()
Get the length of the current sequence in microseconds.
longgetMicrosecondPosition()
Get the current playback position of the sequencer in microseconds.
SequencegetSequence()
Get the current sequence object for this sequencer.
Sequencer.SyncModegetSlaveSyncMode()
Get the current slave synchronization mode.
Sequencer.SyncMode[]getSlaveSyncModes()
Get an array of slave sync modes supported by this sequencer.
floatgetTempoFactor()
Get the current scaling factor for the playback tempo.
floatgetTempoInBPM()
Get the current tempo in beats per minute.
floatgetTempoInMPQ()
Get the current tempo in microseconds per quarter note.
longgetTickLength()
Get the length of the current sequence in MIDI ticks.
longgetTickPosition()
Get the current playback position of the sequencer in MIDI ticks.
booleangetTrackMute(int track)
Get the mute state of a specific track.
booleangetTrackSolo(int track)
Get the solo state for a specific track.
booleanisRecording()
Returns true if sequence is recording.
booleanisRunning()
Returns true if the sequence is playing.
voidrecordDisable(Track track)
Disable recording for a specific track.
voidrecordEnable(Track track, int channel)
Enable recording for a specific track using data from a specific channel.
int[]removeControllerEventListener(ControllerEventListener listener, int[] controllers)
Remove a controller listener from this sequencer for the specified controller numbers.
voidremoveMetaEventListener(MetaEventListener listener)
Remove a meta event listener from this sequencer.
voidsetMasterSyncMode(Sequencer.SyncMode sync)
Set the source of timing information. sync must be found in the array returned by getMasterSyncModes().
voidsetMicrosecondPosition(long microsecond)
Set the current playback position of the sequencer in microseconds.
voidsetSequence(Sequence seq)
Set the Sequence object for this sequencer.
voidsetSequence(InputStream istream)
Set the sequence for this sequencer. istream reads on a valid MIDI file.
voidsetSlaveSyncMode(Sequencer.SyncMode sync)
Set the slave synchronization mode for this sequencer. sync must be found in the array returned by getSlaveSyncModes().
voidsetTempoFactor(float factor)
Set a scaling factor for the playback tempo, which is 1.0 by default.
voidsetTempoInBPM(float bpm)
Sets the current tempo in beats per minute.
voidsetTempoInMPQ(float mpq)
Sets the current tempo in microseconds per quarter note.
voidsetTickPosition(long tick)
Set the current playback position of the sequencer in MIDI ticks.
voidsetTrackMute(int track, boolean mute)
Sets the mute state for a specific track.
voidsetTrackSolo(int track, boolean solo)
Sets the solo state for a specific track.
voidstart()
Start playback of the current sequence.
voidstartRecording()
Start playback and record of MIDI events.
voidstop()
Stop playback of the current sequence.
voidstopRecording()
Stop recording, although continue playing.

Method Detail

addControllerEventListener

public int[] addControllerEventListener(ControllerEventListener listener, int[] controllers)
Add a controller event listening object to this sequencer. It will receive notification whenever the sequencer processes a controller event for a specified controller number..

Parameters: listener the listener to add controllers the conroller numbers to listen to

Returns: the controller numbers being listened to

addMetaEventListener

public boolean addMetaEventListener(MetaEventListener listener)
Add a meta event listening object to this sequencer. It will receive notification whenever the sequencer processes a meta event. A listener may fail to get added if this sequencer doesn't support meta events.

Parameters: listener the listener to add

Returns: true if listener was added, false othewise

getMasterSyncMode

public Sequencer.SyncMode getMasterSyncMode()
Get the source of timing information.

Returns: the current source of timing information

getMasterSyncModes

public Sequencer.SyncMode[] getMasterSyncModes()
Get an array of timing sources supported by this sequencer.

Returns: an array of timing sources supported by this sequencer

getMicrosecondLength

public long getMicrosecondLength()
Get the length of the current sequence in microseconds.

Returns: the length of the current sequence in microseconds

getMicrosecondPosition

public long getMicrosecondPosition()
Get the current playback position of the sequencer in microseconds.

Returns: the current playback position of the sequencer in microseconds

getSequence

public Sequence getSequence()
Get the current sequence object for this sequencer.

Returns: the current sequence object. May be null.

getSlaveSyncMode

public Sequencer.SyncMode getSlaveSyncMode()
Get the current slave synchronization mode.

Returns: the current slave synchronization mode

getSlaveSyncModes

public Sequencer.SyncMode[] getSlaveSyncModes()
Get an array of slave sync modes supported by this sequencer.

Returns: an array of slave sync modes supported by this sequencer

getTempoFactor

public float getTempoFactor()
Get the current scaling factor for the playback tempo.

Returns: the current tempo scaling factor

getTempoInBPM

public float getTempoInBPM()
Get the current tempo in beats per minute.

Returns: the current tempo in beats per minute

getTempoInMPQ

public float getTempoInMPQ()
Get the current tempo in microseconds per quarter note.

Returns: the current tempo in microseconds per quarter note.

getTickLength

public long getTickLength()
Get the length of the current sequence in MIDI ticks.

Returns: the length of the current sequence in MIDI ticks

getTickPosition

public long getTickPosition()
Get the current playback position of the sequencer in MIDI ticks.

Returns: the current playback position of the sequencer in MIDI ticks

getTrackMute

public boolean getTrackMute(int track)
Get the mute state of a specific track.

Parameters: track the track to query

Returns: the mute state for track

getTrackSolo

public boolean getTrackSolo(int track)
Get the solo state for a specific track.

Parameters: track the track to query

Returns: the solo state for track

isRecording

public boolean isRecording()
Returns true if sequence is recording.

Returns: true if the sequence is recording and false otherwise

isRunning

public boolean isRunning()
Returns true if the sequence is playing.

Returns: true if the sequence is playing and false otherwise

recordDisable

public void recordDisable(Track track)
Disable recording for a specific track.

Parameters: track the track to disable recording for

recordEnable

public void recordEnable(Track track, int channel)
Enable recording for a specific track using data from a specific channel.

Parameters: track the track to enable for recording channel the channel from which to record

removeControllerEventListener

public int[] removeControllerEventListener(ControllerEventListener listener, int[] controllers)
Remove a controller listener from this sequencer for the specified controller numbers.

Parameters: listener the listener to remove controllers the controllers to unlisten

Returns: the controller numbers being unlistened

removeMetaEventListener

public void removeMetaEventListener(MetaEventListener listener)
Remove a meta event listener from this sequencer.

Parameters: listener the listener to remove

setMasterSyncMode

public void setMasterSyncMode(Sequencer.SyncMode sync)
Set the source of timing information. sync must be found in the array returned by getMasterSyncModes(). FIXME: What happens if it isn't?

Parameters: sync the new source of timing information

setMicrosecondPosition

public void setMicrosecondPosition(long microsecond)
Set the current playback position of the sequencer in microseconds.

Parameters: microsecond the new playback position of the sequencer in microseconds

setSequence

public void setSequence(Sequence seq)
Set the Sequence object for this sequencer.

Parameters: seq the Sequence to process

Throws: InvalidMidiDataException if the sequence is invalid for any reason

setSequence

public void setSequence(InputStream istream)
Set the sequence for this sequencer. istream reads on a valid MIDI file.

Parameters: istream an input stream for a valid MIDI file

Throws: IOException if an I/O exception happens InvalidMidiDataException if the MIDI file contains bad data

setSlaveSyncMode

public void setSlaveSyncMode(Sequencer.SyncMode sync)
Set the slave synchronization mode for this sequencer. sync must be found in the array returned by getSlaveSyncModes(). FIXME: What happens if it isn't?

Parameters: sync the new slave sync mode for this sequencer

setTempoFactor

public void setTempoFactor(float factor)
Set a scaling factor for the playback tempo, which is 1.0 by default.

Parameters: factor the new tempo scaling factor

setTempoInBPM

public void setTempoInBPM(float bpm)
Sets the current tempo in beats per minute.

Parameters: bpm the new tempo in bears per minutes

setTempoInMPQ

public void setTempoInMPQ(float mpq)
Sets the current tempo in microseconds per quarter note.

Parameters: mpq the new tempo in microseconds per quarter note.

setTickPosition

public void setTickPosition(long tick)
Set the current playback position of the sequencer in MIDI ticks.

Parameters: tick the new playback position of the sequencer in MIDI ticks

setTrackMute

public void setTrackMute(int track, boolean mute)
Sets the mute state for a specific track.

Parameters: track the track to modify mute the new mute state

setTrackSolo

public void setTrackSolo(int track, boolean solo)
Sets the solo state for a specific track.

Parameters: track the track to modify solo the new solo state

start

public void start()
Start playback of the current sequence.

startRecording

public void startRecording()
Start playback and record of MIDI events. Any tracks enabled for recording will have their events replaced. Any newly recorded events, and all events from non-recording tracks will be sent to the sequencer's transmitter.

stop

public void stop()
Stop playback of the current sequence.

stopRecording

public void stopRecording()
Stop recording, although continue playing.