Java Code Examples for javax.sound.midi.Instrument#getPatch()
The following examples show how to use
javax.sound.midi.Instrument#getPatch() .
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: ModelAbstractOscillator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@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; }
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: SF2Soundbank.java From openjdk-jdk8u-backup 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 4
Source File: SimpleSoundbank.java From jdk8u-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: SoftSynthesizer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public boolean remapInstrument(Instrument from, Instrument to) { if (from == null) throw new NullPointerException(); if (to == null) throw new NullPointerException(); if (!(from instanceof ModelInstrument)) { throw new IllegalArgumentException("Unsupported instrument: " + from.toString()); } if (!(to instanceof ModelInstrument)) { throw new IllegalArgumentException("Unsupported instrument: " + to.toString()); } if (!isOpen()) return false; synchronized (control_mutex) { if (!loadedlist.containsValue(to)) throw new IllegalArgumentException("Instrument to is not loaded."); unloadInstrument(from); ModelMappedInstrument mfrom = new ModelMappedInstrument( (ModelInstrument)to, from.getPatch()); return loadInstrument(mfrom); } }
Example 6
Source File: DLSSoundbank.java From jdk8u60 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 7
Source File: GervillSoundbankFactory.java From tuxguitar with GNU Lesser General Public License v2.1 | 6 votes |
private Instrument getDefaultInstrument(TGContext context, GervillProgram program) throws Exception { synchronized (GervillProcessorFactory.class) { if( defaultInstruments == null ) { defaultInstruments = new Instrument[129][128]; Soundbank soundbank = null; String soundbankPath = new GervillSettings(context).getSoundbankPath(); if( soundbankPath != null && soundbankPath.length() > 0 ) { soundbank = this.createSoundbank(context, soundbankPath); } if( soundbank == null ) { soundbank = EmergencySoundbank.createSoundbank(); } if( soundbank != null ) { Instrument[] instruments = soundbank.getInstruments(); for(Instrument instrument : instruments) { ModelPatch patch = (ModelPatch) instrument.getPatch(); if( patch.getProgram() < 128 && patch.getBank() < 128 ) { defaultInstruments[patch.isPercussion() ? 128 : patch.getBank()][patch.getProgram()] = instrument; } } } } } return defaultInstruments[program.getBank()][program.getProgram()]; }
Example 8
Source File: SoftSynthesizer.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public boolean remapInstrument(Instrument from, Instrument to) { if (from == null) throw new NullPointerException(); if (to == null) throw new NullPointerException(); if (!(from instanceof ModelInstrument)) { throw new IllegalArgumentException("Unsupported instrument: " + from.toString()); } if (!(to instanceof ModelInstrument)) { throw new IllegalArgumentException("Unsupported instrument: " + to.toString()); } if (!isOpen()) return false; synchronized (control_mutex) { if (!loadedlist.containsValue(to)) throw new IllegalArgumentException("Instrument to is not loaded."); unloadInstrument(from); ModelMappedInstrument mfrom = new ModelMappedInstrument( (ModelInstrument)to, from.getPatch()); return loadInstrument(mfrom); } }
Example 9
Source File: SF2Soundbank.java From jdk8u-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 10
Source File: SoftSynthesizer.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public boolean remapInstrument(Instrument from, Instrument to) { if (from == null) throw new NullPointerException(); if (to == null) throw new NullPointerException(); if (!(from instanceof ModelInstrument)) { throw new IllegalArgumentException("Unsupported instrument: " + from.toString()); } if (!(to instanceof ModelInstrument)) { throw new IllegalArgumentException("Unsupported instrument: " + to.toString()); } if (!isOpen()) return false; synchronized (control_mutex) { if (!loadedlist.containsValue(to)) throw new IllegalArgumentException("Instrument to is not loaded."); unloadInstrument(from); ModelMappedInstrument mfrom = new ModelMappedInstrument( (ModelInstrument)to, from.getPatch()); return loadInstrument(mfrom); } }
Example 11
Source File: DLSSoundbank.java From Bytecoder with Apache License 2.0 | 6 votes |
@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; }
Example 12
Source File: ModelInstrumentComparator.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public int compare(Instrument arg0, Instrument arg1) { Patch p0 = arg0.getPatch(); Patch p1 = arg1.getPatch(); int a = p0.getBank() * 128 + p0.getProgram(); int b = p1.getBank() * 128 + p1.getProgram(); if (p0 instanceof ModelPatch) { a += ((ModelPatch)p0).isPercussion() ? 2097152 : 0; } if (p1 instanceof ModelPatch) { b += ((ModelPatch)p1).isPercussion() ? 2097152 : 0; } return a - b; }
Example 13
Source File: ModelInstrumentComparator.java From Bytecoder with Apache License 2.0 | 5 votes |
@Override public int compare(Instrument arg0, Instrument arg1) { Patch p0 = arg0.getPatch(); Patch p1 = arg1.getPatch(); int a = p0.getBank() * 128 + p0.getProgram(); int b = p1.getBank() * 128 + p1.getProgram(); if (p0 instanceof ModelPatch) { a += ((ModelPatch)p0).isPercussion() ? 2097152 : 0; } if (p1 instanceof ModelPatch) { b += ((ModelPatch)p1).isPercussion() ? 2097152 : 0; } return a - b; }
Example 14
Source File: ModelAbstractOscillator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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; }
Example 15
Source File: ModelInstrumentComparator.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public int compare(Instrument arg0, Instrument arg1) { Patch p0 = arg0.getPatch(); Patch p1 = arg1.getPatch(); int a = p0.getBank() * 128 + p0.getProgram(); int b = p1.getBank() * 128 + p1.getProgram(); if (p0 instanceof ModelPatch) { a += ((ModelPatch)p0).isPercussion() ? 2097152 : 0; } if (p1 instanceof ModelPatch) { b += ((ModelPatch)p1).isPercussion() ? 2097152 : 0; } return a - b; }
Example 16
Source File: ModelAbstractOscillator.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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; }
Example 17
Source File: ModelAbstractOscillator.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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; }
Example 18
Source File: ModelInstrumentComparator.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public int compare(Instrument arg0, Instrument arg1) { Patch p0 = arg0.getPatch(); Patch p1 = arg1.getPatch(); int a = p0.getBank() * 128 + p0.getProgram(); int b = p1.getBank() * 128 + p1.getProgram(); if (p0 instanceof ModelPatch) { a += ((ModelPatch)p0).isPercussion() ? 2097152 : 0; } if (p1 instanceof ModelPatch) { b += ((ModelPatch)p1).isPercussion() ? 2097152 : 0; } return a - b; }
Example 19
Source File: ModelInstrumentComparator.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public int compare(Instrument arg0, Instrument arg1) { Patch p0 = arg0.getPatch(); Patch p1 = arg1.getPatch(); int a = p0.getBank() * 128 + p0.getProgram(); int b = p1.getBank() * 128 + p1.getProgram(); if (p0 instanceof ModelPatch) { a += ((ModelPatch)p0).isPercussion() ? 2097152 : 0; } if (p1 instanceof ModelPatch) { b += ((ModelPatch)p1).isPercussion() ? 2097152 : 0; } return a - b; }
Example 20
Source File: ModelInstrumentComparator.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public int compare(Instrument arg0, Instrument arg1) { Patch p0 = arg0.getPatch(); Patch p1 = arg1.getPatch(); int a = p0.getBank() * 128 + p0.getProgram(); int b = p1.getBank() * 128 + p1.getProgram(); if (p0 instanceof ModelPatch) { a += ((ModelPatch)p0).isPercussion() ? 2097152 : 0; } if (p1 instanceof ModelPatch) { b += ((ModelPatch)p1).isPercussion() ? 2097152 : 0; } return a - b; }