本文整理汇总了Java中javax.sound.midi.Patch类的典型用法代码示例。如果您正苦于以下问题:Java Patch类的具体用法?Java Patch怎么用?Java Patch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Patch类属于javax.sound.midi包,在下文中一共展示了Patch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInstrument
import javax.sound.midi.Patch; //导入依赖的package包/类
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;
}
示例2: newInstrument
import javax.sound.midi.Patch; //导入依赖的package包/类
public static SF2Instrument newInstrument(SF2Soundbank sf2, String name,
Patch patch, SF2Layer... layers) {
/*
* Create SoundFont2 instrument.
*/
SF2Instrument ins = new SF2Instrument(sf2);
ins.setPatch(patch);
ins.setName(name);
sf2.addInstrument(ins);
/*
* Create region for instrument.
*/
for (int i = 0; i < layers.length; i++) {
SF2InstrumentRegion insregion = new SF2InstrumentRegion();
insregion.setLayer(layers[i]);
ins.getRegions().add(insregion);
}
return ins;
}
示例3: getInstrument
import javax.sound.midi.Patch; //导入依赖的package包/类
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;
}
示例4: getInstrument
import javax.sound.midi.Patch; //导入依赖的package包/类
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;
}
示例5: main
import javax.sound.midi.Patch; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("test.src", "."), "ding.sf2");
FileInputStream fis = new FileInputStream(file);
BufferedInputStream bis = new BufferedInputStream(fis);
try
{
InputStream badis = new BadInputStream(bis);
Soundbank sf2 = new SF2SoundbankReader().getSoundbank(badis);
assertTrue(sf2.getInstruments().length == 1);
Patch patch = sf2.getInstruments()[0].getPatch();
assertTrue(patch.getProgram() == 0);
assertTrue(patch.getBank() == 0);
}
finally
{
bis.close();
}
}
示例6: main
import javax.sound.midi.Patch; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// RealTime: Scale/Octave tuning in 1-byte format
int[] msg = {0xf0,0x7f,0x7f,0x08,0x08,0x03,0x7f,0x7f,
5,10,15,20,25,30,35,40,45,50,51,52,
0xf7};
int[] oct = {5,10,15,20,25,30,35,40,45,50,51,52};
byte[] bmsg = new byte[msg.length];
for (int i = 0; i < bmsg.length; i++)
bmsg[i] = (byte)msg[i];
SoftTuning tuning = new SoftTuning(new Patch(8,32),bmsg);
double[] tunings = tuning.getTuning();
for (int i = 0; i < tunings.length; i++)
assertTrue(Math.abs(tunings[i]-(i*100 + (oct[i%12]-64))) < 0.00001);
assertEquals(tuning.getPatch().getProgram(), 32);
assertEquals(tuning.getPatch().getBank(), 8);
}
示例7: main
import javax.sound.midi.Patch; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("test.src", "."), "ding.dls");
FileInputStream fis = new FileInputStream(file);
BufferedInputStream bis = new BufferedInputStream(fis);
try
{
InputStream badis = new BadInputStream(bis);
Soundbank dls = new DLSSoundbankReader().getSoundbank(badis);
assertTrue(dls.getInstruments().length == 1);
Patch patch = dls.getInstruments()[0].getPatch();
assertTrue(patch.getProgram() == 0);
assertTrue(patch.getBank() == 0);
}
finally
{
bis.close();
}
}
示例8: main
import javax.sound.midi.Patch; //导入依赖的package包/类
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();
}
示例9: main
import javax.sound.midi.Patch; //导入依赖的package包/类
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();
}
示例10: main
import javax.sound.midi.Patch; //导入依赖的package包/类
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.loadInstruments(sbk, new Patch[] {ins2.getPatch()});
assertTrue(synth.getLoadedInstruments().length == 1);
}
synth.close();
}
示例11: main
import javax.sound.midi.Patch; //导入依赖的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();
}
示例12: main
import javax.sound.midi.Patch; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
File file = new File(System.getProperty("test.src", "."), "ding.sf2");
FileInputStream fis = new FileInputStream(file);
BufferedInputStream bis = new BufferedInputStream(fis);
try
{
Soundbank sf2 = new SF2SoundbankReader().getSoundbank(bis);
assertTrue(sf2.getInstruments().length == 1);
Patch patch = sf2.getInstruments()[0].getPatch();
assertTrue(patch.getProgram() == 0);
assertTrue(patch.getBank() == 0);
}
finally
{
bis.close();
}
}
示例13: getInstrument
import javax.sound.midi.Patch; //导入依赖的package包/类
@Override
public Instrument getInstrument(Patch patch) {
Instrument ins = getInstrument();
Patch p = ins.getPatch();
if (p.getBank() != patch.getBank())
return null;
if (p.getProgram() != patch.getProgram())
return null;
if (p instanceof ModelPatch && patch instanceof ModelPatch) {
if (((ModelPatch)p).isPercussion()
!= ((ModelPatch)patch).isPercussion()) {
return null;
}
}
return ins;
}
示例14: getInstrument
import javax.sound.midi.Patch; //导入依赖的package包/类
@Override
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;
}
示例15: getInstrument
import javax.sound.midi.Patch; //导入依赖的package包/类
@Override
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;
}