javax.sound.midi

Class ShortMessage

public class ShortMessage extends MidiMessage

A short MIDI message that is no longer than 3 bytes long.

Since: 1.3

Field Summary
static intACTIVE_SENSING
Status byte for Active Sensing message.
static intCHANNEL_PRESSURE
Statue nibble for Channel Pressure message.
static intCONTINUE
Status byte for Continue message.
static intCONTROL_CHANGE
Status nibble for Control Change message.
static intEND_OF_EXCLUSIVE
Status byte for End Of Exclusive message.
static intMIDI_TIME_CODE
Status byte for Time Code message.
static intNOTE_OFF
Status nibble for Note Off message.
static intNOTE_ON
Status nibble for Note On message.
static intPITCH_BEND
Status nibble for Pitch Bend message.
static intPOLY_PRESSURE
Status nibble for Poly Pressure message.
static intPROGRAM_CHANGE
Status nibble for Program Change message.
static intSONG_POSITION_POINTER
Status byte for Song Position Pointer message.
static intSONG_SELECT
Status byte for Song Select message.
static intSTART
Status byte for Start message.
static intSTOP
Status byte for Stop message.
static intSYSTEM_RESET
Status byte for System Reset message.
static intTIMING_CLOCK
Status byte for Timing Clock message.
static intTUNE_REQUEST
Status byte for Tune Request message.
Constructor Summary
ShortMessage()
Create a short MIDI message.
protected ShortMessage(byte[] data)
Create a short MIDI message.
Method Summary
Objectclone()
intgetChannel()
Get the channel information from this MIDI message, assuming it is a MIDI channel message.
intgetCommand()
Get the command nibble from this MIDI message, assuming it is a MIDI channel message.
intgetData1()
Get the first data byte from this message, assuming it exists, and zero otherwise.
intgetData2()
Get the second data byte from this message, assuming it exists, and zero otherwise.
protected intgetDataLength(int status)
Return the number of data bytes needed for a given MIDI status byte.
voidsetMessage(int status, int data1, int data2)
Set the MIDI message.
voidsetMessage(int command, int channel, int data1, int data2)
voidsetMessage(int status)
Set the MIDI message to one that requires no data bytes.

Field Detail

ACTIVE_SENSING

public static final int ACTIVE_SENSING
Status byte for Active Sensing message.

CHANNEL_PRESSURE

public static final int CHANNEL_PRESSURE
Statue nibble for Channel Pressure message.

CONTINUE

public static final int CONTINUE
Status byte for Continue message.

CONTROL_CHANGE

public static final int CONTROL_CHANGE
Status nibble for Control Change message.

END_OF_EXCLUSIVE

public static final int END_OF_EXCLUSIVE
Status byte for End Of Exclusive message.

MIDI_TIME_CODE

public static final int MIDI_TIME_CODE
Status byte for Time Code message.

NOTE_OFF

public static final int NOTE_OFF
Status nibble for Note Off message.

NOTE_ON

public static final int NOTE_ON
Status nibble for Note On message.

PITCH_BEND

public static final int PITCH_BEND
Status nibble for Pitch Bend message.

POLY_PRESSURE

public static final int POLY_PRESSURE
Status nibble for Poly Pressure message.

PROGRAM_CHANGE

public static final int PROGRAM_CHANGE
Status nibble for Program Change message.

SONG_POSITION_POINTER

public static final int SONG_POSITION_POINTER
Status byte for Song Position Pointer message.

SONG_SELECT

public static final int SONG_SELECT
Status byte for Song Select message.

START

public static final int START
Status byte for Start message.

STOP

public static final int STOP
Status byte for Stop message.

SYSTEM_RESET

public static final int SYSTEM_RESET
Status byte for System Reset message.

TIMING_CLOCK

public static final int TIMING_CLOCK
Status byte for Timing Clock message.

TUNE_REQUEST

public static final int TUNE_REQUEST
Status byte for Tune Request message.

Constructor Detail

ShortMessage

public ShortMessage()
Create a short MIDI message. The spec requires that this represent a valid MIDI message, but doesn't specify what it should be. We've chosen the STOP message for our implementation.

ShortMessage

protected ShortMessage(byte[] data)
Create a short MIDI message. The data argument should be a valid MIDI message. Unfortunately the spec does not allow us to throw an InvalidMidiDataException if data is invalid.

Parameters: data the message data

Method Detail

clone

public Object clone()

getChannel

public int getChannel()
Get the channel information from this MIDI message, assuming it is a MIDI channel message.

Returns: the MIDI channel for this message

getCommand

public int getCommand()
Get the command nibble from this MIDI message, assuming it is a MIDI channel message.

Returns: the MIDI command for this message

getData1

public int getData1()
Get the first data byte from this message, assuming it exists, and zero otherwise.

Returns: the first data byte or zero if none exists.

getData2

public int getData2()
Get the second data byte from this message, assuming it exists, and zero otherwise.

Returns: the second date byte or zero if none exists.

getDataLength

protected final int getDataLength(int status)
Return the number of data bytes needed for a given MIDI status byte.

Parameters: status the status byte for a short MIDI message

Returns: the number of data bytes needed for this status byte

Throws: InvalidMidiDataException if status is an invalid status byte

setMessage

public void setMessage(int status, int data1, int data2)
Set the MIDI message.

Parameters: status the status byte for this message data1 the first data byte for this message data2 the second data byte for this message

Throws: InvalidMidiDataException if status is bad, or data is out of range

setMessage

public void setMessage(int command, int channel, int data1, int data2)

setMessage

public void setMessage(int status)
Set the MIDI message to one that requires no data bytes.

Parameters: status the status byte for this message

Throws: InvalidMidiDataException if status is bad, or requires data