java.lang.Object
javax.sound.midi.MidiMessage
javax.sound.midi.ShortMessage
- All Implemented Interfaces:
- Cloneable
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
 MidiMessage class description.
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intStatus byte for Active Sensing message (0xFE, or 254).static final intCommand value for Channel Pressure (Aftertouch) message (0xD0, or 208).static final intStatus byte for Continue message (0xFB, or 251).static final intCommand value for Control Change message (0xB0, or 176).static final intStatus byte for End of System Exclusive message (0xF7, or 247).static final intStatus byte for MIDI Time Code Quarter Frame message (0xF1, or 241).static final intCommand value for Note Off message (0x80, or 128).static final intCommand value for Note On message (0x90, or 144).static final intCommand value for Pitch Bend message (0xE0, or 224).static final intCommand value for Polyphonic Key Pressure (Aftertouch) message (0xA0, or 160).static final intCommand value for Program Change message (0xC0, or 192).static final intStatus byte for Song Position Pointer message (0xF2, or 242).static final intStatus byte for MIDI Song Select message (0xF3, or 243).static final intStatus byte for Start message (0xFA, or 250).static final intStatus byte for Stop message (0xFC, or 252).static final intStatus byte for System Reset message (0xFF, or 255).static final intStatus byte for Timing Clock message (0xF8, or 248).static final intStatus byte for Tune Request message (0xF6, or 246).Fields declared in class javax.sound.midi.MidiMessagedata, length
- 
Constructor SummaryConstructorsModifierConstructorDescriptionConstructs a newShortMessage.protectedShortMessage(byte[] data) Constructs a newShortMessage.ShortMessage(int status) Constructs a newShortMessagewhich represents a MIDI message that takes no data bytes.ShortMessage(int status, int data1, int data2) Constructs a newShortMessagewhich represents a MIDI message that takes up to two data bytes.ShortMessage(int command, int channel, int data1, int data2) Constructs a newShortMessagewhich represents a channel MIDI message that takes up to two data bytes.
- 
Method SummaryModifier and TypeMethodDescriptionclone()Creates a new object of the same class and with the same contents as this object.intObtains the MIDI channel associated with this event.intObtains the MIDI command associated with this event.intgetData1()Obtains the first data byte in the message.intgetData2()Obtains the second data byte in the message.protected final intgetDataLength(int status) Retrieves the number of data bytes associated with a particular status byte value.voidsetMessage(int status) Sets the parameters for a MIDI message that takes no data bytes.voidsetMessage(int status, int data1, int data2) Sets the parameters for a MIDI message that takes one or two data bytes.voidsetMessage(int command, int channel, int data1, int data2) Sets the short message parameters for a channel message which takes up to two data bytes.Methods declared in class javax.sound.midi.MidiMessagegetLength, getMessage, getStatus, setMessage
- 
Field Details- 
MIDI_TIME_CODEpublic static final int MIDI_TIME_CODEStatus byte for MIDI Time Code Quarter Frame message (0xF1, or 241).- See Also:
 
- 
SONG_POSITION_POINTERpublic static final int SONG_POSITION_POINTERStatus byte for Song Position Pointer message (0xF2, or 242).- See Also:
 
- 
SONG_SELECTpublic static final int SONG_SELECTStatus byte for MIDI Song Select message (0xF3, or 243).- See Also:
 
- 
TUNE_REQUESTpublic static final int TUNE_REQUESTStatus byte for Tune Request message (0xF6, or 246).- See Also:
 
- 
END_OF_EXCLUSIVEpublic static final int END_OF_EXCLUSIVEStatus byte for End of System Exclusive message (0xF7, or 247).- See Also:
 
- 
TIMING_CLOCKpublic static final int TIMING_CLOCKStatus byte for Timing Clock message (0xF8, or 248).- See Also:
 
- 
STARTpublic static final int STARTStatus byte for Start message (0xFA, or 250).- See Also:
 
- 
CONTINUEpublic static final int CONTINUEStatus byte for Continue message (0xFB, or 251).- See Also:
 
- 
STOPpublic static final int STOPStatus byte for Stop message (0xFC, or 252).- See Also:
 
- 
ACTIVE_SENSINGpublic static final int ACTIVE_SENSINGStatus byte for Active Sensing message (0xFE, or 254).- See Also:
 
- 
SYSTEM_RESETpublic static final int SYSTEM_RESETStatus byte for System Reset message (0xFF, or 255).- See Also:
 
- 
NOTE_OFFpublic static final int NOTE_OFFCommand value for Note Off message (0x80, or 128).- See Also:
 
- 
NOTE_ONpublic static final int NOTE_ONCommand value for Note On message (0x90, or 144).- See Also:
 
- 
POLY_PRESSUREpublic static final int POLY_PRESSURECommand value for Polyphonic Key Pressure (Aftertouch) message (0xA0, or 160).- See Also:
 
- 
CONTROL_CHANGEpublic static final int CONTROL_CHANGECommand value for Control Change message (0xB0, or 176).- See Also:
 
- 
PROGRAM_CHANGEpublic static final int PROGRAM_CHANGECommand value for Program Change message (0xC0, or 192).- See Also:
 
- 
CHANNEL_PRESSUREpublic static final int CHANNEL_PRESSURECommand value for Channel Pressure (Aftertouch) message (0xD0, or 208).- See Also:
 
- 
PITCH_BENDpublic static final int PITCH_BENDCommand value for Pitch Bend message (0xE0, or 224).- See Also:
 
 
- 
- 
Constructor Details- 
ShortMessagepublic ShortMessage()Constructs a newShortMessage. 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 thesetMessagemethods.- See Also:
 
- 
ShortMessageConstructs a newShortMessagewhich represents a MIDI message that takes no data bytes. The contents of the message can be changed by using one of thesetMessagemethods.- Parameters:
- status- the MIDI status byte
- Throws:
- InvalidMidiDataException- if- statusdoes not specify a valid MIDI status byte for a message that requires no data bytes
- Since:
- 1.7
- See Also:
 
- 
ShortMessageConstructs a newShortMessagewhich represents a MIDI message that 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. The contents of the message can be changed by using one of thesetMessagemethods.- Parameters:
- status- the MIDI status byte
- data1- the first data byte
- data2- the second data byte
- Throws:
- InvalidMidiDataException- if the status byte or all data bytes belonging to the message do not specify a valid MIDI message
- Since:
- 1.7
- See Also:
 
- 
ShortMessageConstructs a newShortMessagewhich represents a channel MIDI message that 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. The contents of the message can be changed by using one of thesetMessagemethods.- Parameters:
- 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
- Throws:
- InvalidMidiDataException- if the command value, channel value or all data bytes belonging to the message do not specify a valid MIDI message
- Since:
- 1.7
- See Also:
 
- 
ShortMessageprotected ShortMessage(byte[] data) Constructs a newShortMessage.- Parameters:
- data- an array of bytes containing the complete message. The message data may be changed using the- setMessagemethod.
- See Also:
 
 
- 
- 
Method Details- 
setMessageSets the parameters for a MIDI message that takes no data bytes.- Parameters:
- status- the MIDI status byte
- Throws:
- InvalidMidiDataException- if- statusdoes not specify a valid MIDI status byte for a message that requires no data bytes
- See Also:
 
- 
setMessageSets 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.- Parameters:
- status- the MIDI status byte
- data1- the first data byte
- data2- the second data byte
- Throws:
- InvalidMidiDataException- if the status byte, or all data bytes belonging to the message, do not specify a valid MIDI message
- See Also:
 
- 
setMessagepublic void setMessage(int command, int channel, int data1, int data2) throws InvalidMidiDataException Sets 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.- Parameters:
- 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
- Throws:
- InvalidMidiDataException- if the status byte or all data bytes belonging to the message, do not specify a valid MIDI message
- See Also:
 
- 
getChannelpublic int getChannel()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.- Returns:
- MIDI channel associated with the message
- See Also:
 
- 
getCommandpublic int getCommand()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.- Returns:
- the MIDI command associated with this event
- See Also:
 
- 
getData1public int getData1()Obtains the first data byte in the message.- Returns:
- the value of the data1field
- See Also:
 
- 
getData2public int getData2()Obtains the second data byte in the message.- Returns:
- the value of the data2field
- See Also:
 
- 
cloneCreates a new object of the same class and with the same contents as this object.- Specified by:
- clonein class- MidiMessage
- Returns:
- a clone of this instance
- See Also:
 
- 
getDataLengthRetrieves the number of data bytes associated with a particular status byte value.- Parameters:
- status- status byte value, which must represent a short MIDI message
- Returns:
- data length in bytes (0, 1, or 2)
- Throws:
- InvalidMidiDataException- if the- statusargument does not represent the status byte for any short message
 
 
-