KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > sound > midi > Instrument


1 /*
2  * @(#)Instrument.java 1.16 04/05/05
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.sound.midi;
9
10 import java.net.URL JavaDoc;
11
12
13
14 /**
15  * An instrument is a sound-synthesis algorithm with certain parameter
16  * settings, usually designed to emulate a specific real-world
17  * musical instrument or to achieve a specific sort of sound effect.
18  * Instruments are typically stored in collections called soundbanks.
19  * Before the instrument can be used to play notes, it must first be loaded
20  * onto a synthesizer, and then it must be selected for use on
21  * one or more channels, via a program-change command. MIDI notes
22  * that are subsequently received on those channels will be played using
23  * the sound of the selected instrument.
24  *
25  * @see Soundbank
26  * @see Soundbank#getInstruments
27  * @see Patch
28  * @see Synthesizer#loadInstrument(Instrument)
29  * @see MidiChannel#programChange(int, int)
30  * @version 1.16, 04/05/05
31  * @author Kara Kytle
32  */

33
34 public abstract class Instrument extends SoundbankResource JavaDoc {
35
36
37     /**
38      * Instrument patch
39      */

40     private final Patch JavaDoc patch;
41
42
43     /**
44      * Constructs a new MIDI instrument from the specified <code>Patch</code>.
45      * When a subsequent request is made to load the
46      * instrument, the sound bank will search its contents for this instrument's <code>Patch</code>,
47      * and the instrument will be loaded into the synthesizer at the
48      * bank and program location indicated by the <code>Patch</code> object.
49      * @param soundbank sound bank containing the instrument
50      * @param patch the patch of this instrument
51      * @param name the name of this instrument
52      * @param dataClass the class used to represent the sample's data.
53      *
54      * @see Synthesizer#loadInstrument(Instrument)
55      */

56     protected Instrument(Soundbank JavaDoc soundbank, Patch JavaDoc patch, String JavaDoc name, Class JavaDoc<?> dataClass) {
57
58     super(soundbank, name, dataClass);
59     this.patch = patch;
60     }
61
62
63     /**
64      * Obtains the <code>Patch</code> object that indicates the bank and program
65      * numbers where this instrument is to be stored in the synthesizer.
66      * @return this instrument's patch
67      */

68     public Patch JavaDoc getPatch() {
69     return patch;
70     }
71 }
72
73
74
Popular Tags