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 identify sources in connection blocks,
  30  * see ModelConnectionBlock.
  31  *
  32  * @author Karl Helgason
  33  */
  34 public final class ModelSource {
  35 
  36     public static final ModelIdentifier SOURCE_NONE = null;
  37     public static final ModelIdentifier SOURCE_NOTEON_KEYNUMBER =
  38             new ModelIdentifier("noteon", "keynumber");     // midi keynumber
  39     public static final ModelIdentifier SOURCE_NOTEON_VELOCITY =
  40             new ModelIdentifier("noteon", "velocity");      // midi velocity
  41     public static final ModelIdentifier SOURCE_EG1 =
  42             new ModelIdentifier("eg", null, 0);
  43     public static final ModelIdentifier SOURCE_EG2 =
  44             new ModelIdentifier("eg", null, 1);
  45     public static final ModelIdentifier SOURCE_LFO1 =
  46             new ModelIdentifier("lfo", null, 0);
  47     public static final ModelIdentifier SOURCE_LFO2 =
  48             new ModelIdentifier("lfo", null, 1);
  49     public static final ModelIdentifier SOURCE_MIDI_PITCH =
  50             new ModelIdentifier("midi", "pitch", 0);            // (0..16383)
  51     public static final ModelIdentifier SOURCE_MIDI_CHANNEL_PRESSURE =
  52             new ModelIdentifier("midi", "channel_pressure", 0); // (0..127)
  53 //    public static final ModelIdentifier SOURCE_MIDI_MONO_PRESSURE =
  54 //            new ModelIdentifier("midi","mono_pressure",0);    // (0..127)
  55     public static final ModelIdentifier SOURCE_MIDI_POLY_PRESSURE =
  56             new ModelIdentifier("midi", "poly_pressure", 0);    // (0..127)
  57     public static final ModelIdentifier SOURCE_MIDI_CC_0 =
  58             new ModelIdentifier("midi_cc", "0", 0);             // (0..127)
  59     public static final ModelIdentifier SOURCE_MIDI_RPN_0 =
  60             new ModelIdentifier("midi_rpn", "0", 0);            // (0..16383)
  61     private ModelIdentifier source = SOURCE_NONE;
  62     private ModelTransform transform;
  63 
  64     public ModelSource() {
  65         this.transform = new ModelStandardTransform();
  66     }
  67 
  68     public ModelSource(ModelIdentifier id) {
  69         source = id;
  70         this.transform = new ModelStandardTransform();
  71     }
  72 
  73     public ModelSource(ModelIdentifier id, boolean direction) {
  74         source = id;
  75         this.transform = new ModelStandardTransform(direction);
  76     }
  77 
  78     public ModelSource(ModelIdentifier id, boolean direction, boolean polarity) {
  79         source = id;
  80         this.transform = new ModelStandardTransform(direction, polarity);
  81     }
  82 
  83     public ModelSource(ModelIdentifier id, boolean direction, boolean polarity,
  84             int transform) {
  85         source = id;
  86         this.transform =
  87                 new ModelStandardTransform(direction, polarity, transform);
  88     }
  89 
  90     public ModelSource(ModelIdentifier id, ModelTransform transform) {
  91         source = id;
  92         this.transform = transform;
  93     }
  94 
  95     public ModelIdentifier getIdentifier() {
  96         return source;
  97     }
  98 
  99     public void setIdentifier(ModelIdentifier source) {
 100         this.source = source;
 101     }
 102 
 103     public ModelTransform getTransform() {
 104         return transform;
 105     }
 106 
 107     public void setTransform(ModelTransform transform) {
 108         this.transform = transform;
 109     }
 110 }