很长一段时间以来一直在尝试使用 jFugue 5 将序列发送到 midi 设备:
MusicReceiver device = getDeviceByName("name");
Player player = new Player();
Pattern pattern = new Pattern("A");
device.sendSequence(player.getSequence(pattern));
不能超越"device.sendSequence"上的"Unhandled exception type MidiUnavailableException "。
static MidiDevice.Info getDeviceInfoByName(String name) {
for (MidiDevice.Info info : MidiSystem.getMidiDeviceInfo()) {
if (info.getName().equals(name)) {
return info;
}
}
return null;
}
static MusicReceiver getDeviceByName(String name) {
return new MusicReceiver((MidiDevice) getDeviceInfoByName(name));
}