0N/A/*
2362N/A * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.sound.midi;
0N/A
0N/A
0N/A/**
0N/A * A <code>Patch</code> object represents a location, on a MIDI
0N/A * synthesizer, into which a single instrument is stored (loaded).
0N/A * Every <code>Instrument</code> object has its own <code>Patch</code>
0N/A * object that specifies the memory location
0N/A * into which that instrument should be loaded. The
0N/A * location is specified abstractly by a bank index and a program number (not by
0N/A * any scheme that directly refers to a specific address or offset in RAM).
0N/A * This is a hierarchical indexing scheme: MIDI provides for up to 16384 banks,
0N/A * each of which contains up to 128 program locations. For example, a
0N/A * minimal sort of synthesizer might have only one bank of instruments, and
0N/A * only 32 instruments (programs) in that bank.
0N/A * <p>
0N/A * To select what instrument should play the notes on a particular MIDI
0N/A * channel, two kinds of MIDI message are used that specify a patch location:
0N/A * a bank-select command, and a program-change channel command. The Java Sound
0N/A * equivalent is the
0N/A * {@link MidiChannel#programChange(int, int) programChange(int, int)}
0N/A * method of <code>MidiChannel</code>.
0N/A *
0N/A * @see Instrument
0N/A * @see Instrument#getPatch()
0N/A * @see MidiChannel#programChange(int, int)
0N/A * @see Synthesizer#loadInstruments(Soundbank, Patch[])
0N/A * @see Soundbank
0N/A * @see Sequence#getPatchList()
0N/A *
0N/A * @author Kara Kytle
0N/A */
0N/A
0N/Apublic class Patch {
0N/A
0N/A
0N/A /**
0N/A * Bank index
0N/A */
0N/A private final int bank;
0N/A
0N/A
0N/A /**
0N/A * Program change number
0N/A */
0N/A private final int program;
0N/A
0N/A
0N/A /**
0N/A * Constructs a new patch object from the specified bank and program
0N/A * numbers.
0N/A * @param bank the bank index (in the range from 0 to 16383)
0N/A * @param program the program index (in the range from 0 to 127)
0N/A */
0N/A public Patch(int bank, int program) {
0N/A
0N/A this.bank = bank;
0N/A this.program = program;
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Returns the number of the bank that contains the instrument
0N/A * whose location this <code>Patch</code> specifies.
0N/A * @return the bank number, whose range is from 0 to 16383
0N/A * @see MidiChannel#programChange(int, int)
0N/A */
0N/A public int getBank() {
0N/A
0N/A return bank;
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Returns the index, within
0N/A * a bank, of the instrument whose location this <code>Patch</code> specifies.
0N/A * @return the instrument's program number, whose range is from 0 to 127
0N/A *
0N/A * @see MidiChannel#getProgram
0N/A * @see MidiChannel#programChange(int)
0N/A * @see MidiChannel#programChange(int, int)
0N/A */
0N/A public int getProgram() {
0N/A
0N/A return program;
0N/A }
0N/A}