gpt4 book ai didi

java - Midi 音序器异常

转载 作者:行者123 更新时间:2023-12-01 05:35:24 26 4
gpt4 key购买 nike

我正在尝试以下操作,

 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

最佳答案

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

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

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

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

关于java - Midi 音序器异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8276769/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com