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 stores the identity of source and destinations in connection
   29    * blocks, see ModelConnectionBlock.
   30    *
   31    * @author Karl Helgason
   32    */
   33   public class ModelIdentifier {
   34   
   35       /*
   36        *  Object    Variable
   37        *  ------    --------
   38        *
   39        *  // INPUT parameters
   40        *  noteon    keynumber                7 bit midi value
   41        *            velocity                 7 bit midi vale
   42        *            on                       1 or 0
   43        *
   44        *  midi      pitch                    14 bit midi value
   45        *            channel_pressure         7 bit midi value
   46        *            poly_pressure            7 bit midi value
   47        *
   48        *  midi_cc   0 (midi control #0       7 bit midi value
   49        *            1 (midi control #1       7 bit midi value
   50        *            ...
   51        *            127 (midi control #127   7 bit midi value
   52        *
   53        *  midi_rpn  0 (midi rpn control #0)  14 bit midi value
   54        *            1 (midi rpn control #1)  14 bit midi value
   55        *            ....
   56        *
   57        *  // DAHDSR envelope generator
   58        *  eg        (null)
   59        *            delay                    timecent
   60        *            attack                   timecent
   61        *            hold                     timecent
   62        *            decay                    timecent
   63        *            sustain                  0.1 %
   64        *            release                  timecent
   65        *
   66        *  // Low frequency oscillirator (sine wave)
   67        *  lfo       (null)
   68        *            delay                    timcent
   69        *            freq                     cent
   70        *
   71        *  // Resonance LowPass Filter 6dB slope
   72        *  filter    (null) (output/input)
   73        *            freq                     cent
   74        *            q                        cB
   75        *
   76        *  // The oscillator with preloaded wavetable data
   77        *  osc       (null)
   78        *            pitch                    cent
   79        *
   80        *  // Output mixer pins
   81        *  mixer     gain                     cB
   82        *            pan                      0.1 %
   83        *            reverb                   0.1 %
   84        *            chorus                   0.1 %
   85        *
   86        */
   87       private String object = null;
   88       private String variable = null;
   89       private int instance = 0;
   90   
   91       public ModelIdentifier(String object) {
   92           this.object = object;
   93       }
   94   
   95       public ModelIdentifier(String object, int instance) {
   96           this.object = object;
   97           this.instance = instance;
   98       }
   99   
  100       public ModelIdentifier(String object, String variable) {
  101           this.object = object;
  102           this.variable = variable;
  103   
  104       }
  105   
  106       public ModelIdentifier(String object, String variable, int instance) {
  107           this.object = object;
  108           this.variable = variable;
  109           this.instance = instance;
  110   
  111       }
  112   
  113       public int getInstance() {
  114           return instance;
  115       }
  116   
  117       public void setInstance(int instance) {
  118           this.instance = instance;
  119       }
  120   
  121       public String getObject() {
  122           return object;
  123       }
  124   
  125       public void setObject(String object) {
  126           this.object = object;
  127       }
  128   
  129       public String getVariable() {
  130           return variable;
  131       }
  132   
  133       public void setVariable(String variable) {
  134           this.variable = variable;
  135       }
  136   
  137       public int hashCode() {
  138           int hashcode = instance;
  139           if(object != null) hashcode |= object.hashCode();
  140           if(variable != null) hashcode |= variable.hashCode();
  141           return  hashcode;
  142       }
  143   
  144       public boolean equals(Object obj) {
  145           if (!(obj instanceof ModelIdentifier))
  146               return false;
  147   
  148           ModelIdentifier mobj = (ModelIdentifier)obj;
  149           if ((object == null) != (mobj.object == null))
  150               return false;
  151           if ((variable == null) != (mobj.variable == null))
  152               return false;
  153           if (mobj.getInstance() != getInstance())
  154               return false;
  155           if (!(object == null || object.equals(mobj.object)))
  156               return false;
  157           if (!(variable == null || variable.equals(mobj.variable)))
  158               return false;
  159           return true;
  160       }
  161   
  162       public String toString() {
  163           if (variable == null) {
  164               return object + "[" + instance + "]";
  165           } else {
  166               return object + "[" + instance + "]" + "." + variable;
  167           }
  168       }
  169   }

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