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