JRE的较新版本不加载音库,但旧版本不 [英] Newer version of JRE doesn't load soundbank but older version does
问题描述
我有以下的code,它会尝试加载音库。我和JRE 03年6月1日和43年1月6日测试在Windows 7中的code。老版本的JRE(03年6月1日)的正常工作,但新版本中会抛出异常。这是怎么回事?
I have the following code that tries to load a soundbank. I've tested the code on Windows 7 with JRE 1.6.03 and 1.6.43. The old version of the JRE (1.6.03) works fine but the new version throws an exception. What's going on?
public Main() {
try {
Synthesizer synth = MidiSystem.getSynthesizer();
synth.open();
BufferedInputStream soundBankStream = new BufferedInputStream(
getClass().getClassLoader().getResourceAsStream(
"soundbank.gm"));
synth.loadAllInstruments(MidiSystem.getSoundbank(soundBankStream));
} catch (MidiUnavailableException e) {
e.printStackTrace();
} catch (InvalidMidiDataException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
F:\>java -version
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_03-b05, mixed mode)
F:\>java -jar Test2.jar
F:\>"C:\Program Files\Java\jre6\bin\java.exe" -version
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)
F:\>"C:\Program Files\Java\jre6\bin\java.exe" -jar Test2.jar
javax.sound.midi.InvalidMidiDataException: cannot get soundbank from stream
at javax.sound.midi.MidiSystem.getSoundbank(Unknown Source)
at com.gulshansingh.test.Main.<init>(Main.java:24)
at com.gulshansingh.test.Main.main(Main.java:14)
您可以从这里下载的音库:<一href=\"http://www.oracle.com/technetwork/java/soundbanks-135798.html\">http://www.oracle.com/technetwork/java/soundbanks-135798.html
You can download the soundbanks from here: http://www.oracle.com/technetwork/java/soundbanks-135798.html
推荐答案
我一直有同样的问题,从我发现,JAVA的最新版本(1.7+),通用汽车音库不再支持
I have been having the same problem, and from what I have found, the latest versions of java (1.7+), the GM soundbanks are no longer supported
的http://www.oracle.com/technetwork/java/javase/compatibility-417013.html#incompatibilities
在Java Sound包的软件合成实现已被替换的开源版本。由于置换,其特点如下只好作罢:
GM音库的支持,
RMF文件播放的支持,
在Linux平台上OSS(开放声音系统)的支持。
新合成的实施支持DLS和音色库(SF2)格式的音库。
The software synthesizer implementation in the Java Sound package has been replaced with an open sourced version. Due to the replacement, the following features were dropped: GM soundbank support, RMF file playback support, OSS (Open Sound System) support on the Linux platform. The new synthesizer implementation supports soundbanks in DLS and SoundFont (SF2) formats.
,因为它说,它支持DLS和SF2 Soundbank中的格式(我与你在做什么,试着和它的工作)。看看在互联网这些文件,如在这里:
http://www.ronimusic.com/smp_ios_dls_files.htm
As it says, it supports the DLS and SF2 Soundbank formats (which I tried with what you were doing and it worked). Have a look around on the internet for these files such as here: http://www.ronimusic.com/smp_ios_dls_files.htm
这篇关于JRE的较新版本不加载音库,但旧版本不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!