Midi 音序器异常

发布于 2024-12-18 03:46:19 字数 1107 浏览 5 评论 0原文

我正在尝试以下内容,

 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

I'm trying the following,

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

But, I get the following,

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

二手情话 2024-12-25 03:46:19

嗯,似乎有 Midi 设备,但这些设备不可用,如 MidiUnavailableException 所示。

查看该异常的来源,即您对 MidiSystem.getSequencer() 的调用。在 JavaDoc 在该方法中,您会发现以下内容:

抛出:
MidiUnavailableException - 如果定序器由于资源限制而不可用,或者系统中未安装定序器,或者如果连接为 true,并且没有接收器任何已安装的 MidiDevice 均可使用

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

Well, it seems as if there are Midi devices but those are not available, as indicated by the MidiUnavailableException.

Have a look at the origin of that exception, i.e. your call to MidiSystem.getSequencer(). In the JavaDocon that method you'll find the following:

Throws:
MidiUnavailableException - if the sequencer is not available due to resource restrictions, or no sequencer is installed in the system, or if connected is true, and there is no Receiver available by any installed MidiDevice

Continue from there, i.e. look which condition could cause that exception.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文