问题描述
我将为一个学校项目制作一个小程序,该程序应该能够识别通过MIDI钢琴输入(仅是其中一部分)正在播放的和弦.
I am about to make a little program for a school project that is supposed to recognize the chords that are being played via a MIDI piano input (that's just one part of it).
此刻,我的发展如此之快,以至于每次按下键盘和释放Midi键盘上的每个键,我都会得到一个ShortMessage
类的对象.
At the moment I got so far that for each press and each release of a key on the midi keyboard I get an object of the class ShortMessage
.
我的问题:如何确定按键是否被按下或释放?在每种情况下,按下并释放,静态变量NOTE_OFF
确实包含值128,变量NOTE_ON
包含值144.
My question: How do I figure out if the key has been pressed or released?In each case, press and release, the static variable NOTE_OFF
does contain the value 128, the variable NOTE_ON
the value 144.
我不知道该如何告诉我按键是否被按下或释放.任何的想法?我错过了基本的东西吗?
I don't get how this is supposed to tell me if the key has been pressed or released. Any idea? Am I missing a fundamental thing?
谢谢.
推荐答案
NOTE_ON
和NOTE_OFF
只是常量;您将消息的实际命令值(getCommand()
)与它们进行比较.
NOTE_ON
and NOTE_OFF
are just constants; you compare the message's actual command value (getCommand()
) with them.
请注意,必须将速度(getData2()
)为零的注释打开消息解释为注释关闭消息.
Please note that a note-on message with a velocity (getData2()
) of zero must be interpreted as a note-off message.
这篇关于区分按键和MIDI钢琴输入的释放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!