javax.sound.midi.Patch Java Examples
The following examples show how to use
javax.sound.midi.Patch.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoadInstrument.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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(); }
Example #2
Source File: SimpleSoundbank.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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; }
Example #3
Source File: TestGetSoundbankInputStream2.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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(); } }
Example #4
Source File: SF2Soundbank.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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; }
Example #5
Source File: DLSSoundbank.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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; }
Example #6
Source File: EmergencySoundbank.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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; }
Example #7
Source File: NewSoftTuningPatchByteArray.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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); }
Example #8
Source File: TestGetSoundbankInputStream2.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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(); } }
Example #9
Source File: TestGetSoundbankInputStream.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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 { Soundbank dls = new DLSSoundbankReader().getSoundbank(bis); assertTrue(dls.getInstruments().length == 1); Patch patch = dls.getInstruments()[0].getPatch(); assertTrue(patch.getProgram() == 0); assertTrue(patch.getBank() == 0); } finally { bis.close(); } }
Example #10
Source File: UnloadInstrument.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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(); }
Example #11
Source File: UnloadInstruments.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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(); }
Example #12
Source File: LoadAllInstruments.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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.loadAllInstruments(sbk); assertTrue(synth.getLoadedInstruments().length == 2); } synth.close(); }
Example #13
Source File: RemapInstrument.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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(); }
Example #14
Source File: LoadInstrument.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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(); }
Example #15
Source File: LoadInstruments.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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(); }
Example #16
Source File: TestGetSoundbankInputStream.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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(); } }
Example #17
Source File: SF2Soundbank.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #18
Source File: EmergencySoundbank.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #19
Source File: SimpleSoundbank.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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; }
Example #20
Source File: LoadInstruments.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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(); }
Example #21
Source File: NewSoftTuningPatchByteArray.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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); }
Example #22
Source File: TestGetSoundbankInputStream.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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(); } }
Example #23
Source File: TestGetSoundbankInputStream2.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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(); } }
Example #24
Source File: TestGetSoundbankInputStream.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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 { Soundbank dls = new DLSSoundbankReader().getSoundbank(bis); assertTrue(dls.getInstruments().length == 1); Patch patch = dls.getInstruments()[0].getPatch(); assertTrue(patch.getProgram() == 0); assertTrue(patch.getBank() == 0); } finally { bis.close(); } }
Example #25
Source File: UnloadInstrument.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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(); }
Example #26
Source File: LoadAllInstruments.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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.loadAllInstruments(sbk); assertTrue(synth.getLoadedInstruments().length == 2); } synth.close(); }
Example #27
Source File: RemapInstrument.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
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(); }
Example #28
Source File: TestGetSoundbankInputStream2.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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(); } }
Example #29
Source File: SF2Instrument.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public void setPatch(Patch patch) { if (patch instanceof ModelPatch && ((ModelPatch) patch).isPercussion()) { bank = 128; preset = patch.getProgram(); } else { bank = patch.getBank() >> 7; preset = patch.getProgram(); } }
Example #30
Source File: ModelInstrument.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
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); }