Save This Page
Home » openjdk-7 » javax.sound » midi » [javadoc | source]
    1   /*
    2    * Copyright 1999-2004 Sun Microsystems, Inc.  All Rights Reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Sun designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Sun in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
   22    * CA 95054 USA or visit www.sun.com if you need additional information or
   23    * have any questions.
   24    */
   25   
   26   package javax.sound.midi;
   27   
   28   import java.net.URL;
   29   
   30   
   31   
   32   /**
   33    * An instrument is a sound-synthesis algorithm with certain parameter
   34    * settings, usually designed to emulate a specific real-world
   35    * musical instrument or to achieve a specific sort of sound effect.
   36    * Instruments are typically stored in collections called soundbanks.
   37    * Before the instrument can be used to play notes, it must first be loaded
   38    * onto a synthesizer, and then it must be selected for use on
   39    * one or more channels, via a program-change command.  MIDI notes
   40    * that are subsequently received on those channels will be played using
   41    * the sound of the selected instrument.
   42    *
   43    * @see Soundbank
   44    * @see Soundbank#getInstruments
   45    * @see Patch
   46    * @see Synthesizer#loadInstrument(Instrument)
   47    * @see MidiChannel#programChange(int, int)
   48    * @author Kara Kytle
   49    */
   50   
   51   public abstract class Instrument extends SoundbankResource {
   52   
   53   
   54       /**
   55        * Instrument patch
   56        */
   57       private final Patch patch;
   58   
   59   
   60       /**
   61        * Constructs a new MIDI instrument from the specified <code>Patch</code>.
   62        * When a subsequent request is made to load the
   63        * instrument, the sound bank will search its contents for this instrument's <code>Patch</code>,
   64        * and the instrument will be loaded into the synthesizer at the
   65        * bank and program location indicated by the <code>Patch</code> object.
   66        * @param soundbank sound bank containing the instrument
   67        * @param patch the patch of this instrument
   68        * @param name the name of this instrument
   69        * @param dataClass the class used to represent the sample's data.
   70        *
   71        * @see Synthesizer#loadInstrument(Instrument)
   72        */
   73       protected Instrument(Soundbank soundbank, Patch patch, String name, Class<?> dataClass) {
   74   
   75           super(soundbank, name, dataClass);
   76           this.patch = patch;
   77       }
   78   
   79   
   80       /**
   81        * Obtains the <code>Patch</code> object that indicates the bank and program
   82        * numbers where this instrument is to be stored in the synthesizer.
   83        * @return this instrument's patch
   84        */
   85       public Patch getPatch() {
   86           return patch;
   87       }
   88   }

Save This Page
Home » openjdk-7 » javax.sound » midi » [javadoc | source]