|
JavaTM 2 Platform Std. Ed. v1.4.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A hardware or software device that plays back a MIDI
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.
sequence
The Sequencer
interface includes methods for the following
basic MIDI sequencer operations:
Sequencer
has access to:
Sequencer.SyncMode
,
addMetaEventListener(javax.sound.midi.MetaEventListener)
,
ControllerEventListener
,
Receiver
,
Transmitter
,
MidiDevice
Nested Class Summary | |
static class |
Sequencer.SyncMode
A 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. |
Nested classes inherited from class javax.sound.midi.MidiDevice |
MidiDevice.Info |
Method Summary | |
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. |
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. |
Sequencer.SyncMode |
getMasterSyncMode()
Obtains the current master synchronization mode for this sequencer. |
Sequencer.SyncMode[] |
getMasterSyncModes()
Obtains the set of master synchronization modes supported by this sequencer. |
long |
getMicrosecondLength()
Obtains the length of the current sequence, expressed in microseconds. |
long |
getMicrosecondPosition()
Obtains the current position in the sequence, expressed in microseconds. |
Sequence |
getSequence()
Obtains the sequence on which the Sequencer is currently operating. |
Sequencer.SyncMode |
getSlaveSyncMode()
Obtains the current slave synchronization mode for this sequencer. |
Sequencer.SyncMode[] |
getSlaveSyncModes()
Obtains the set of slave synchronization modes supported by the sequencer. |
float |
getTempoFactor()
Returns the current tempo factor for the sequencer. |
float |
getTempoInBPM()
Obtains the current tempo, expressed in beats per minute. |
float |
getTempoInMPQ()
Obtains the current tempo, expressed in microseconds per quarter note. |
long |
getTickLength()
Obtains the length of the current sequence, expressed in MIDI ticks. |
long |
getTickPosition()
Obtains the current position in the sequence, expressed in MIDI ticks. |
boolean |
getTrackMute(int track)
Obtains the current mute state for a track. |
boolean |
getTrackSolo(int track)
Obtains the current solo state for a track. |
boolean |
isRecording()
Indicates whether the Sequencer is currently recording. |
boolean |
isRunning()
Indicates whether the Sequencer is currently running. |
void |
recordDisable(Track track)
Disables recording to the specified track. |
void |
recordEnable(Track track,
int channel)
Prepares the specified track for recording events received on a particular channel. |
int[] |
removeControllerEventListener(ControllerEventListener listener,
int[] controllers)
Removes a controller event listener's interest in one or more types of controller event. |
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. |
void |
setMasterSyncMode(Sequencer.SyncMode sync)
Sets the source of timing information used by this sequencer. |
void |
setMicrosecondPosition(long microseconds)
Sets the current position in the sequence, expressed in microseconds |
void |
setSequence(InputStream stream)
Sets the current sequence on which the sequencer operates. |
void |
setSequence(Sequence sequence)
Sets the current sequence on which the sequencer operates. |
void |
setSlaveSyncMode(Sequencer.SyncMode sync)
Sets the slave synchronization mode for the sequencer. |
void |
setTempoFactor(float factor)
Scales the sequencer's actual playback tempo by the factor provided. |
void |
setTempoInBPM(float bpm)
Sets the tempo in beats per minute. |
void |
setTempoInMPQ(float mpq)
Sets the tempo in microseconds per quarter note. |
void |
setTickPosition(long tick)
Sets the current sequencer position in MIDI ticks |
void |
setTrackMute(int track,
boolean mute)
Sets the mute state for a track. |
void |
setTrackSolo(int track,
boolean solo)
Sets the solo state for a track. |
void |
start()
Starts playback of the MIDI data in the currently loaded sequence. |
void |
startRecording()
Starts recording and playback of MIDI data. |
void |
stop()
Stops recording, if active, and playback of the currently loaded sequence, if any. |
void |
stopRecording()
Stops recording, if active. |
Methods inherited from interface javax.sound.midi.MidiDevice |
close, getDeviceInfo, getMaxReceivers, getMaxTransmitters, getReceiver, getTransmitter, isOpen, open |
Method Detail |
public void setSequence(Sequence sequence) throws InvalidMidiDataException
sequence
- the sequence to be loaded.
InvalidMidiDataException
- if the sequence contains invalid
MIDI data, or is not supported.public void setSequence(InputStream stream) throws IOException, InvalidMidiDataException
stream
- stream containing MIDI file data.
IOException
- if an I/O exception occurs during reading of the stream.
InvalidMidiDataException
- if invalid data is encountered
in the stream, or the stream is not supported.public Sequence getSequence()
null
if no sequence is currently set.public void start()
public void stop()
start()
,
isRunning()
public boolean isRunning()
false
.
The Sequencer starts running when either start()
or startRecording()
is called. isRunning
then returns true
until playback of the
sequence completes or stop()
is called.
true
if the Sequencer is running, otherwise false
public void startRecording()
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.
public void stopRecording()
startRecording()
,
isRecording()
public boolean isRecording()
false
.
The Sequencer begins recording when startRecording()
is called,
and then returns true
until stop()
or stopRecording()
is called.
true
if the Sequencer is recording, otherwise false
public void recordEnable(Track track, int channel)
track
- the track to which events will be recordedchannel
- the channel on which events will be received. If -1 is specified
for the channel value, the track will receive data from all channels.
IllegalArgumentException
- thrown if the track is not part of the current
sequence.public void recordDisable(Track track)
track
- the track to disable for recording, or null
to disable
recording for all tracks.public float getTempoInBPM()
getTempoFactor()
,
setTempoInBPM(float)
,
getTempoInMPQ()
public void setTempoInBPM(float bpm)
bpm
- desired new tempo in beats per minutegetTempoFactor()
,
setTempoInMPQ(float)
,
getTempoInBPM()
public float getTempoInMPQ()
getTempoFactor()
,
setTempoInMPQ(float)
,
getTempoInBPM()
public void setTempoInMPQ(float mpq)
mpq
- desired new tempo in microseconds per quarter note.getTempoFactor()
,
setTempoInBPM(float)
,
getTempoInMPQ()
public void setTempoFactor(float factor)
getTempoInMPQ()
and getTempoInBPM()
.
Those values indicate the tempo prior to scaling.
Note that the tempo factor cannot be adjusted when external
synchronization is used. In that situation,
setTempoFactor
always sets the tempo factor to 1.0.
factor
- the requested tempo scalargetTempoFactor()
public float getTempoFactor()
setTempoFactor(float)
public long getTickLength()
public long getTickPosition()
Sequence
.)
setTickPosition(long)
public void setTickPosition(long tick)
tick
- the desired tick positiongetTickPosition()
public long getMicrosecondLength()
public long getMicrosecondPosition()
getMicrosecondPosition
in interface MidiDevice
setMicrosecondPosition(long)
public void setMicrosecondPosition(long microseconds)
microseconds
- desired position in microsecondsgetMicrosecondPosition()
public void setMasterSyncMode(Sequencer.SyncMode sync)
sync
. The sync
argument must be one
of the supported modes, as returned by
getMasterSyncModes()
.
sync
- the desired master synchronization modeSequencer.SyncMode.INTERNAL_CLOCK
,
Sequencer.SyncMode.MIDI_SYNC
,
Sequencer.SyncMode.MIDI_TIME_CODE
,
getMasterSyncMode()
public Sequencer.SyncMode getMasterSyncMode()
setMasterSyncMode(Sequencer.SyncMode)
,
getMasterSyncModes()
public Sequencer.SyncMode[] getMasterSyncModes()
Sequencer.SyncMode.INTERNAL_CLOCK
,
Sequencer.SyncMode.MIDI_SYNC
,
Sequencer.SyncMode.MIDI_TIME_CODE
,
getMasterSyncMode()
,
setMasterSyncMode(Sequencer.SyncMode)
public void setSlaveSyncMode(Sequencer.SyncMode sync)
sync
argument must be one
of the supported modes, as returned by
getSlaveSyncModes()
.
sync
- the desired slave synchronization modeSequencer.SyncMode.MIDI_SYNC
,
Sequencer.SyncMode.MIDI_TIME_CODE
,
Sequencer.SyncMode.NO_SYNC
,
getSlaveSyncModes()
public Sequencer.SyncMode getSlaveSyncMode()
setSlaveSyncMode(Sequencer.SyncMode)
,
getSlaveSyncModes()
public Sequencer.SyncMode[] getSlaveSyncModes()
Sequencer.SyncMode.MIDI_SYNC
,
Sequencer.SyncMode.MIDI_TIME_CODE
,
Sequencer.SyncMode.NO_SYNC
public void setTrackMute(int track, boolean mute)
getTrackMute(int)
.
track
- the track number. Tracks in the current sequence are numbered
from 0 to the number of tracks in the sequence minus 1.mute
- the new mute state for the track. true
implies the
track should be muted, false
implies the track should be unmuted.getSequence()
public boolean getTrackMute(int track)
track
- the track number. Tracks in the current sequence are numbered
from 0 to the number of tracks in the sequence minus 1.
true
if muted, false
if not.public void setTrackSolo(int track, boolean solo)
solo
is true
only this track and other solo'd tracks will sound. If solo
is false
then only other solo'd tracks will sound, unless no
tracks are solo'd in which case all un-muted tracks will sound.
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
.
getTrackSolo(int)
track
- the track number. Tracks in the current sequence are numbered
from 0 to the number of tracks in the sequence minus 1.solo
- the new solo state for the track. true
implies the
track should be solo'd, false
implies the track should not be solo'd.getSequence()
public boolean getTrackSolo(int track)
track
- the track number. Tracks in the current sequence are numbered
from 0 to the number of tracks in the sequence minus 1.
true
if solo'd, false
if not.public boolean addMetaEventListener(MetaEventListener listener)
listener
- listener to add
true
if the listener was successfully added,
otherwise false
removeMetaEventListener(javax.sound.midi.MetaEventListener)
,
MetaEventListener
,
MetaMessage
public void removeMetaEventListener(MetaEventListener listener)
listener
- the meta-event listener to removeaddMetaEventListener(javax.sound.midi.MetaEventListener)
public int[] addControllerEventListener(ControllerEventListener listener, int[] controllers)
controllers
argument, which should contain an array of
MIDI controller numbers. (Each number should be between 0 and 127,
inclusive. See the MIDI 1.0 Specification for the numbers that
correspond to various types of controllers.)
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.
listener
- the controller event listener to add to the list of
registered listenerscontrollers
- the MIDI controller numbers for which change
notification is requested
removeControllerEventListener(javax.sound.midi.ControllerEventListener, int[])
,
ControllerEventListener
public int[] removeControllerEventListener(ControllerEventListener listener, int[] controllers)
controllers
argument
is an array of MIDI numbers corresponding to the controllers for
which the listener should no longer receive change notifications.
To completely remove this listener from the list of registered
listeners, pass in null
for controllers
.
The returned array contains the MIDI controller
numbers for which the listener will now receive events. The
array has a length of 0 if the listener will not receive
change notifications for any controllers.
listener
- old listenercontrollers
- the MIDI controller numbers for which change
notification should be cancelled, or null
to cancel
for all controllers
addControllerEventListener(javax.sound.midi.ControllerEventListener, int[])
|
JavaTM 2 Platform Std. Ed. v1.4.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 2002 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.