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