Java Code Examples for javax.sound.midi.Soundbank#getInstrument()

The following examples show how to use javax.sound.midi.Soundbank#getInstrument() . 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: RemapInstrument.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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 2
Source File: RemapInstrument.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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 3
Source File: RemapInstrument.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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 4
Source File: RemapInstrument.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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 5
Source File: SoftSynthesizer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example 6
Source File: SoftSynthesizer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@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);
        }
    }
}
 
Example 7
Source File: SoftSynthesizer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example 8
Source File: SoftSynthesizer.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@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);
        }
    }
}
 
Example 9
Source File: SoftSynthesizer.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 10
Source File: SoftSynthesizer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example 11
Source File: SoftSynthesizer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example 12
Source File: SoftSynthesizer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 13
Source File: SoftSynthesizer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 14
Source File: SoftSynthesizer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 15
Source File: SoftSynthesizer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 16
Source File: SoftSynthesizer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example 17
Source File: SoftSynthesizer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 18
Source File: SoftSynthesizer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}
 
Example 19
Source File: SoftSynthesizer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example 20
Source File: SoftSynthesizer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
        }
    }
}