从MIDI活动到INT的十六进制字节阵列
我正在尝试通过javax.midi
库来检索MIDI文件的节奏。
MidiMessage message = event.getMessage();
if(message instanceof MetaMessage)
MetaMessage mm = (MetaMessage) message;
System.out.println(Arrays.toString(mm.getData()));
}
我期望收到的是三个ex的数组,因为设置的节奏元消息(这种情况,只有3个字节指定了一个miliseconds数量。 这就是MIDI事件返回的方式
0x07 0xA1 0x20
在打印中返回,
[7, -95, 32]
,因此,如果您加入它们,则有500,000毫秒的0x07A120,但是Java首先 它将其解析为十进制,然后我需要获得500,000个数字。我不知道该怎么做,因为首先我需要加入所有十六进制,然后我将拥有这个数字,但我不知道该怎么做。
有人可以帮我吗?
I'm trying to retrieve the tempo of a midi file through the javax.midi
library.
MidiMessage message = event.getMessage();
if(message instanceof MetaMessage)
MetaMessage mm = (MetaMessage) message;
System.out.println(Arrays.toString(mm.getData()));
}
What I am expected to receive is an array of three ex, because the Set Tempo meta message (which is this case, has just 3 bytes specifying a miliseconds amount.
This is how the midi event returns
0x07 0xA1 0x20
So if you join them you have 0x07A120 which is 500,000 ms, but Java returns in the print
[7, -95, 32]
First of all it is parsing it to decimal, and then I need to get this 500,000 number. I don't know how to do it because first I need to join all the hex, and then I will have the number, but I don't know how to do it.
Anyone can help me, please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
metAmessage.getData()
返回一个字节数组,您可以使用arrays.aslist()
将其变成字节列表,这就是为什么打印字节列表的原因。以下是一种从节奏元素中计算出每分钟节奏的节奏的方法。
MSPQ
变量(每季度毫秒)是您寻求的价值。您会在Java找到更多MIDI实用程序。
MetaMessage.getData()
returns a byte array, which you turn into a list of bytes usingArrays.asList()
, that's why you print a list of bytes.Below is a method that compute the tempo in beats per minute from a TEMPO MetaMessage. The
mspq
variable (milliseconds per quarter) is the value you seek.Here you'll find some more Midi utilities in java.
会更简单
would be simpler