5050147: RFE: Add More Useful Constructors to MidiMessage Subclasses
Reviewed-by: alexp
This commit is contained in:
parent
fd76ca6d80
commit
a758339886
@ -102,6 +102,29 @@ public class MetaMessage extends MidiMessage {
|
||||
this(defaultMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code MetaMessage} and sets the message parameters.
|
||||
* The contents of the message can be changed by using
|
||||
* the {@code setMessage} method.
|
||||
*
|
||||
* @param type meta-message type (must be less than 128)
|
||||
* @param data the data bytes in the MIDI message
|
||||
* @param length an amount of bytes in the {@code data} byte array;
|
||||
* it should be non-negative and less than or equal to
|
||||
* {@code data.length}
|
||||
* @throws InvalidMidiDataException if the parameter values do not specify
|
||||
* a valid MIDI meta message
|
||||
* @see #setMessage(int, byte[], int)
|
||||
* @see #getType()
|
||||
* @see #getData()
|
||||
* @since 1.7
|
||||
*/
|
||||
public MetaMessage(int type, byte[] data, int length)
|
||||
throws InvalidMidiDataException {
|
||||
super(null);
|
||||
setMessage(type, data, length); // can throw InvalidMidiDataException
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new <code>MetaMessage</code>.
|
||||
|
@ -187,6 +187,83 @@ public class ShortMessage extends MidiMessage {
|
||||
length = 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code ShortMessage} which represents a MIDI
|
||||
* message that takes no data bytes.
|
||||
* The contents of the message can be changed by using one of
|
||||
* the {@code setMessage} methods.
|
||||
*
|
||||
* @param status the MIDI status byte
|
||||
* @throws InvalidMidiDataException if {@code status} does not specify
|
||||
* a valid MIDI status byte for a message that requires no data bytes
|
||||
* @see #setMessage(int)
|
||||
* @see #setMessage(int, int, int)
|
||||
* @see #setMessage(int, int, int, int)
|
||||
* @see #getStatus()
|
||||
* @since 1.7
|
||||
*/
|
||||
public ShortMessage(int status) throws InvalidMidiDataException {
|
||||
super(null);
|
||||
setMessage(status); // can throw InvalidMidiDataException
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code ShortMessage} which 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
|
||||
* the {@code setMessage} methods.
|
||||
*
|
||||
* @param status the MIDI status byte
|
||||
* @param data1 the first data byte
|
||||
* @param 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 #setMessage(int)
|
||||
* @see #setMessage(int, int, int)
|
||||
* @see #setMessage(int, int, int, int)
|
||||
* @see #getStatus()
|
||||
* @see #getData1()
|
||||
* @see #getData2()
|
||||
* @since 1.7
|
||||
*/
|
||||
public ShortMessage(int status, int data1, int data2)
|
||||
throws InvalidMidiDataException {
|
||||
super(null);
|
||||
setMessage(status, data1, data2); // can throw InvalidMidiDataException
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code ShortMessage} which 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
|
||||
* the {@code setMessage} methods.
|
||||
*
|
||||
* @param command the MIDI command represented by this message
|
||||
* @param channel the channel associated with the message
|
||||
* @param data1 the first data byte
|
||||
* @param 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
|
||||
* @see #setMessage(int)
|
||||
* @see #setMessage(int, int, int)
|
||||
* @see #setMessage(int, int, int, int)
|
||||
* @see #getCommand()
|
||||
* @see #getChannel()
|
||||
* @see #getData1()
|
||||
* @see #getData2()
|
||||
* @since 1.7
|
||||
*/
|
||||
public ShortMessage(int command, int channel, int data1, int data2)
|
||||
throws InvalidMidiDataException {
|
||||
super(null);
|
||||
setMessage(command, channel, data1, data2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new <code>ShortMessage</code>.
|
||||
|
@ -120,6 +120,54 @@ public class SysexMessage extends MidiMessage {
|
||||
data[1] = (byte) (ShortMessage.END_OF_EXCLUSIVE & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code SysexMessage} and sets the data for
|
||||
* the message. The first byte of the data array must be a valid system
|
||||
* exclusive status byte (0xF0 or 0xF7).
|
||||
* The contents of the message can be changed by using one of
|
||||
* the {@code setMessage} methods.
|
||||
*
|
||||
* @param data the system exclusive message data including the status byte
|
||||
* @param length the length of the valid message data in the array,
|
||||
* including the status byte; it should be non-negative and less than
|
||||
* or equal to {@code data.length}
|
||||
* @throws InvalidMidiDataException if the parameter values
|
||||
* do not specify a valid MIDI meta message.
|
||||
* @see #setMessage(byte[], int)
|
||||
* @see #setMessage(int, byte[], int)
|
||||
* @see #getData()
|
||||
* @since 1.7
|
||||
*/
|
||||
public SysexMessage(byte[] data, int length)
|
||||
throws InvalidMidiDataException {
|
||||
super(null);
|
||||
setMessage(data, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code SysexMessage} and sets the data for the message.
|
||||
* The contents of the message can be changed by using one of
|
||||
* the {@code setMessage} methods.
|
||||
*
|
||||
* @param status the status byte for the message; it must be a valid system
|
||||
* exclusive status byte (0xF0 or 0xF7)
|
||||
* @param data the system exclusive message data (without the status byte)
|
||||
* @param length the length of the valid message data in the array;
|
||||
* it should be non-negative and less than or equal to
|
||||
* {@code data.length}
|
||||
* @throws InvalidMidiDataException if the parameter values
|
||||
* do not specify a valid MIDI meta message.
|
||||
* @see #setMessage(byte[], int)
|
||||
* @see #setMessage(int, byte[], int)
|
||||
* @see #getData()
|
||||
* @since 1.7
|
||||
*/
|
||||
public SysexMessage(int status, byte[] data, int length)
|
||||
throws InvalidMidiDataException {
|
||||
super(null);
|
||||
setMessage(status, data, length);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new <code>SysexMessage</code>.
|
||||
|
Loading…
x
Reference in New Issue
Block a user