1 /* 2 * Copyright (c) 2007, 2013, 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 com.sun.media.sound; 27 28 /** 29 * This class is used to store modulator/artiuclation data. 30 * A modulator connects one synthesizer source to 31 * a destination. For example a note on velocity 32 * can be mapped to the gain of the synthesized voice. 33 * It is stored as a "art1" or "art2" chunk inside DLS files. 34 * 35 * @author Karl Helgason 36 */ 37 public final class DLSModulator { 38 39 // DLS1 Destinations 40 public static final int CONN_DST_NONE = 0x000; // 0 41 public static final int CONN_DST_GAIN = 0x001; // cB 42 public static final int CONN_DST_PITCH = 0x003; // cent 43 public static final int CONN_DST_PAN = 0x004; // 0.1% 44 public static final int CONN_DST_LFO_FREQUENCY = 0x104; // cent (default 5 Hz) 45 public static final int CONN_DST_LFO_STARTDELAY = 0x105; // timecent 46 public static final int CONN_DST_EG1_ATTACKTIME = 0x206; // timecent 47 public static final int CONN_DST_EG1_DECAYTIME = 0x207; // timecent 48 public static final int CONN_DST_EG1_RELEASETIME = 0x209; // timecent 49 public static final int CONN_DST_EG1_SUSTAINLEVEL = 0x20A; // 0.1% 50 public static final int CONN_DST_EG2_ATTACKTIME = 0x30A; // timecent 51 public static final int CONN_DST_EG2_DECAYTIME = 0x30B; // timecent 52 public static final int CONN_DST_EG2_RELEASETIME = 0x30D; // timecent 53 public static final int CONN_DST_EG2_SUSTAINLEVEL = 0x30E; // 0.1% 54 // DLS2 Destinations 55 public static final int CONN_DST_KEYNUMBER = 0x005; 56 public static final int CONN_DST_LEFT = 0x010; // 0.1% 57 public static final int CONN_DST_RIGHT = 0x011; // 0.1% 58 public static final int CONN_DST_CENTER = 0x012; // 0.1% 59 public static final int CONN_DST_LEFTREAR = 0x013; // 0.1% 60 public static final int CONN_DST_RIGHTREAR = 0x014; // 0.1% 61 public static final int CONN_DST_LFE_CHANNEL = 0x015; // 0.1% 62 public static final int CONN_DST_CHORUS = 0x080; // 0.1% 63 public static final int CONN_DST_REVERB = 0x081; // 0.1% 64 public static final int CONN_DST_VIB_FREQUENCY = 0x114; // cent 65 public static final int CONN_DST_VIB_STARTDELAY = 0x115; // dB 66 public static final int CONN_DST_EG1_DELAYTIME = 0x20B; // timecent 67 public static final int CONN_DST_EG1_HOLDTIME = 0x20C; // timecent 68 public static final int CONN_DST_EG1_SHUTDOWNTIME = 0x20D; // timecent 69 public static final int CONN_DST_EG2_DELAYTIME = 0x30F; // timecent 70 public static final int CONN_DST_EG2_HOLDTIME = 0x310; // timecent 71 public static final int CONN_DST_FILTER_CUTOFF = 0x500; // cent 72 public static final int CONN_DST_FILTER_Q = 0x501; // dB 73 74 // DLS1 Sources 75 public static final int CONN_SRC_NONE = 0x000; // 1 76 public static final int CONN_SRC_LFO = 0x001; // linear (sine wave) 77 public static final int CONN_SRC_KEYONVELOCITY = 0x002; // ??db or velocity?? 78 public static final int CONN_SRC_KEYNUMBER = 0x003; // ??cent or keynumber?? 79 public static final int CONN_SRC_EG1 = 0x004; // linear direct from eg 80 public static final int CONN_SRC_EG2 = 0x005; // linear direct from eg 81 public static final int CONN_SRC_PITCHWHEEL = 0x006; // linear -1..1 82 public static final int CONN_SRC_CC1 = 0x081; // linear 0..1 83 public static final int CONN_SRC_CC7 = 0x087; // linear 0..1 84 public static final int CONN_SRC_CC10 = 0x08A; // linear 0..1 85 public static final int CONN_SRC_CC11 = 0x08B; // linear 0..1 86 public static final int CONN_SRC_RPN0 = 0x100; // ?? // Pitch Bend Range 87 public static final int CONN_SRC_RPN1 = 0x101; // ?? // Fine Tune 88 public static final int CONN_SRC_RPN2 = 0x102; // ?? // Course Tune 89 // DLS2 Sources 90 public static final int CONN_SRC_POLYPRESSURE = 0x007; // linear 0..1 91 public static final int CONN_SRC_CHANNELPRESSURE = 0x008; // linear 0..1 92 public static final int CONN_SRC_VIBRATO = 0x009; // linear 0..1 93 public static final int CONN_SRC_MONOPRESSURE = 0x00A; // linear 0..1 94 public static final int CONN_SRC_CC91 = 0x0DB; // linear 0..1 95 public static final int CONN_SRC_CC93 = 0x0DD; // linear 0..1 96 // DLS1 Transforms 97 public static final int CONN_TRN_NONE = 0x000; 98 public static final int CONN_TRN_CONCAVE = 0x001; 99 // DLS2 Transforms 100 public static final int CONN_TRN_CONVEX = 0x002; 101 public static final int CONN_TRN_SWITCH = 0x003; 102 public static final int DST_FORMAT_CB = 1; 103 public static final int DST_FORMAT_CENT = 1; 104 public static final int DST_FORMAT_TIMECENT = 2; 105 public static final int DST_FORMAT_PERCENT = 3; 106 int source; 107 int control; 108 int destination; 109 int transform; 110 int scale; 111 int version = 1; 112 getControl()113 public int getControl() { 114 return control; 115 } 116 setControl(int control)117 public void setControl(int control) { 118 this.control = control; 119 } 120 getDestinationFormat(int destination)121 public static int getDestinationFormat(int destination) { 122 123 if (destination == CONN_DST_GAIN) 124 return DST_FORMAT_CB; 125 if (destination == CONN_DST_PITCH) 126 return DST_FORMAT_CENT; 127 if (destination == CONN_DST_PAN) 128 return DST_FORMAT_PERCENT; 129 130 if (destination == CONN_DST_LFO_FREQUENCY) 131 return DST_FORMAT_CENT; 132 if (destination == CONN_DST_LFO_STARTDELAY) 133 return DST_FORMAT_TIMECENT; 134 135 if (destination == CONN_DST_EG1_ATTACKTIME) 136 return DST_FORMAT_TIMECENT; 137 if (destination == CONN_DST_EG1_DECAYTIME) 138 return DST_FORMAT_TIMECENT; 139 if (destination == CONN_DST_EG1_RELEASETIME) 140 return DST_FORMAT_TIMECENT; 141 if (destination == CONN_DST_EG1_SUSTAINLEVEL) 142 return DST_FORMAT_PERCENT; 143 144 if (destination == CONN_DST_EG2_ATTACKTIME) 145 return DST_FORMAT_TIMECENT; 146 if (destination == CONN_DST_EG2_DECAYTIME) 147 return DST_FORMAT_TIMECENT; 148 if (destination == CONN_DST_EG2_RELEASETIME) 149 return DST_FORMAT_TIMECENT; 150 if (destination == CONN_DST_EG2_SUSTAINLEVEL) 151 return DST_FORMAT_PERCENT; 152 153 if (destination == CONN_DST_KEYNUMBER) 154 return DST_FORMAT_CENT; // NOT SURE WITHOUT DLS 2 SPEC 155 if (destination == CONN_DST_LEFT) 156 return DST_FORMAT_CB; 157 if (destination == CONN_DST_RIGHT) 158 return DST_FORMAT_CB; 159 if (destination == CONN_DST_CENTER) 160 return DST_FORMAT_CB; 161 if (destination == CONN_DST_LEFTREAR) 162 return DST_FORMAT_CB; 163 if (destination == CONN_DST_RIGHTREAR) 164 return DST_FORMAT_CB; 165 if (destination == CONN_DST_LFE_CHANNEL) 166 return DST_FORMAT_CB; 167 if (destination == CONN_DST_CHORUS) 168 return DST_FORMAT_PERCENT; 169 if (destination == CONN_DST_REVERB) 170 return DST_FORMAT_PERCENT; 171 172 if (destination == CONN_DST_VIB_FREQUENCY) 173 return DST_FORMAT_CENT; 174 if (destination == CONN_DST_VIB_STARTDELAY) 175 return DST_FORMAT_TIMECENT; 176 177 if (destination == CONN_DST_EG1_DELAYTIME) 178 return DST_FORMAT_TIMECENT; 179 if (destination == CONN_DST_EG1_HOLDTIME) 180 return DST_FORMAT_TIMECENT; 181 if (destination == CONN_DST_EG1_SHUTDOWNTIME) 182 return DST_FORMAT_TIMECENT; 183 184 if (destination == CONN_DST_EG2_DELAYTIME) 185 return DST_FORMAT_TIMECENT; 186 if (destination == CONN_DST_EG2_HOLDTIME) 187 return DST_FORMAT_TIMECENT; 188 189 if (destination == CONN_DST_FILTER_CUTOFF) 190 return DST_FORMAT_CENT; 191 if (destination == CONN_DST_FILTER_Q) 192 return DST_FORMAT_CB; 193 194 return -1; 195 } 196 getDestinationName(int destination)197 public static String getDestinationName(int destination) { 198 199 if (destination == CONN_DST_GAIN) 200 return "gain"; 201 if (destination == CONN_DST_PITCH) 202 return "pitch"; 203 if (destination == CONN_DST_PAN) 204 return "pan"; 205 206 if (destination == CONN_DST_LFO_FREQUENCY) 207 return "lfo1.freq"; 208 if (destination == CONN_DST_LFO_STARTDELAY) 209 return "lfo1.delay"; 210 211 if (destination == CONN_DST_EG1_ATTACKTIME) 212 return "eg1.attack"; 213 if (destination == CONN_DST_EG1_DECAYTIME) 214 return "eg1.decay"; 215 if (destination == CONN_DST_EG1_RELEASETIME) 216 return "eg1.release"; 217 if (destination == CONN_DST_EG1_SUSTAINLEVEL) 218 return "eg1.sustain"; 219 220 if (destination == CONN_DST_EG2_ATTACKTIME) 221 return "eg2.attack"; 222 if (destination == CONN_DST_EG2_DECAYTIME) 223 return "eg2.decay"; 224 if (destination == CONN_DST_EG2_RELEASETIME) 225 return "eg2.release"; 226 if (destination == CONN_DST_EG2_SUSTAINLEVEL) 227 return "eg2.sustain"; 228 229 if (destination == CONN_DST_KEYNUMBER) 230 return "keynumber"; 231 if (destination == CONN_DST_LEFT) 232 return "left"; 233 if (destination == CONN_DST_RIGHT) 234 return "right"; 235 if (destination == CONN_DST_CENTER) 236 return "center"; 237 if (destination == CONN_DST_LEFTREAR) 238 return "leftrear"; 239 if (destination == CONN_DST_RIGHTREAR) 240 return "rightrear"; 241 if (destination == CONN_DST_LFE_CHANNEL) 242 return "lfe_channel"; 243 if (destination == CONN_DST_CHORUS) 244 return "chorus"; 245 if (destination == CONN_DST_REVERB) 246 return "reverb"; 247 248 if (destination == CONN_DST_VIB_FREQUENCY) 249 return "vib.freq"; 250 if (destination == CONN_DST_VIB_STARTDELAY) 251 return "vib.delay"; 252 253 if (destination == CONN_DST_EG1_DELAYTIME) 254 return "eg1.delay"; 255 if (destination == CONN_DST_EG1_HOLDTIME) 256 return "eg1.hold"; 257 if (destination == CONN_DST_EG1_SHUTDOWNTIME) 258 return "eg1.shutdown"; 259 260 if (destination == CONN_DST_EG2_DELAYTIME) 261 return "eg2.delay"; 262 if (destination == CONN_DST_EG2_HOLDTIME) 263 return "eg.2hold"; 264 265 if (destination == CONN_DST_FILTER_CUTOFF) 266 return "filter.cutoff"; // NOT SURE WITHOUT DLS 2 SPEC 267 if (destination == CONN_DST_FILTER_Q) 268 return "filter.q"; // NOT SURE WITHOUT DLS 2 SPEC 269 270 return null; 271 } 272 getSourceName(int source)273 public static String getSourceName(int source) { 274 275 if (source == CONN_SRC_NONE) 276 return "none"; 277 if (source == CONN_SRC_LFO) 278 return "lfo"; 279 if (source == CONN_SRC_KEYONVELOCITY) 280 return "keyonvelocity"; 281 if (source == CONN_SRC_KEYNUMBER) 282 return "keynumber"; 283 if (source == CONN_SRC_EG1) 284 return "eg1"; 285 if (source == CONN_SRC_EG2) 286 return "eg2"; 287 if (source == CONN_SRC_PITCHWHEEL) 288 return "pitchweel"; 289 if (source == CONN_SRC_CC1) 290 return "cc1"; 291 if (source == CONN_SRC_CC7) 292 return "cc7"; 293 if (source == CONN_SRC_CC10) 294 return "c10"; 295 if (source == CONN_SRC_CC11) 296 return "cc11"; 297 298 if (source == CONN_SRC_POLYPRESSURE) 299 return "polypressure"; 300 if (source == CONN_SRC_CHANNELPRESSURE) 301 return "channelpressure"; 302 if (source == CONN_SRC_VIBRATO) 303 return "vibrato"; 304 if (source == CONN_SRC_MONOPRESSURE) 305 return "monopressure"; 306 if (source == CONN_SRC_CC91) 307 return "cc91"; 308 if (source == CONN_SRC_CC93) 309 return "cc93"; 310 return null; 311 } 312 getDestination()313 public int getDestination() { 314 return destination; 315 } 316 setDestination(int destination)317 public void setDestination(int destination) { 318 this.destination = destination; 319 } 320 getScale()321 public int getScale() { 322 return scale; 323 } 324 setScale(int scale)325 public void setScale(int scale) { 326 this.scale = scale; 327 } 328 getSource()329 public int getSource() { 330 return source; 331 } 332 setSource(int source)333 public void setSource(int source) { 334 this.source = source; 335 } 336 getVersion()337 public int getVersion() { 338 return version; 339 } 340 setVersion(int version)341 public void setVersion(int version) { 342 this.version = version; 343 } 344 getTransform()345 public int getTransform() { 346 return transform; 347 } 348 setTransform(int transform)349 public void setTransform(int transform) { 350 this.transform = transform; 351 } 352 } 353