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

Save This Page
Home » openjdk-7 » com.sun.media » sound » [javadoc | source]