⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dssisynthesizer.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* DSSISynthesizer.java -- DSSI Synthesizer Provider   Copyright (C) 2005 Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package gnu.javax.sound.midi.dssi;import java.util.ArrayList;import java.util.Iterator;import java.util.List;import javax.sound.midi.Instrument;import javax.sound.midi.MidiChannel;import javax.sound.midi.MidiMessage;import javax.sound.midi.MidiUnavailableException;import javax.sound.midi.Patch;import javax.sound.midi.Receiver;import javax.sound.midi.ShortMessage;import javax.sound.midi.Soundbank;import javax.sound.midi.SoundbankResource;import javax.sound.midi.Synthesizer;import javax.sound.midi.Transmitter;import javax.sound.midi.VoiceStatus;// FIXME: This import in only required for gcj it seems.import javax.sound.midi.MidiDevice.Info;/** * DSSI soft-synth support. *  * All DSSI soft-synths are expected to be installed in /usr/lib/dssi. *  * @author Anthony Green (green@redhat.com) * */public class DSSISynthesizer implements Synthesizer{  /**   * The DSSI Instrument class.   *    * @author Anthony Green (green@redhat.com)   *   */  class DSSIInstrument extends Instrument  {    DSSIInstrument (Soundbank soundbank, Patch patch, String name)    {      super (soundbank, patch, name, null);    }        /* @see javax.sound.midi.SoundbankResource#getData()     */    public Object getData()    {      return null;    }  }/**   * DSSISoundbank holds all instruments.   *    * @author Anthony Green (green@redhat.com)   *   */  class DSSISoundbank implements Soundbank  {    private String name;    private String description;    private List instruments = new ArrayList();    private List resources = new ArrayList();    private String vendor;    private String version;        public DSSISoundbank(String name, String description, String vendor, String version)    {      this.name = name;      this.description = description;      this.vendor = vendor;      this.version = version;    }        void add(Instrument instrument)    {      instruments.add(instrument);    }        /* @see javax.sound.midi.Soundbank#getName()     */    public String getName()    {      return name;    }    /* @see javax.sound.midi.Soundbank#getVersion()     */    public String getVersion()    {      return version;    }    /* @see javax.sound.midi.Soundbank#getVendor()     */    public String getVendor()    {      return vendor;    }    /* @see javax.sound.midi.Soundbank#getDescription()     */    public String getDescription()    {      return description;    }    /* @see javax.sound.midi.Soundbank#getResources()     */    public SoundbankResource[] getResources()    {      return (SoundbankResource[])        resources.toArray(new SoundbankResource[resources.size()]);    }    /* @see javax.sound.midi.Soundbank#getInstruments()     */    public Instrument[] getInstruments()    {      return (Instrument[])        instruments.toArray(new Instrument[instruments.size()]);    }    /* @see javax.sound.midi.Soundbank#getInstrument(javax.sound.midi.Patch)     */    public Instrument getInstrument(Patch patch)    {      Iterator itr = instruments.iterator();            while (itr.hasNext())      {        Instrument i = (Instrument) itr.next();        if (i.getPatch().equals(patch))          return i;      }            return null;    }  }/**   * The Receiver class receives all MIDI messages from a connected   * Transmitter.   *    * @author Anthony Green (green@redhat.com)   *   */  class DSSIReceiver implements Receiver  {    /* (non-Javadoc)     * @see javax.sound.midi.Receiver#send(javax.sound.midi.MidiMessage, long)     */    public void send(MidiMessage message, long timeStamp)        throws IllegalStateException    {      if (message instanceof ShortMessage)      {        ShortMessage smessage = (ShortMessage) message;              switch (message.getStatus())        {        case ShortMessage.NOTE_ON:          int velocity = smessage.getData2();          if (velocity > 0)            channels[smessage.getChannel()].noteOn(smessage.getData1(),                                                    smessage.getData2());          else            channels[smessage.getChannel()].noteOff(smessage.getData1());          break;        case ShortMessage.CONTROL_CHANGE:          channels[smessage.getChannel()].controlChange(smessage.getData1(),                                                        smessage.getData2());          break;        default:          System.out.println ("Unhandled message: " + message.getStatus());          break;        }      }    }    /* (non-Javadoc)     * @see javax.sound.midi.Receiver#close()     */    public void close()    {      // TODO Auto-generated method stub    }  }  static native void noteOn_(long handle, int channel, int noteNumber, int velocity);    static native void noteOff_(long handle, int channel, int noteNumber, int velocity);    static native void setPolyPressure_(long handle, int channel, int noteNumber, int pressure);  static native int getPolyPressure_(long handle, int channel, int noteNumber);  static native void controlChange_(long handle, int channel, int control, int value);  static native void open_(long handle);  static native void close_(long handle);  static native String getProgramName_(long handle, int index);  static native int getProgramBank_(long handle, int index);  static native int getProgramProgram_(long handle, int index);  static native void selectProgram_(long handle, int bank, int program);        /**   * @author Anthony Green (green@redhat.com)   *   */  public class DSSIMidiChannel implements MidiChannel  {    int channel = 0;        /**     * Default contructor.     */    public DSSIMidiChannel(int channel)    {      super();      this.channel = channel;    }    /* (non-Javadoc)     * @see javax.sound.midi.MidiChannel#noteOn(int, int)     */    public void noteOn(int noteNumber, int velocity)    {      noteOn_(sohandle, channel, noteNumber, velocity);    }    /* (non-Javadoc)     * @see javax.sound.midi.MidiChannel#noteOff(int, int)     */    public void noteOff(int noteNumber, int velocity)    {      noteOff_(sohandle, channel, noteNumber, velocity);    }    /* (non-Javadoc)     * @see javax.sound.midi.MidiChannel#noteOff(int)     */    public void noteOff(int noteNumber)    {      noteOff_(sohandle, channel, noteNumber, -1);    }    /* (non-Javadoc)     * @see javax.sound.midi.MidiChannel#setPolyPressure(int, int)     */    public void setPolyPressure(int noteNumber, int pressure)    {      setPolyPressure_(sohandle, channel, noteNumber, pressure);    }    /* (non-Javadoc)     * @see javax.sound.midi.MidiChannel#getPolyPressure(int)     */    public int getPolyPressure(int noteNumber)    {      return getPolyPressure_(sohandle, channel, noteNumber);    }    /* (non-Javadoc)     * @see javax.sound.midi.MidiChannel#setChannelPressure(int)     */    public void setChannelPressure(int pressure)    {      // TODO Auto-generated method stub    }    /* (non-Javadoc)     * @see javax.sound.midi.MidiChannel#getChannelPressure()     */    public int getChannelPressure()    {      // TODO Auto-generated method stub      return 0;    }    /* @see javax.sound.midi.MidiChannel#controlChange(int, int)  */    public void controlChange(int controller, int value)    {      controlChange_(sohandle, channel, controller, value);    }    /* (non-Javadoc)     * @see javax.sound.midi.MidiChannel#getController(int)     */    public int getController(int controller)    {      // TODO Auto-generated method stub      return 0;    }    /* (non-Javadoc)     * @see javax.sound.midi.MidiChannel#programChange(int)     */    public void programChange(int program)    {      // TODO Auto-generated method stub    }    /* (non-Javadoc)     * @see javax.sound.midi.MidiChannel#programChange(int, int)     */    public void programChange(int bank, int program)    {      // TODO Auto-generated method stub    }    /* (non-Javadoc)     * @see javax.sound.midi.MidiChannel#getProgram()     */    public int getProgram()    {      // TODO Auto-generated method stub      return 0;    }    /* (non-Javadoc)     * @see javax.sound.midi.MidiChannel#setPitchBend(int)     */    public void setPitchBend(int bend)    {      // TODO Auto-generated method stub    }    /* (non-Javadoc)     * @see javax.sound.midi.MidiChannel#getPitchBend()     */    public int getPitchBend()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -