本文整理汇总了Java中javax.sound.midi.Soundbank.getInstrument方法的典型用法代码示例。如果您正苦于以下问题:Java Soundbank.getInstrument方法的具体用法?Java Soundbank.getInstrument怎么用?Java Soundbank.getInstrument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sound.midi.Soundbank
的用法示例。
在下文中一共展示了Soundbank.getInstrument方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import javax.sound.midi.Soundbank; //导入方法依赖的package包/类
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();
}
示例2: loadInstruments
import javax.sound.midi.Soundbank; //导入方法依赖的package包/类
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);
}
示例3: unloadInstruments
import javax.sound.midi.Soundbank; //导入方法依赖的package包/类
public void unloadInstruments(Soundbank soundbank, Patch[] patchList) {
if (soundbank == null || !isSoundbankSupported(soundbank))
throw new IllegalArgumentException("Unsupported soundbank: " + soundbank);
if (!isOpen())
return;
for (Patch pat: patchList) {
Instrument ins = soundbank.getInstrument(pat);
if (ins instanceof ModelInstrument) {
unloadInstrument(ins);
}
}
}
示例4: loadInstruments
import javax.sound.midi.Soundbank; //导入方法依赖的package包/类
@Override
public boolean loadInstruments(Soundbank soundbank, Patch[] patchList) {
List<ModelInstrument> instruments = new ArrayList<>();
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);
}
示例5: unloadInstruments
import javax.sound.midi.Soundbank; //导入方法依赖的package包/类
@Override
public void unloadInstruments(Soundbank soundbank, Patch[] patchList) {
if (soundbank == null || !isSoundbankSupported(soundbank))
throw new IllegalArgumentException("Unsupported soundbank: " + soundbank);
if (!isOpen())
return;
for (Patch pat: patchList) {
Instrument ins = soundbank.getInstrument(pat);
if (ins instanceof ModelInstrument) {
unloadInstrument(ins);
}
}
}