jdk/src/java.desktop/share/classes/javax/sound/midi/Patch.java
author ddehaven
Tue, 19 Aug 2014 10:32:16 -0700
changeset 26037 508779ce6619
parent 26003 jdk/src/share/classes/javax/sound/midi/Patch.java@d630c97424bd
parent 25859 jdk/src/share/classes/javax/sound/midi/Patch.java@3317bb8137f4
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
     2
 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.sound.midi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    29
 * A {@code Patch} object represents a location, on a MIDI synthesizer, into
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    30
 * which a single instrument is stored (loaded). Every {@code Instrument} object
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    31
 * has its own {@code Patch} object that specifies the memory location into
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    32
 * which that instrument should be loaded. The location is specified abstractly
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    33
 * by a bank index and a program number (not by any scheme that directly refers
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    34
 * to a specific address or offset in RAM). This is a hierarchical indexing
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    35
 * scheme: MIDI provides for up to 16384 banks, each of which contains up to 128
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    36
 * program locations. For example, a minimal sort of synthesizer might have only
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    37
 * one bank of instruments, and only 32 instruments (programs) in that bank.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <p>
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    39
 * To select what instrument should play the notes on a particular MIDI channel,
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    40
 * two kinds of MIDI message are used that specify a patch location: a
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    41
 * bank-select command, and a program-change channel command. The Java Sound
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * equivalent is the
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    43
 * {@link MidiChannel#programChange(int, int) programChange(int, int)} method of
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    44
 * {@code MidiChannel}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    46
 * @author Kara Kytle
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @see Instrument
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @see Instrument#getPatch()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * @see MidiChannel#programChange(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * @see Synthesizer#loadInstruments(Soundbank, Patch[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * @see Soundbank
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * @see Sequence#getPatchList()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
public class Patch {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    /**
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    57
     * Bank index.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private final int bank;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /**
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    62
     * Program change number.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private final int program;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * Constructs a new patch object from the specified bank and program
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * numbers.
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    69
     *
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    70
     * @param  bank the bank index (in the range from 0 to 16383)
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    71
     * @param  program the program index (in the range from 0 to 127)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public Patch(int bank, int program) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        this.bank = bank;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        this.program = program;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /**
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    79
     * Returns the number of the bank that contains the instrument whose
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    80
     * location this {@code Patch} specifies.
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    81
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * @return the bank number, whose range is from 0 to 16383
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @see MidiChannel#programChange(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public int getBank() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        return bank;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
26003
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    90
     * Returns the index, within a bank, of the instrument whose location this
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    91
     * {@code Patch} specifies.
d630c97424bd 8050852: Javadoc cleanup of javax.sound.midi package
serb
parents: 5506
diff changeset
    92
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @return the instrument's program number, whose range is from 0 to 127
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @see MidiChannel#getProgram
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @see MidiChannel#programChange(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @see MidiChannel#programChange(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    public int getProgram() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        return program;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
}