Been trying for a long time to send a sequence to a midi device with jFugue 5:
MusicReceiver device = getDeviceByName("name");
Player player = new Player();
Pattern pattern = new Pattern("A");
device.sendSequence(player.getSequence(pattern));
Can't go beyong "Unhandled exception type MidiUnavailableException" on "device.sendSequence".
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));
}
You are trying to cast an instance of
MidiDevice.Info
that you get from yourgetDeviceByInfo
to aMidiDevice
. Replace yourgetDeviceByName
function with the following: