Midi Sequencer异常

时间:2011-11-26 06:34:51

标签: java midi

我正在尝试以下内容,

 MidiDevice.Info[] devices = MidiSystem.getMidiDeviceInfo();
        if (devices.length == 0) {
            System.out.println("No MIDI devices found");
        } else {
            for (MidiDevice.Info dev : devices) {
                System.out.println(dev);
            }
        }

        Sequencer player = MidiSystem.getSequencer();
        player.open();

但是,我得到以下内容,

Real Time Sequencer
javax.sound.midi.MidiUnavailableException
at javax.sound.midi.MidiSystem.getDefaultDeviceWrapper(MidiSystem.java:1078)
at javax.sound.midi.MidiSystem.getReceiver(MidiSystem.java:240)
at javax.sound.midi.MidiSystem.getSequencer(MidiSystem.java:442)
at javax.sound.midi.MidiSystem.getSequencer(MidiSystem.java:348)
at MidiPlayTest.play(MidiPlayTest.java:23)
at MidiPlayTest.main(MidiPlayTest.java:56)
Caused by: java.lang.IllegalArgumentException: Requested device not installed
at javax.sound.midi.MidiSystem.getDefaultDevice(MidiSystem.java:1130)
at javax.sound.midi.MidiSystem.getDefaultDeviceWrapper(MidiSystem.java:1076)
... 5 more

1 个答案:

答案 0 :(得分:0)

好吧,似乎有Midi设备但是那些不可用,如MidiUnavailableException所示。

查看该异常的来源,即您对MidiSystem.getSequencer()的来电。在该方法的JavaDoc上,您会找到以下内容:

  

抛出:
      MidiUnavailableException - 如果序列发生器由于资源限制而不可用,或者系统中没有安装音序器,或如果连接是真的,并且没有接收器任何已安装的MidiDevice都可以

从那里继续,即查看哪种情况可能导致该异常。