jdk/src/java.desktop/share/classes/javax/sound/midi/Instrument.java
changeset 26037 508779ce6619
parent 26003 d630c97424bd
parent 25859 3317bb8137f4
equal deleted inserted replaced
25992:e9b05e933ddd 26037:508779ce6619
     1 /*
     1 /*
     2  * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package javax.sound.midi;
    26 package javax.sound.midi;
    27 
    27 
    28 import java.net.URL;
       
    29 
       
    30 
       
    31 
       
    32 /**
    28 /**
    33  * An instrument is a sound-synthesis algorithm with certain parameter
    29  * An instrument is a sound-synthesis algorithm with certain parameter settings,
    34  * settings, usually designed to emulate a specific real-world
    30  * usually designed to emulate a specific real-world musical instrument or to
    35  * musical instrument or to achieve a specific sort of sound effect.
    31  * achieve a specific sort of sound effect. Instruments are typically stored in
    36  * Instruments are typically stored in collections called soundbanks.
    32  * collections called soundbanks. Before the instrument can be used to play
    37  * Before the instrument can be used to play notes, it must first be loaded
    33  * notes, it must first be loaded onto a synthesizer, and then it must be
    38  * onto a synthesizer, and then it must be selected for use on
    34  * selected for use on one or more channels, via a program-change command. MIDI
    39  * one or more channels, via a program-change command.  MIDI notes
    35  * notes that are subsequently received on those channels will be played using
    40  * that are subsequently received on those channels will be played using
       
    41  * the sound of the selected instrument.
    36  * the sound of the selected instrument.
    42  *
    37  *
       
    38  * @author Kara Kytle
    43  * @see Soundbank
    39  * @see Soundbank
    44  * @see Soundbank#getInstruments
    40  * @see Soundbank#getInstruments
    45  * @see Patch
    41  * @see Patch
    46  * @see Synthesizer#loadInstrument(Instrument)
    42  * @see Synthesizer#loadInstrument(Instrument)
    47  * @see MidiChannel#programChange(int, int)
    43  * @see MidiChannel#programChange(int, int)
    48  * @author Kara Kytle
       
    49  */
    44  */
    50 
       
    51 public abstract class Instrument extends SoundbankResource {
    45 public abstract class Instrument extends SoundbankResource {
    52 
    46 
    53 
       
    54     /**
    47     /**
    55      * Instrument patch
    48      * Instrument patch.
    56      */
    49      */
    57     private final Patch patch;
    50     private final Patch patch;
    58 
    51 
    59 
       
    60     /**
    52     /**
    61      * Constructs a new MIDI instrument from the specified <code>Patch</code>.
    53      * Constructs a new MIDI instrument from the specified {@code Patch}. When a
    62      * When a subsequent request is made to load the
    54      * subsequent request is made to load the instrument, the sound bank will
    63      * instrument, the sound bank will search its contents for this instrument's <code>Patch</code>,
    55      * search its contents for this instrument's {@code Patch}, and the
    64      * and the instrument will be loaded into the synthesizer at the
    56      * instrument will be loaded into the synthesizer at the bank and program
    65      * bank and program location indicated by the <code>Patch</code> object.
    57      * location indicated by the {@code Patch} 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      *
    58      *
       
    59      * @param  soundbank sound bank containing the instrument
       
    60      * @param  patch the patch of this instrument
       
    61      * @param  name the name of this instrument
       
    62      * @param  dataClass the class used to represent the sample's data
    71      * @see Synthesizer#loadInstrument(Instrument)
    63      * @see Synthesizer#loadInstrument(Instrument)
    72      */
    64      */
    73     protected Instrument(Soundbank soundbank, Patch patch, String name, Class<?> dataClass) {
    65     protected Instrument(Soundbank soundbank, Patch patch, String name, Class<?> dataClass) {
    74 
    66 
    75         super(soundbank, name, dataClass);
    67         super(soundbank, name, dataClass);
    76         this.patch = patch;
    68         this.patch = patch;
    77     }
    69     }
    78 
    70 
    79 
       
    80     /**
    71     /**
    81      * Obtains the <code>Patch</code> object that indicates the bank and program
    72      * Obtains the {@code Patch} object that indicates the bank and program
    82      * numbers where this instrument is to be stored in the synthesizer.
    73      * numbers where this instrument is to be stored in the synthesizer.
       
    74      *
    83      * @return this instrument's patch
    75      * @return this instrument's patch
    84      */
    76      */
    85     public Patch getPatch() {
    77     public Patch getPatch() {
    86         return patch;
    78         return patch;
    87     }
    79     }