java.lang.Object | ||
↳ | javax.sound.midi.MidiMessage | |
↳ | javax.sound.midi.ShortMessage |
![]() |
A ShortMessage
contains a MIDI message that has at most
two data bytes following its status byte. The types of MIDI message
that satisfy this criterion are channel voice, channel mode, system common,
and system real-time--in other words, everything except system exclusive
and meta-events. The ShortMessage
class provides methods
for getting and setting the contents of the MIDI message.
A number of ShortMessage
methods have integer parameters by which
you specify a MIDI status or data byte. If you know the numeric value, you
can express it directly. For system common and system real-time messages,
you can often use the corresponding fields of ShortMessage
, such as
SYSTEM_RESET
. For channel messages,
the upper four bits of the status byte are specified by a command value and
the lower four bits are specified by a MIDI channel number. To
convert incoming MIDI data bytes that are in the form of Java's signed bytes,
you can use the conversion code
given in the
class description.MidiMessage
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | ACTIVE_SENSING | Status byte for Active Sensing message (0xFE, or 254). | |||||||||
int | CHANNEL_PRESSURE | Command value for Channel Pressure (Aftertouch) message (0xD0, or 208) | |||||||||
int | CONTINUE | Status byte for Continue message (0xFB, or 251). | |||||||||
int | CONTROL_CHANGE | Command value for Control Change message (0xB0, or 176) | |||||||||
int | END_OF_EXCLUSIVE | Status byte for End of System Exclusive message (0xF7, or 247). | |||||||||
int | MIDI_TIME_CODE | Status byte for MIDI Time Code Quarter Frame message (0xF1, or 241). | |||||||||
int | NOTE_OFF | Command value for Note Off message (0x80, or 128) | |||||||||
int | NOTE_ON | Command value for Note On message (0x90, or 144) | |||||||||
int | PITCH_BEND | Command value for Pitch Bend message (0xE0, or 224) | |||||||||
int | POLY_PRESSURE | Command value for Polyphonic Key Pressure (Aftertouch) message (0xA0, or 160) | |||||||||
int | PROGRAM_CHANGE | Command value for Program Change message (0xC0, or 192) | |||||||||
int | SONG_POSITION_POINTER | Status byte for Song Position Pointer message (0xF2, or 242). | |||||||||
int | SONG_SELECT | Status byte for MIDI Song Select message (0xF3, or 243). | |||||||||
int | START | Status byte for Start message (0xFA, or 250). | |||||||||
int | STOP | Status byte for Stop message (0xFC, or 252). | |||||||||
int | SYSTEM_RESET | Status byte for System Reset message (0xFF, or 255). | |||||||||
int | TIMING_CLOCK | Status byte for Timing Clock messagem (0xF8, or 248). | |||||||||
int | TUNE_REQUEST | Status byte for Tune Request message (0xF6, or 246). |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new
ShortMessage . |
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new
ShortMessage . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new object of the same class and with the same contents
as this object.
| |||||||||||
Obtains the MIDI channel associated with this event.
| |||||||||||
Obtains the MIDI command associated with this event.
| |||||||||||
Obtains the first data byte in the message.
| |||||||||||
Obtains the second data byte in the message.
| |||||||||||
Sets the short message parameters for a channel message
which takes up to two data bytes.
| |||||||||||
Sets the parameters for a MIDI message that takes one or two data
bytes.
| |||||||||||
Sets the parameters for a MIDI message that takes no data bytes.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Retrieves the number of data bytes associated with a particular
status byte value.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Status byte for Active Sensing message (0xFE, or 254).
Command value for Channel Pressure (Aftertouch) message (0xD0, or 208)
Status byte for Continue message (0xFB, or 251).
Command value for Control Change message (0xB0, or 176)
Status byte for End of System Exclusive message (0xF7, or 247).
Status byte for MIDI Time Code Quarter Frame message (0xF1, or 241).
Command value for Note Off message (0x80, or 128)
Command value for Note On message (0x90, or 144)
Command value for Pitch Bend message (0xE0, or 224)
Command value for Polyphonic Key Pressure (Aftertouch) message (0xA0, or 160)
Command value for Program Change message (0xC0, or 192)
Status byte for Song Position Pointer message (0xF2, or 242).
Status byte for MIDI Song Select message (0xF3, or 243).
Status byte for System Reset message (0xFF, or 255).
Status byte for Timing Clock messagem (0xF8, or 248).
Status byte for Tune Request message (0xF6, or 246).
Constructs a new ShortMessage
. The
contents of the new message are guaranteed to specify
a valid MIDI message. Subsequently, you may set the
contents of the message using one of the setMessage
methods.
Constructs a new ShortMessage
.
data | an array of bytes containing the complete message.
The message data may be changed using the setMessage
method. |
---|
Creates a new object of the same class and with the same contents as this object.
Obtains the MIDI channel associated with this event. This method assumes that the event is a MIDI channel message; if not, the return value will not be meaningful.
Obtains the MIDI command associated with this event. This method assumes that the event is a MIDI channel message; if not, the return value will not be meaningful.
Obtains the first data byte in the message.
data1
fieldObtains the second data byte in the message.
data2
fieldSets the short message parameters for a channel message which takes up to two data bytes. If the message only takes one data byte, the second data byte is ignored; if the message does not take any data bytes, both data bytes are ignored.
command | the MIDI command represented by this message |
---|---|
channel | the channel associated with the message |
data1 | the first data byte |
data2 | the second data byte |
if the status byte or all data bytes belonging to the message, do not specify a valid MIDI message | |
InvalidMidiDataException |
Sets the parameters for a MIDI message that takes one or two data bytes. If the message takes only one data byte, the second data byte is ignored; if the message does not take any data bytes, both data bytes are ignored.
status | the MIDI status byte |
---|---|
data1 | the first data byte |
data2 | the second data byte |
if the the status byte, or all data bytes belonging to the message, do not specify a valid MIDI message. | |
InvalidMidiDataException |
Sets the parameters for a MIDI message that takes no data bytes.
status | the MIDI status byte |
---|
if status does not
specify a valid MIDI status byte for a message that requires no data bytes. |
|
InvalidMidiDataException |
Retrieves the number of data bytes associated with a particular status byte value.
status | status byte value, which must represent a short MIDI message |
---|
if the
status argument does not represent the status byte for any
short message
|
|
InvalidMidiDataException |