use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.
the class LoadInstrument method main.
public static void main(String[] args) throws Exception {
AudioSynthesizer synth = new SoftSynthesizer();
synth.openStream(null, null);
Soundbank defsbk = synth.getDefaultSoundbank();
if (defsbk != null) {
synth.unloadAllInstruments(defsbk);
SimpleSoundbank sbk = new SimpleSoundbank();
SimpleInstrument ins = new SimpleInstrument();
ins.setPatch(new Patch(0, 1));
sbk.addInstrument(ins);
SimpleInstrument ins2 = new SimpleInstrument();
ins2.setPatch(new Patch(0, 2));
sbk.addInstrument(ins2);
synth.loadInstrument(ins2);
assertTrue(synth.getLoadedInstruments().length == 1);
}
synth.close();
}
use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.
the class RemapInstrument method main.
public static void main(String[] args) throws Exception {
AudioSynthesizer synth = new SoftSynthesizer();
synth.openStream(null, null);
Soundbank defsbk = synth.getDefaultSoundbank();
if (defsbk != null) {
Instrument ins3 = defsbk.getInstrument(new Patch(0, 3));
Instrument ins10 = defsbk.getInstrument(new Patch(0, 10));
assertTrue(synth.remapInstrument(ins3, ins10));
Instrument[] loaded = synth.getLoadedInstruments();
for (int i = 0; i < loaded.length; i++) {
if (loaded[i].getPatch().getBank() == ins3.getPatch().getBank())
if (loaded[i].getPatch().getProgram() == ins3.getPatch().getProgram()) {
assertEquals(loaded[i].getName(), ins10.getName());
break;
}
}
}
synth.close();
}
use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.
the class IsSoundbankSupported method main.
public static void main(String[] args) throws Exception {
AudioSynthesizer synth = new SoftSynthesizer();
synth.openStream(null, null);
SimpleSoundbank sbk = new SimpleSoundbank();
SimpleInstrument ins = new SimpleInstrument();
sbk.addInstrument(ins);
assertTrue(synth.isSoundbankSupported(sbk));
Soundbank dummysbk = new Soundbank() {
public String getName() {
return null;
}
public String getVersion() {
return null;
}
public String getVendor() {
return null;
}
public String getDescription() {
return null;
}
public SoundbankResource[] getResources() {
return null;
}
public Instrument[] getInstruments() {
Instrument ins = new Instrument(null, null, null, null) {
public Object getData() {
return null;
}
};
return new Instrument[] { ins };
}
public Instrument getInstrument(Patch patch) {
return null;
}
};
assertTrue(!synth.isSoundbankSupported(dummysbk));
synth.close();
}
use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.
the class GetLoadedInstruments2 method main.
public static void main(String[] args) throws Exception {
AudioSynthesizer synth = new SoftSynthesizer();
synth.openStream(null, null);
Soundbank defsbk = synth.getDefaultSoundbank();
if (defsbk != null) {
assertTrue(defsbk.getInstruments().length == synth.getLoadedInstruments().length);
}
synth.close();
}
use of javax.sound.midi.Soundbank in project jdk8u_jdk by JetBrains.
the class GetAvailableInstruments method main.
public static void main(String[] args) throws Exception {
AudioSynthesizer synth = new SoftSynthesizer();
synth.openStream(null, null);
Soundbank defsbk = synth.getDefaultSoundbank();
if (defsbk != null) {
assertTrue(defsbk.getInstruments().length == synth.getAvailableInstruments().length);
}
synth.close();
}
Aggregations