Path: blob/master/src/java.desktop/share/classes/javax/sound/midi/Patch.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* A {@code Patch} object represents a location, on a MIDI synthesizer, into29* which a single instrument is stored (loaded). Every {@code Instrument} object30* has its own {@code Patch} object that specifies the memory location into31* which that instrument should be loaded. The location is specified abstractly32* by a bank index and a program number (not by any scheme that directly refers33* to a specific address or offset in RAM). This is a hierarchical indexing34* scheme: MIDI provides for up to 16384 banks, each of which contains up to 12835* program locations. For example, a minimal sort of synthesizer might have only36* one bank of instruments, and only 32 instruments (programs) in that bank.37* <p>38* To select what instrument should play the notes on a particular MIDI channel,39* two kinds of MIDI message are used that specify a patch location: a40* bank-select command, and a program-change channel command. The Java Sound41* equivalent is the42* {@link MidiChannel#programChange(int, int) programChange(int, int)} method of43* {@code MidiChannel}.44*45* @author Kara Kytle46* @see Instrument47* @see Instrument#getPatch()48* @see MidiChannel#programChange(int, int)49* @see Synthesizer#loadInstruments(Soundbank, Patch[])50* @see Soundbank51* @see Sequence#getPatchList()52*/53public class Patch {5455/**56* Bank index.57*/58private final int bank;5960/**61* Program change number.62*/63private final int program;6465/**66* Constructs a new patch object from the specified bank and program67* numbers.68*69* @param bank the bank index (in the range from 0 to 16383)70* @param program the program index (in the range from 0 to 127)71*/72public Patch(int bank, int program) {73this.bank = bank;74this.program = program;75}7677/**78* Returns the number of the bank that contains the instrument whose79* location this {@code Patch} specifies.80*81* @return the bank number, whose range is from 0 to 1638382* @see MidiChannel#programChange(int, int)83*/84public int getBank() {85return bank;86}8788/**89* Returns the index, within a bank, of the instrument whose location this90* {@code Patch} specifies.91*92* @return the instrument's program number, whose range is from 0 to 12793* @see MidiChannel#getProgram94* @see MidiChannel#programChange(int)95* @see MidiChannel#programChange(int, int)96*/97public int getProgram() {98return program;99}100}101102103