Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.sound.midi.MidiMessage
javax.sound.midi.ShortMessage
public class ShortMessage
extends MidiMessage
Field Summary | |
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
Fields inherited from class javax.sound.midi.MidiMessage | |
data , length |
Constructor Summary | |
| |
|
Method Summary | |
Object |
|
int |
|
int |
|
int |
|
int |
|
protected int |
|
void |
|
void |
|
void |
|
Methods inherited from class javax.sound.midi.MidiMessage | |
clone , getLength , getMessage , getStatus , setMessage |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static final int ACTIVE_SENSING
Status byte for Active Sensing message.
- Field Value:
- 254
public static final int CHANNEL_PRESSURE
Statue nibble for Channel Pressure message.
- Field Value:
- 208
public static final int CONTROL_CHANGE
Status nibble for Control Change message.
- Field Value:
- 176
public static final int END_OF_EXCLUSIVE
Status byte for End Of Exclusive message.
- Field Value:
- 247
public static final int MIDI_TIME_CODE
Status byte for Time Code message.
- Field Value:
- 241
public static final int POLY_PRESSURE
Status nibble for Poly Pressure message.
- Field Value:
- 160
public static final int PROGRAM_CHANGE
Status nibble for Program Change message.
- Field Value:
- 192
public static final int SONG_POSITION_POINTER
Status byte for Song Position Pointer message.
- Field Value:
- 242
public static final int SYSTEM_RESET
Status byte for System Reset message.
- Field Value:
- 255
public static final int TIMING_CLOCK
Status byte for Timing Clock message.
- Field Value:
- 248
public static final int TUNE_REQUEST
Status byte for Tune Request message.
- Field Value:
- 246
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.
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
public Object clone()
This method may be called to create a new copy of the Object. The typical behavior is as follows:
o == o.clone()
is falseo.getClass() == o.clone().getClass()
is trueo.equals(o)
is trueHowever, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override
Object.equals(Object)
.If the Object you call clone() on does not implement
Cloneable
(which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.
All array types implement Cloneable, and override this method as follows (it should never fail):
public Object clone() { try { super.clone(); } catch (CloneNotSupportedException e) { throw new InternalError(e.getMessage()); } }
- Overrides:
- clone in interface MidiMessage
- Returns:
- a copy of the Object
- See Also:
Cloneable
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
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
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.
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.
protected final int getDataLength(int status) throws InvalidMidiDataException
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
public void setMessage(int status) throws InvalidMidiDataException
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
public void setMessage(int status, int data1, int data2) throws InvalidMidiDataException
Set the MIDI message.
- Parameters:
status
- the status byte for this messagedata1
- the first data byte for this messagedata2
- the second data byte for this message
- Throws:
InvalidMidiDataException
- if status is bad, or data is out of range
public void setMessage(int command, int channel, int data1, int data2) throws InvalidMidiDataException