Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/sound/midi/Instrument.java
38830 views
/*1* Copyright (c) 1999, 2004, 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;2627import java.net.URL;28293031/**32* An instrument is a sound-synthesis algorithm with certain parameter33* settings, usually designed to emulate a specific real-world34* musical instrument or to achieve a specific sort of sound effect.35* Instruments are typically stored in collections called soundbanks.36* Before the instrument can be used to play notes, it must first be loaded37* onto a synthesizer, and then it must be selected for use on38* one or more channels, via a program-change command. MIDI notes39* that are subsequently received on those channels will be played using40* the sound of the selected instrument.41*42* @see Soundbank43* @see Soundbank#getInstruments44* @see Patch45* @see Synthesizer#loadInstrument(Instrument)46* @see MidiChannel#programChange(int, int)47* @author Kara Kytle48*/4950public abstract class Instrument extends SoundbankResource {515253/**54* Instrument patch55*/56private final Patch patch;575859/**60* Constructs a new MIDI instrument from the specified <code>Patch</code>.61* When a subsequent request is made to load the62* instrument, the sound bank will search its contents for this instrument's <code>Patch</code>,63* and the instrument will be loaded into the synthesizer at the64* bank and program location indicated by the <code>Patch</code> object.65* @param soundbank sound bank containing the instrument66* @param patch the patch of this instrument67* @param name the name of this instrument68* @param dataClass the class used to represent the sample's data.69*70* @see Synthesizer#loadInstrument(Instrument)71*/72protected Instrument(Soundbank soundbank, Patch patch, String name, Class<?> dataClass) {7374super(soundbank, name, dataClass);75this.patch = patch;76}777879/**80* Obtains the <code>Patch</code> object that indicates the bank and program81* numbers where this instrument is to be stored in the synthesizer.82* @return this instrument's patch83*/84public Patch getPatch() {85return patch;86}87}888990