本文介绍了JFugue 5外部Midi设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

长时间尝试使用jFugue 5将序列发送到midi设备:

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));

不能在"device.sendSequence" 上的未处理的异常类型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));
      }

推荐答案

您正试图将从getDeviceByInfo获得的MidiDevice.Info实例转换为MidiDevice.将getDeviceByName函数替换为以下内容:

You are trying to cast an instance of MidiDevice.Info that you get from your getDeviceByInfo to a MidiDevice. Replace your getDeviceByName function with the following:

static MusicReceiver getDeviceByName(String name)
        throws MidiUnavailableException {
    MidiDevice.Info info = getDeviceInfoByName(name);
    return new MusicReceiver(MidiSystem.getMidiDevice(info));
}

这篇关于JFugue 5外部Midi设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 15:35