我正在使用新的 MIDI API为了播放一些 MIDI 音符。但是,我听不到任何声音,也没有抛出任何异常。其代码如下:
//initialising the MidiReceiver
private MidiReceiver midiReceiver;
midiReceiver = new MidiReceiver() {
@Override
public void onSend(byte[] msg, int offset,
int count, long timestamp) throws IOException {
}
};
/*Then in my loop containing note_on or note_off events*/
byte[] buffer = new byte[32];
int numBytes = 0;
int channel = 2; // MIDI channels 1-16 are encoded as 0-15.
// NOTE_STATUS is either 0x90 or 0x80
buffer[numBytes++] = (byte)(NOTE_STATUS + (channel - 1));
buffer[numBytes++] = (byte)noteValue; // the required MIDI pitch
buffer[numBytes++] = (byte)127; // max velocity
int offset = 0;
midiReceiver.send(buffer, offset, numBytes);
我在这里做错了什么?我想这一定是因为onSend
方法为空。如何使用它来让我的应用程序回放 Android 设备中的笔记?
我在中找不到任何指示文档新的 MIDI API 实际上可以让你合成音频,所以,看来你需要自己生成声音。
Maybe 这个图书馆可能有用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)