Path: blob/master/src/java.desktop/share/classes/javax/sound/midi/Instrument.java
41159 views
/*1* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.sound.midi;2627/**28* An instrument is a sound-synthesis algorithm with certain parameter settings,29* usually designed to emulate a specific real-world musical instrument or to30* achieve a specific sort of sound effect. Instruments are typically stored in31* collections called soundbanks. Before the instrument can be used to play32* notes, it must first be loaded onto a synthesizer, and then it must be33* selected for use on one or more channels, via a program-change command. MIDI34* notes that are subsequently received on those channels will be played using35* the sound of the selected instrument.36*37* @author Kara Kytle38* @see Soundbank39* @see Soundbank#getInstruments40* @see Patch41* @see Synthesizer#loadInstrument(Instrument)42* @see MidiChannel#programChange(int, int)43*/44public abstract class Instrument extends SoundbankResource {4546/**47* Instrument patch.48*/49private final Patch patch;5051/**52* Constructs a new MIDI instrument from the specified {@code Patch}. When a53* subsequent request is made to load the instrument, the sound bank will54* search its contents for this instrument's {@code Patch}, and the55* instrument will be loaded into the synthesizer at the bank and program56* location indicated by the {@code Patch} object.57*58* @param soundbank sound bank containing the instrument59* @param patch the patch of this instrument60* @param name the name of this instrument61* @param dataClass the class used to represent the sample's data62* @see Synthesizer#loadInstrument(Instrument)63*/64protected Instrument(Soundbank soundbank, Patch patch, String name, Class<?> dataClass) {6566super(soundbank, name, dataClass);67this.patch = patch;68}6970/**71* Obtains the {@code Patch} object that indicates the bank and program72* numbers where this instrument is to be stored in the synthesizer.73*74* @return this instrument's patch75*/76public Patch getPatch() {77return patch;78}79}808182