sequence is known as a sequencer. A MIDI sequence
contains lists of time-stamped MIDI data, such as might be read from a
standard MIDI file. Most sequencers also provide functions for creating and
editing sequences.
The Sequencer interface includes methods for the following basic MIDI
sequencer operations:
Sequencer has access to:
SyncMode, addMetaEventListener, ControllerEventListener, Receiver, Transmitter, MidiDevice
| Modifier and Type | Class and Description |
|---|---|
| public static class | Sequencer.
A |
| Modifier and Type | Field and Description |
|---|---|
| public static final int | LOOP_CONTINUOUSLY
A value indicating that looping should continue indefinitely rather than complete after a specific number of loops. |
| Modifier and Type | Method and Description |
|---|---|
| public int[] | Returns: the numbers of all the MIDI controllers whose changes will now be reported to the specified listenerthe controller event listener to add to the list of
registered listeners listener, int[] the MIDI controller numbers for which change
notification is requested controllers)Registers a controller event listener to receive notification whenever the sequencer processes a control-change event of the requested type or types. |
| public boolean | Returns: true if the listener was successfully added, otherwise
falselistener to add listener)Registers a meta-event listener to receive notification whenever a meta-event is encountered in the sequence and processed by the sequencer. |
| public int | Returns: the number of loops after which playback plays to the end of the sequenceObtains the number of repetitions for playback. |
| public long | Returns: the end position of the loop, in MIDI ticks (zero-based), or -1 to indicate the end of the sequenceObtains the end position of the loop, in MIDI ticks. |
| public long | Returns: the start position of the loop, in MIDI ticks (zero-based)Obtains the start position of the loop, in MIDI ticks. |
| public Sequencer. | Returns: the current master synchronization modeObtains the current master synchronization mode for this sequencer. |
| public Sequencer. | Returns: the available master synchronization modesObtains the set of master synchronization modes supported by this sequencer. |
| public long | Returns: length of the sequence in microsecondsObtains the length of the current sequence, expressed in microseconds, or 0 if no sequence is set. |
| public long | Returns: the current position in microsecondsRedeclares javax. Obtains the current position in the sequence, expressed in microseconds. |
| public Sequence | Returns: the current sequence, ornull if no sequence is currently
setObtains the sequence on which the Sequencer is currently operating. |
| public Sequencer. | Returns: the current slave synchronization modeObtains the current slave synchronization mode for this sequencer. |
| public Sequencer. | Returns: the available slave synchronization modesObtains the set of slave synchronization modes supported by the sequencer. |
| public float | |
| public float | Returns: the current tempo in beats per minuteObtains the current tempo, expressed in beats per minute. |
| public float | Returns: the current tempo in microseconds per quarter noteObtains the current tempo, expressed in microseconds per quarter note. |
| public long | Returns: length of the sequence in ticksObtains the length of the current sequence, expressed in MIDI ticks, or 0 if no sequence is set. |
| public long | Returns: current tickObtains the current position in the sequence, expressed in MIDI ticks. |
| public boolean | Returns: true if muted, false if notthe track number. Tracks in the current sequence are
numbered from 0 to the number of tracks in the sequence minus 1. track)Obtains the current mute state for a track. |
| public boolean | Returns: true if solo'd, false if notthe track number. Tracks in the current sequence are
numbered from 0 to the number of tracks in the sequence minus 1. track)Obtains the current solo state for a track. |
| public boolean | Returns: true if the Sequencer is recording, otherwise
falseIndicates whether the Sequencer is currently recording. |
| public boolean | Returns: true if the Sequencer is running, otherwise falseIndicates whether the Sequencer is currently running. |
| public void | recordDisable(Track
the track to disable for recording, or track)null to
disable recording for all tracksDisables recording to the specified track. |
| public void | recordEnable(Track
the track to which events will be recorded track, int the channel on which events will be received. If -1 is
specified for the channel value, the track will receive data from
all channels. channel)Prepares the specified track for recording events received on a particular channel. |
| public int[] | Returns: the numbers of all the MIDI controllers whose changes will now be reported to the specified listenerold listener listener, int[] the MIDI controller numbers for which change
notification should be cancelled, or controllers)null to cancel for
all controllersRemoves a controller event listener's interest in one or more types of controller event. |
| public void | removeMetaEventListener(MetaEventListener
the meta-event listener to remove listener)Removes the specified meta-event listener from this sequencer's list of registered listeners, if in fact the listener is registered. |
| public void | setLoopCount(int
the number of times playback should loop back from the
loop's end position to the loop's start position, or
count)LOOP_CONTINUOUSLY to indicate that looping should
continue until interruptedSets the number of repetitions of the loop for playback. |
| public void | setLoopEndPoint(long
the loop's ending position, in MIDI ticks (zero-based), or
-1 to indicate the final tick tick)Sets the last MIDI tick that will be played in the loop. |
| public void | setLoopStartPoint(long
the loop's starting position, in MIDI ticks (zero-based) tick)Sets the first MIDI tick that will be played in the loop. |
| public void | setMasterSyncMode(Sequencer.
the desired master synchronization mode syncSets the source of timing information used by this sequencer. |
| public void | setMicrosecondPosition(long
desired position in microseconds microseconds)Sets the current position in the sequence, expressed in microseconds. |
| public void | setSequence(Sequence
the sequence to be loaded sequence)Sets the current sequence on which the sequencer operates. |
| public void | setSequence(InputStream
stream containing MIDI file data stream)Sets the current sequence on which the sequencer operates. |
| public void | setSlaveSyncMode(Sequencer.
the desired slave synchronization mode syncSets the slave synchronization mode for the sequencer. |
| public void | setTempoFactor(float
the requested tempo scalar factor)Scales the sequencer's actual playback tempo by the factor provided. |
| public void | |
| public void | setTempoInMPQ(float
desired new tempo in microseconds per quarter note mpq)Sets the tempo in microseconds per quarter note. |
| public void | setTickPosition(long
the desired tick position tick)Sets the current sequencer position in MIDI ticks. |
| public void | setTrackMute(int
the track number. Tracks in the current sequence are
numbered from 0 to the number of tracks in the sequence minus 1. track, boolean the new mute state for the track. mute)true implies the
track should be muted, false implies the track should be
unmuted.Sets the mute state for a track. |
| public void | setTrackSolo(int
the track number. Tracks in the current sequence are
numbered from 0 to the number of tracks in the sequence minus 1. track, boolean the new solo state for the track. solo)true implies the
track should be solo'd, false implies the track should
not be solo'd.Sets the solo state for a track. |
| public void | |
| public void | |
| public void | |
| public void |
| LOOP_CONTINUOUSLY | back to summary |
|---|---|
| public static final int LOOP_CONTINUOUSLY A value indicating that looping should continue indefinitely rather than complete after a specific number of loops.
| |
| addControllerEventListener | back to summary |
|---|---|
| public int[] addControllerEventListener(ControllerEventListener listener, int[] controllers) Registers a controller event listener to receive notification whenever
the sequencer processes a control-change event of the requested type or
types. The types are specified by the The returned array contains the MIDI controller numbers for which the listener will now receive events. Some sequencers might not support controller event notification, in which case the array has a length of 0. Other sequencers might support notification for some controllers but not all. This method may be invoked repeatedly. Each time, the returned array indicates all the controllers that the listener will be notified about, not only the controllers requested in that particular invocation.
| |
| addMetaEventListener | back to summary |
|---|---|
| public boolean addMetaEventListener(MetaEventListener listener) Registers a meta-event listener to receive notification whenever a meta-event is encountered in the sequence and processed by the sequencer. This method can fail if, for instance, this class of sequencer does not support meta-event notification.
| |
| getLoopCount | back to summary |
|---|---|
| public int getLoopCount() Obtains the number of repetitions for playback.
| |
| getLoopEndPoint | back to summary |
|---|---|
| public long getLoopEndPoint() Obtains the end position of the loop, in MIDI ticks.
| |
| getLoopStartPoint | back to summary |
|---|---|
| public long getLoopStartPoint() Obtains the start position of the loop, in MIDI ticks.
| |
| getMasterSyncMode | back to summary |
|---|---|
| public Sequencer. Obtains the current master synchronization mode for this sequencer.
| |
| getMasterSyncModes | back to summary |
|---|---|
| public Sequencer. Obtains the set of master synchronization modes supported by this sequencer.
| |
| getMicrosecondLength | back to summary |
|---|---|
| public long getMicrosecondLength() Obtains the length of the current sequence, expressed in microseconds, or 0 if no sequence is set.
| |
| getMicrosecondPosition | back to summary |
|---|---|
| public long getMicrosecondPosition() Redeclares javax. Obtains the current position in the sequence, expressed in microseconds.
| |
| getSequence | back to summary |
|---|---|
| public Sequence getSequence() Obtains the sequence on which the Sequencer is currently operating.
This method can be called even if the
| |
| getSlaveSyncMode | back to summary |
|---|---|
| public Sequencer. Obtains the current slave synchronization mode for this sequencer.
| |
| getSlaveSyncModes | back to summary |
|---|---|
| public Sequencer. Obtains the set of slave synchronization modes supported by the sequencer.
| |
| getTempoFactor | back to summary |
|---|---|
| public float getTempoFactor() Returns the current tempo factor for the sequencer. The default is 1.0.
| |
| getTempoInBPM | back to summary |
|---|---|
| public float getTempoInBPM() Obtains the current tempo, expressed in beats per minute. The actual tempo of playback is the product of the returned value and the tempo factor.
| |
| getTempoInMPQ | back to summary |
|---|---|
| public float getTempoInMPQ() Obtains the current tempo, expressed in microseconds per quarter note. The actual tempo of playback is the product of the returned value and the tempo factor.
| |
| getTickLength | back to summary |
|---|---|
| public long getTickLength() Obtains the length of the current sequence, expressed in MIDI ticks, or 0 if no sequence is set.
| |
| getTickPosition | back to summary |
|---|---|
| public long getTickPosition() Obtains the current position in the sequence, expressed in MIDI ticks.
(The duration of a tick in seconds is determined both by the tempo and by
the timing resolution stored in the
| |
| getTrackMute | back to summary |
|---|---|
| public boolean getTrackMute(int track) Obtains the current mute state for a track. The default mute state for all tracks which have not been muted is false. In any case where the specified track has not been muted, this method should return false. This applies if the sequencer does not support muting of tracks, and if the specified track index is not valid.
| |
| getTrackSolo | back to summary |
|---|---|
| public boolean getTrackSolo(int track) Obtains the current solo state for a track. The default mute state for all tracks which have not been solo'd is false. In any case where the specified track has not been solo'd, this method should return false. This applies if the sequencer does not support soloing of tracks, and if the specified track index is not valid.
| |
| isRecording | back to summary |
|---|---|
| public boolean isRecording() Indicates whether the Sequencer is currently recording. The default is
| |
| isRunning | back to summary |
|---|---|
| public boolean isRunning() Indicates whether the Sequencer is currently running. The default is
| |
| recordDisable | back to summary |
|---|---|
| public void recordDisable(Track track) Disables recording to the specified track. Events will no longer be recorded into this track.
| |
| recordEnable | back to summary |
|---|---|
| public void recordEnable(Track track, int channel) Prepares the specified track for recording events received on a particular channel. Once enabled, a track will receive events when recording is active.
| |
| removeControllerEventListener | back to summary |
|---|---|
| public int[] removeControllerEventListener(ControllerEventListener listener, int[] controllers) Removes a controller event listener's interest in one or more types of
controller event. The
| |
| removeMetaEventListener | back to summary |
|---|---|
| public void removeMetaEventListener(MetaEventListener listener) Removes the specified meta-event listener from this sequencer's list of registered listeners, if in fact the listener is registered.
| |
| setLoopCount | back to summary |
|---|---|
| public void setLoopCount(int count) Sets the number of repetitions of the loop for playback. When the
playback position reaches the loop end point, it will loop back to the
loop start point If the current position when this method is invoked is greater than the loop end point, playback continues to the end of the sequence without looping, unless the loop end point is changed subsequently.
A If playback is stopped during looping, the current loop status is cleared; subsequent start requests are not affected by an interrupted loop operation.
| |
| setLoopEndPoint | back to summary |
|---|---|
| public void setLoopEndPoint(long tick) Sets the last MIDI tick that will be played in the loop. If the loop count is 0, the loop end point has no effect and playback continues to play when reaching the loop end point. A value of -1 for the ending point indicates the last tick of the sequence. Otherwise, the ending point must be greater than or equal to the starting point, and it must fall within the size of the loaded sequence. A sequencer's loop end point defaults to -1, meaning the end of the sequence.
| |
| setLoopStartPoint | back to summary |
|---|---|
| public void setLoopStartPoint(long tick) Sets the first MIDI tick that will be played in the loop. If the loop count is greater than 0, playback will jump to this point when reaching the loop end point. A value of 0 for the starting point means the beginning of the loaded sequence. The starting point must be lower than or equal to the ending point, and it must fall within the size of the loaded sequence. A sequencer's loop start point defaults to start of the sequence.
| |
| setMasterSyncMode | back to summary |
|---|---|
| public void setMasterSyncMode(Sequencer. Sets the source of timing information used by this sequencer. The
sequencer synchronizes to the master, which is the internal clock, MIDI
clock, or MIDI time code, depending on the value of
| |
| setMicrosecondPosition | back to summary |
|---|---|
| public void setMicrosecondPosition(long microseconds) Sets the current position in the sequence, expressed in microseconds.
| |
| setSequence | back to summary |
|---|---|
| public void setSequence(Sequence sequence) throws InvalidMidiDataException Sets the current sequence on which the sequencer operates.
This method can be called even if the
| |
| setSequence | back to summary |
|---|---|
| public void setSequence(InputStream stream) throws IOException, InvalidMidiDataException Sets the current sequence on which the sequencer operates. The stream must point to MIDI file data.
This method can be called even if the
| |
| setSlaveSyncMode | back to summary |
|---|---|
| public void setSlaveSyncMode(Sequencer. Sets the slave synchronization mode for the sequencer. This indicates the
type of timing information sent by the sequencer to its receiver. The
| |
| setTempoFactor | back to summary |
|---|---|
| public void setTempoFactor(float factor) Scales the sequencer's actual playback tempo by the factor provided. The
default is 1.0. A value of 1.0 represents the natural rate (the tempo
specified in the sequence), 2.0 means twice as fast, etc. The tempo
factor does not affect the values returned by
Note that the tempo factor cannot be adjusted when external
synchronization is used. In that situation,
| |
| setTempoInBPM | back to summary |
|---|---|
| public void setTempoInBPM(float bpm) Sets the tempo in beats per minute. The actual tempo of playback is the product of the specified value and the tempo factor.
| |
| setTempoInMPQ | back to summary |
|---|---|
| public void setTempoInMPQ(float mpq) Sets the tempo in microseconds per quarter note. The actual tempo of playback is the product of the specified value and the tempo factor.
| |
| setTickPosition | back to summary |
|---|---|
| public void setTickPosition(long tick) Sets the current sequencer position in MIDI ticks.
| |
| setTrackMute | back to summary |
|---|---|
| public void setTrackMute(int track, boolean mute) Sets the mute state for a track. This method may fail for a number of
reasons. For example, the track number specified may not be valid for the
current sequence, or the sequencer may not support this functionality. An
application which needs to verify whether this operation succeeded should
follow this call with a call to
| |
| setTrackSolo | back to summary |
|---|---|
| public void setTrackSolo(int track, boolean solo) Sets the solo state for a track. If
This method may fail for a number of reasons. For example, the track
number specified may not be valid for the current sequence, or the
sequencer may not support this functionality. An application which needs
to verify whether this operation succeeded should follow this call with a
call to
| |
| start | back to summary |
|---|---|
| public void start() Starts playback of the MIDI data in the currently loaded sequence.
Playback will begin from the current position. If the playback position
reaches the loop end point, and the loop count is greater than 0,
playback will resume at the loop start point for the number of
repetitions set with The implementation ensures that the synthesizer is brought to a consistent state when jumping to the loop start point by sending appropriate controllers, pitch bend, and program change events.
| |
| startRecording | back to summary |
|---|---|
| public void startRecording() Starts recording and playback of MIDI data. Data is recorded to all enabled tracks, on the channel(s) for which they were enabled. Recording begins at the current position of the sequencer. Any events already in the track are overwritten for the duration of the recording session. Events from the currently loaded sequence, if any, are delivered to the sequencer's transmitter(s) along with messages received during recording. Note that tracks are not by default enabled for recording. In order to record MIDI data, at least one track must be specifically enabled for recording.
| |
| stop | back to summary |
|---|---|
| public void stop() Stops recording, if active, and playback of the currently loaded sequence, if any.
| |
| stopRecording | back to summary |
|---|---|
| public void stopRecording() Stops recording, if active. Playback of the current sequence continues.
| |
SyncMode object represents one of the ways in which a MIDI
sequencer's notion of time can be synchronized with a master or slave
device. If the sequencer is being synchronized to a master, the sequencer
revises its current time in response to messages from the master. If the
sequencer has a slave, the sequencer similarly sends messages to control
the slave's timing.
There are three predefined modes that specify possible masters for a
sequencer: INTERNAL_CLOCK, MIDI_SYNC, and
MIDI_TIME_CODE. The latter two work if the sequencer receives
MIDI messages from another device. In these two modes, the sequencer's
time gets reset based on system real-time timing clock messages or MIDI
time code (MTC) messages, respectively. These two modes can also be used
as slave modes, in which case the sequencer sends the corresponding types
of MIDI messages to its receiver (whether or not the sequencer is also
receiving them from a master). A fourth mode, NO_SYNC, is used to
indicate that the sequencer should not control its receiver's timing.
| Modifier and Type | Field and Description |
|---|---|
| public static final Sequencer. | INTERNAL_CLOCK
A master synchronization mode that makes the sequencer get its timing information from its internal clock. |
| public static final Sequencer. | MIDI_SYNC
A master or slave synchronization mode that specifies the use of MIDI clock messages. |
| public static final Sequencer. | MIDI_TIME_CODE
A master or slave synchronization mode that specifies the use of MIDI Time Code. |
| private final String | name
Synchronization mode name. |
| public static final Sequencer. | NO_SYNC
A slave synchronization mode indicating that no timing information should be sent to the receiver. |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | Returns: true if the specified object is equal to this
synchronization mode; false otherwisethe reference object with which to compare obj)Overrides java. Indicates whether the specified object is equal to this
synchronization mode, returning |
| public final int | Returns: a hash code value for this synchronization modeOverrides java. Returns a hash code value for this synchronization mode. |
| public final String | Returns: a string representation of the synchronization modeOverrides java. Returns mode's name as the string representation of the synchronization mode. |
| INTERNAL_CLOCK | back to summary |
|---|---|
| public static final Sequencer. A master synchronization mode that makes the sequencer get its timing information from its internal clock. This is not a legal slave sync mode. | |
| MIDI_SYNC | back to summary |
|---|---|
| public static final Sequencer. A master or slave synchronization mode that specifies the use of MIDI clock messages. If this mode is used as the master sync mode, the sequencer gets its timing information from system real-time MIDI clock messages. This mode only applies as the master sync mode for sequencers that are also MIDI receivers. If this is the slave sync mode, the sequencer sends system real-time MIDI clock messages to its receiver. MIDI clock messages are sent at a rate of 24 per quarter note. | |
| MIDI_TIME_CODE | back to summary |
|---|---|
| public static final Sequencer. A master or slave synchronization mode that specifies the use of MIDI Time Code. If this mode is used as the master sync mode, the sequencer gets its timing information from MIDI Time Code messages. This mode only applies as the master sync mode to sequencers that are also MIDI receivers. If this mode is used as the slave sync mode, the sequencer sends MIDI Time Code messages to its receiver. (See the MIDI 1.0 Detailed Specification for a description of MIDI Time Code.) | |
| name | back to summary |
|---|---|
| private final String name Synchronization mode name. | |
| NO_SYNC | back to summary |
|---|---|
| public static final Sequencer. A slave synchronization mode indicating that no timing information should be sent to the receiver. This is not a legal master sync mode. | |
| SyncMode | back to summary |
|---|---|
| protected SyncMode(String name) Constructs a synchronization mode.
| |
| equals | back to summary |
|---|---|
| public final boolean equals(Object obj) Overrides java. Indicates whether the specified object is equal to this
synchronization mode, returning | |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Overrides java. Returns a hash code value for this synchronization mode.
| |
| toString | back to summary |
|---|---|
| public final String toString() Overrides java. Returns mode's name as the string representation of the synchronization mode. | |