Package javax.sound.midi

Examples of javax.sound.midi.Instrument


            synthesizer.open();
            synthesizer.loadAllInstruments(synthesizer.getDefaultSoundbank());
        } catch (MidiUnavailableException ex) {
            ex.printStackTrace();
        }
        Instrument in[] = synthesizer.getLoadedInstruments();
        String ret[] = new String[in.length];
        for (int x = 0; x < in.length; x++) {
            ret[x] = in[x].getName();
        }
        return ret;
View Full Code Here


            // events directly to the Synthesizer instead.
            Synthesizer synthesizer = MidiSystem.getSynthesizer();
            synthesizer.open();

            synthesizer.loadAllInstruments(synthesizer.getDefaultSoundbank());
            Instrument in[] = synthesizer.getLoadedInstruments();

            synthesizer.loadInstrument(in[70]);
            channel = synthesizer.getChannels()[0];
        } catch (MidiUnavailableException ex) {
            ex.printStackTrace();
View Full Code Here

    public String getDescription() {
        return getName();
    }

    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) {
View Full Code Here

    if (midiChooser==null) {
      log.error("unable to perform test on null midi chooser, NPE will follow");
    }
    try {
      MidiDevice.Info info=midiChooser.getSelectedOutputDevice();
      Instrument instrument=midiChooser.getSelectedInstrument();
      if (info==null && instrument==null) {
        ErrorHandler.handleMessage(MESSAGE_CHOOSE_OUTPUT_FIRST);
        return;
      }
      if (info==null) {
View Full Code Here

    if (midiChooser==null) {
      log.severe("unable to perform test on null midi chooser, NPE will follow");
    }
    try {
      MidiDevice.Info info=midiChooser.getSelectedOutputDevice();
      Instrument instrument=midiChooser.getSelectedInstrument();
      if (info==null && instrument==null) {
        handleMessage(MESSAGE_CHOOSE_OUTPUT_FIRST);
        return;
      }
      if (info==null) {
View Full Code Here

      }
      public SoundbankResource[] getResources() {
        return null;
      }
      public Instrument[] getInstruments() {
        Instrument ins = new Instrument(null, null, null, null)
        {           
          public Object getData() {
            return null;
          }           
        };
View Full Code Here

    }

    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);
View Full Code Here

        if (!isOpen())
            return;

        for (Patch pat: patchList) {
            Instrument ins = soundbank.getInstrument(pat);
            if (ins instanceof ModelInstrument) {
                unloadInstrument(ins);
            }
        }
    }
View Full Code Here

    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;
        }
      }
     
    }
View Full Code Here

    }

    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);
View Full Code Here

TOP

Related Classes of javax.sound.midi.Instrument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.