java.lang.Objectjavax.sound.midi.MidiMessage
javax.sound.midi.MetaMessage
public class MetaMessage
MetaMessage 是一个 ,它对于合成器没有任何意义,但可存储在一个 MIDI 文件中然后由 sequencer 程序解释。(请参阅 MidiMessageMidiMessage 类描述中的论述。)Standard MIDI Files 规范定义了各种元事件类型,例如序列号、歌词、提示点和设置的速度。还有针对类似歌词、版权、速度指示、时间和主要签名、制造者等信息的元事件。有关更多的信息,请参见 Standard MIDI Files 1.0 规范,它是由 MIDI 制造商协会 (http://www.midi.org) 发布的 Complete MIDI 1.0 Detailed Specification 的一部分。
使用 MIDI wire 协议传输数据时, 带状态值 ShortMessage0xFF 表示系统重置消息。在 MIDI 文件中,此相同的状态值表示 MetaMessage。各个元消息类型通过状态字节 0xFF 后面的第一个字节进行区分。后续的字节是数据字节。与系统独占消息相同,其中还有任意个数据字节,具体取决于 MetaMessage 的类型。
MetaEventListener
| 字段摘要 | |
|---|---|
static int |
META MetaMessage 的状态字节(0xFF 或 255),供在 MIDI 文件中使用。 |
| 从类 javax.sound.midi.MidiMessage 继承的字段 |
|---|
data, length |
| 构造方法摘要 | |
|---|---|
|
MetaMessage() 构造一个新的 MetaMessage。 |
protected |
MetaMessage(byte[] data) 构造一个新的 MetaMessage。 |
| 方法摘要 | |
|---|---|
Object |
clone() 创建一个与此对象具有相同类和相同内容的新对象。 |
byte[] |
getData() 获得元消息数据的副本。 |
int |
getType() 获得 MetaMessage 的类型。 |
void |
setMessage(int type, byte[] data, int length) 为 MetaMessage 设置消息参数。 |
| 从类 javax.sound.midi.MidiMessage 继承的方法 |
|---|
getLength, getMessage, getStatus, setMessage |
| 从类 java.lang.Object 继承的方法 |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
public static final int META
MetaMessage 的状态字节(0xFF 或 255),供在 MIDI 文件中使用。它与 SYSTEM_RESET 具有相同的值,用于实时 "MIDI wire" 协议中。
MidiMessage.getStatus(),
常量字段值
| 构造方法详细信息 |
|---|
public MetaMessage()
MetaMessage。在此不设置消息的内容;可随后使用
setMessage 对其进行设置。
protected MetaMessage(byte[] data)
MetaMessage。
data - 包含完整消息的 byte 数组。使用
setMessage 方法可更改消息数据。
setMessage(int, byte[], int)
| 方法详细信息 |
|---|
public void setMessage(int type,
byte[] data,
int length)
throws InvalidMidiDataException
MetaMessage 设置消息参数。由于元消息只允许有一个状态字节值
0xFF,因此在这里不需要对其进行指定。对于所有的元消息,调用
getStatus 都返回
0xFF。
type 参数应该是一个 MetaMessage 中的状态字节后的 byte 有效值。data 参数应包含 MetaMessage 的所有后续字节。换句话说,不将指定 MetaMessage 类型的字节认为是数据字节。
type - 元消息类型(不超过 128)
data - MIDI 消息中的数据字节
length -
data byte 数组中的字节数
InvalidMidiDataException - 如果参数值未指定有效的 MIDI 元消息
InvalidMidiDataException
public int getType()
MetaMessage 的类型。
MetaMessage 类型的整数
public byte[] getData()
MidiMessage.getLength()
public Object clone()
MidiMessage 中的
clone
Cloneable