Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/sound/midi/Patch.java
38830 views
/*1* Copyright (c) 1999, 2002, 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;262728/**29* A <code>Patch</code> object represents a location, on a MIDI30* synthesizer, into which a single instrument is stored (loaded).31* Every <code>Instrument</code> object has its own <code>Patch</code>32* object that specifies the memory location33* into which that instrument should be loaded. The34* location is specified abstractly by a bank index and a program number (not by35* any scheme that directly refers to a specific address or offset in RAM).36* This is a hierarchical indexing scheme: MIDI provides for up to 16384 banks,37* each of which contains up to 128 program locations. For example, a38* minimal sort of synthesizer might have only one bank of instruments, and39* only 32 instruments (programs) in that bank.40* <p>41* To select what instrument should play the notes on a particular MIDI42* channel, two kinds of MIDI message are used that specify a patch location:43* a bank-select command, and a program-change channel command. The Java Sound44* equivalent is the45* {@link MidiChannel#programChange(int, int) programChange(int, int)}46* method of <code>MidiChannel</code>.47*48* @see Instrument49* @see Instrument#getPatch()50* @see MidiChannel#programChange(int, int)51* @see Synthesizer#loadInstruments(Soundbank, Patch[])52* @see Soundbank53* @see Sequence#getPatchList()54*55* @author Kara Kytle56*/5758public class Patch {596061/**62* Bank index63*/64private final int bank;656667/**68* Program change number69*/70private final int program;717273/**74* Constructs a new patch object from the specified bank and program75* numbers.76* @param bank the bank index (in the range from 0 to 16383)77* @param program the program index (in the range from 0 to 127)78*/79public Patch(int bank, int program) {8081this.bank = bank;82this.program = program;83}848586/**87* Returns the number of the bank that contains the instrument88* whose location this <code>Patch</code> specifies.89* @return the bank number, whose range is from 0 to 1638390* @see MidiChannel#programChange(int, int)91*/92public int getBank() {9394return bank;95}969798/**99* Returns the index, within100* a bank, of the instrument whose location this <code>Patch</code> specifies.101* @return the instrument's program number, whose range is from 0 to 127102*103* @see MidiChannel#getProgram104* @see MidiChannel#programChange(int)105* @see MidiChannel#programChange(int, int)106*/107public int getProgram() {108109return program;110}111}112113114