use of javax.sound.midi.Instrument in project jdk8u_jdk by JetBrains.
the class SimpleSoundbank method getInstrument.
public Instrument getInstrument(Patch patch) {
int program = patch.getProgram();
int bank = patch.getBank();
boolean percussion = false;
if (patch instanceof ModelPatch)
percussion = ((ModelPatch) patch).isPercussion();
for (Instrument instrument : instruments) {
Patch patch2 = instrument.getPatch();
int program2 = patch2.getProgram();
int bank2 = patch2.getBank();
if (program == program2 && bank == bank2) {
boolean percussion2 = false;
if (patch2 instanceof ModelPatch)
percussion2 = ((ModelPatch) patch2).isPercussion();
if (percussion == percussion2)
return instrument;
}
}
return null;
}
use of javax.sound.midi.Instrument in project jdk8u_jdk by JetBrains.
the class SoftSynthesizer method getAvailableInstruments.
public Instrument[] getAvailableInstruments() {
Soundbank defsbk = getDefaultSoundbank();
if (defsbk == null)
return new Instrument[0];
Instrument[] inslist_array = defsbk.getInstruments();
Arrays.sort(inslist_array, new ModelInstrumentComparator());
return inslist_array;
}
use of javax.sound.midi.Instrument in project jdk8u_jdk by JetBrains.
the class DLSSoundbank method getInstrument.
public Instrument getInstrument(Patch patch) {
int program = patch.getProgram();
int bank = patch.getBank();
boolean percussion = false;
if (patch instanceof ModelPatch)
percussion = ((ModelPatch) patch).isPercussion();
for (Instrument instrument : instruments) {
Patch patch2 = instrument.getPatch();
int program2 = patch2.getProgram();
int bank2 = patch2.getBank();
if (program == program2 && bank == bank2) {
boolean percussion2 = false;
if (patch2 instanceof ModelPatch)
percussion2 = ((ModelPatch) patch2).isPercussion();
if (percussion == percussion2)
return instrument;
}
}
return null;
}
use of javax.sound.midi.Instrument 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.Instrument 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();
}
Aggregations