use of javax.sound.midi.Patch in project jdk8u_jdk by JetBrains.
the class UnloadInstrument 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.unloadInstrument(ins2);
assertTrue(synth.getLoadedInstruments().length == 0);
}
synth.close();
}
use of javax.sound.midi.Patch in project jdk8u_jdk by JetBrains.
the class UnloadInstruments 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.unloadInstruments(sbk, new Patch[] { ins2.getPatch() });
assertTrue(synth.getLoadedInstruments().length == 0);
}
synth.close();
}
use of javax.sound.midi.Patch in project jdk8u_jdk by JetBrains.
the class NewSoftTuningPatch method main.
public static void main(String[] args) throws Exception {
SoftTuning tuning = new SoftTuning(new Patch(8, 32));
assertEquals(tuning.getPatch().getProgram(), 32);
assertEquals(tuning.getPatch().getBank(), 8);
}
use of javax.sound.midi.Patch in project jdk8u_jdk by JetBrains.
the class SoftSynthesizer method loadInstruments.
public boolean loadInstruments(Soundbank soundbank, Patch[] patchList) {
List<ModelInstrument> instruments = new ArrayList<ModelInstrument>();
for (Patch patch : patchList) {
Instrument ins = soundbank.getInstrument(patch);
if (ins == null || !(ins instanceof ModelInstrument)) {
throw new IllegalArgumentException("Unsupported instrument: " + ins);
}
instruments.add((ModelInstrument) ins);
}
return loadInstruments(instruments);
}
use of javax.sound.midi.Patch in project jdk8u_jdk by JetBrains.
the class ModelInstrument method getPatchAlias.
// Get General MIDI 2 Alias patch for this instrument.
public final Patch getPatchAlias() {
Patch patch = getPatch();
int program = patch.getProgram();
int bank = patch.getBank();
if (bank != 0)
return patch;
boolean percussion = false;
if (getPatch() instanceof ModelPatch)
percussion = ((ModelPatch) getPatch()).isPercussion();
if (percussion)
return new Patch(0x78 << 7, program);
else
return new Patch(0x79 << 7, program);
}
Aggregations