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 package com.sun.media.sound;
26
27 import java.util.ArrayList;
28 import java.util.HashMap;
29 import java.util.List;
30 import java.util.Map;
31
32 /**
33 * Soundfont general region.
34 *
35 * @author Karl Helgason
36 */
37 public class SF2Region {
38
39 public static final int GENERATOR_STARTADDRSOFFSET = 0;
40 public static final int GENERATOR_ENDADDRSOFFSET = 1;
41 public static final int GENERATOR_STARTLOOPADDRSOFFSET = 2;
42 public static final int GENERATOR_ENDLOOPADDRSOFFSET = 3;
43 public static final int GENERATOR_STARTADDRSCOARSEOFFSET = 4;
44 public static final int GENERATOR_MODLFOTOPITCH = 5;
80 public static final int GENERATOR_INSTRUMENT = 41;
81 public static final int GENERATOR_RESERVED1 = 42;
82 public static final int GENERATOR_KEYRANGE = 43;
83 public static final int GENERATOR_VELRANGE = 44;
84 public static final int GENERATOR_STARTLOOPADDRSCOARSEOFFSET = 45;
85 public static final int GENERATOR_KEYNUM = 46;
86 public static final int GENERATOR_VELOCITY = 47;
87 public static final int GENERATOR_INITIALATTENUATION = 48;
88 public static final int GENERATOR_RESERVED2 = 49;
89 public static final int GENERATOR_ENDLOOPADDRSCOARSEOFFSET = 50;
90 public static final int GENERATOR_COARSETUNE = 51;
91 public static final int GENERATOR_FINETUNE = 52;
92 public static final int GENERATOR_SAMPLEID = 53;
93 public static final int GENERATOR_SAMPLEMODES = 54;
94 public static final int GENERATOR_RESERVED3 = 55;
95 public static final int GENERATOR_SCALETUNING = 56;
96 public static final int GENERATOR_EXCLUSIVECLASS = 57;
97 public static final int GENERATOR_OVERRIDINGROOTKEY = 58;
98 public static final int GENERATOR_UNUSED5 = 59;
99 public static final int GENERATOR_ENDOPR = 60;
100 protected Map<Integer, Short> generators = new HashMap<Integer, Short>();
101 protected List<SF2Modulator> modulators = new ArrayList<SF2Modulator>();
102
103 public Map<Integer, Short> getGenerators() {
104 return generators;
105 }
106
107 public boolean contains(int generator) {
108 return generators.containsKey(generator);
109 }
110
111 public static short getDefaultValue(int generator) {
112 if (generator == 8) return (short)13500;
113 if (generator == 21) return (short)-12000;
114 if (generator == 23) return (short)-12000;
115 if (generator == 25) return (short)-12000;
116 if (generator == 26) return (short)-12000;
117 if (generator == 27) return (short)-12000;
118 if (generator == 28) return (short)-12000;
119 if (generator == 30) return (short)-12000;
120 if (generator == 33) return (short)-12000;
121 if (generator == 34) return (short)-12000;
|
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 com.sun.media.sound;
27
28 import java.util.ArrayList;
29 import java.util.HashMap;
30 import java.util.List;
31 import java.util.Map;
32
33 /**
34 * Soundfont general region.
35 *
36 * @author Karl Helgason
37 */
38 public class SF2Region {
39
40 public static final int GENERATOR_STARTADDRSOFFSET = 0;
41 public static final int GENERATOR_ENDADDRSOFFSET = 1;
42 public static final int GENERATOR_STARTLOOPADDRSOFFSET = 2;
43 public static final int GENERATOR_ENDLOOPADDRSOFFSET = 3;
44 public static final int GENERATOR_STARTADDRSCOARSEOFFSET = 4;
45 public static final int GENERATOR_MODLFOTOPITCH = 5;
81 public static final int GENERATOR_INSTRUMENT = 41;
82 public static final int GENERATOR_RESERVED1 = 42;
83 public static final int GENERATOR_KEYRANGE = 43;
84 public static final int GENERATOR_VELRANGE = 44;
85 public static final int GENERATOR_STARTLOOPADDRSCOARSEOFFSET = 45;
86 public static final int GENERATOR_KEYNUM = 46;
87 public static final int GENERATOR_VELOCITY = 47;
88 public static final int GENERATOR_INITIALATTENUATION = 48;
89 public static final int GENERATOR_RESERVED2 = 49;
90 public static final int GENERATOR_ENDLOOPADDRSCOARSEOFFSET = 50;
91 public static final int GENERATOR_COARSETUNE = 51;
92 public static final int GENERATOR_FINETUNE = 52;
93 public static final int GENERATOR_SAMPLEID = 53;
94 public static final int GENERATOR_SAMPLEMODES = 54;
95 public static final int GENERATOR_RESERVED3 = 55;
96 public static final int GENERATOR_SCALETUNING = 56;
97 public static final int GENERATOR_EXCLUSIVECLASS = 57;
98 public static final int GENERATOR_OVERRIDINGROOTKEY = 58;
99 public static final int GENERATOR_UNUSED5 = 59;
100 public static final int GENERATOR_ENDOPR = 60;
101 protected Map<Integer, Short> generators = new HashMap<>();
102 protected List<SF2Modulator> modulators = new ArrayList<>();
103
104 public Map<Integer, Short> getGenerators() {
105 return generators;
106 }
107
108 public boolean contains(int generator) {
109 return generators.containsKey(generator);
110 }
111
112 public static short getDefaultValue(int generator) {
113 if (generator == 8) return (short)13500;
114 if (generator == 21) return (short)-12000;
115 if (generator == 23) return (short)-12000;
116 if (generator == 25) return (short)-12000;
117 if (generator == 26) return (short)-12000;
118 if (generator == 27) return (short)-12000;
119 if (generator == 28) return (short)-12000;
120 if (generator == 30) return (short)-12000;
121 if (generator == 33) return (short)-12000;
122 if (generator == 34) return (short)-12000;
|