我正在使用new MIDI API来播放一些MIDI音符。但是,我无法听到任何声音,也没有发生任何异常。代码相同如下:Android 6.0+:没有声音使用新的MIDI API
//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设备中播放音符?
那么,你的'onSend'函数看起来是空的。你期望什么是空功能呢? –
我怀疑是一样的。您能否告诉我如何使用该功能来开始回放音符?另外,我会编辑包括这一点的问题。 – androidnoob
您链接到的页面显示如何将MIDI发送到某个设备。 –