1 |
/* |
2 |
* jlscp - a java LinuxSampler control protocol API |
3 |
* |
4 |
* Copyright (C) 2005-2011 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
6 |
* This file is part of jlscp. |
7 |
* |
8 |
* jlscp is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License version 2 |
10 |
* as published by the Free Software Foundation. |
11 |
* |
12 |
* jlscp is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with jlscp; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
* MA 02111-1307 USA |
21 |
*/ |
22 |
|
23 |
package org.linuxsampler.lscp; |
24 |
|
25 |
import static org.linuxsampler.lscp.Parser.*; |
26 |
|
27 |
/** |
28 |
* Provides information about the current settings of a specific effect send. |
29 |
* @author Grigor Iliev |
30 |
*/ |
31 |
public class FxSend implements Parseable { |
32 |
private int fxSendId = -1; |
33 |
private String name = null; |
34 |
private int midiController = -1; |
35 |
private float level = 0; |
36 |
private Integer[] aor = null; |
37 |
private int destChainId = -1; |
38 |
private int destChainPos = -1; |
39 |
|
40 |
|
41 |
/** Creates a new instance of <code>FxSend</code> */ |
42 |
public |
43 |
FxSend() { } |
44 |
|
45 |
/** |
46 |
* Creates a new instance of <code>FxSend</code> and parses the information |
47 |
* about a specific effect send described by <code>resultSet</code>. |
48 |
* @param resultSet An array with information categories about an effect send entity. |
49 |
* @throws LscpException If the parse fail. |
50 |
*/ |
51 |
public |
52 |
FxSend(String[] resultSet) throws LscpException { |
53 |
for(String s : resultSet) |
54 |
if(!parse(s)) Client.getLogger().info(LscpI18n.getLogMsg("unknownLine", s)); |
55 |
} |
56 |
|
57 |
/** |
58 |
* Gets the numerical ID of this effect send. |
59 |
* @return The numerical ID of this effect |
60 |
* send or -1 if the effect send number is not set. |
61 |
*/ |
62 |
public int |
63 |
getFxSendId() { return fxSendId; } |
64 |
|
65 |
/** |
66 |
* Sets the numerical ID of this effect send. |
67 |
* @param id The new effect send number. |
68 |
*/ |
69 |
public void |
70 |
setFxSendId(int id) { fxSendId = id; } |
71 |
|
72 |
/** |
73 |
* Gets the name of this effect send. |
74 |
* @return The name of this effect send. |
75 |
*/ |
76 |
public String |
77 |
getName() { return name; } |
78 |
|
79 |
/** |
80 |
* Sets the name of this effect send. |
81 |
* @param name The new name of this effect send. |
82 |
*/ |
83 |
public void |
84 |
setName(String name) { this.name = name; } |
85 |
|
86 |
/** |
87 |
* Gets the MIDI controller, which is able to modify the send level. |
88 |
* @return The MIDI controller, which is able to modify the |
89 |
* send level, or -1 if the effect send number is not set. |
90 |
*/ |
91 |
public int |
92 |
getMidiController() { return midiController; } |
93 |
|
94 |
/** |
95 |
* Gets the current send level. |
96 |
* @return The current send level. |
97 |
*/ |
98 |
public float |
99 |
getLevel() { return level; } |
100 |
|
101 |
/** |
102 |
* Gets a list which reflects to which audio channel of the selected |
103 |
* audio output device each effect send output channel is routed to. |
104 |
* The number of the array's position represents the effect send output channel |
105 |
* and the value at the specified position represents |
106 |
* to which channel of the selected audio output device the |
107 |
* effect send output channel is routed to. |
108 |
* @return A list which reflects to which audio channel of the selected audio |
109 |
* output device each effect send output channel is routed to. |
110 |
*/ |
111 |
public Integer[] |
112 |
getAudioOutputRouting() { return aor; } |
113 |
|
114 |
/** Gets the destination send effect chain ID. */ |
115 |
public int |
116 |
getDestChainId() { return destChainId; } |
117 |
|
118 |
/** Gets the destination send effect chain position. */ |
119 |
public int |
120 |
getDestChainPos() { return destChainPos; } |
121 |
|
122 |
/** |
123 |
* Parses a line of text. |
124 |
* @param s The string to be parsed. |
125 |
* @return <code>true</code> if the line has been processed, <code>false</code> otherwise. |
126 |
* @throws LscpException If some error occurs. |
127 |
*/ |
128 |
public boolean |
129 |
parse(String s) throws LscpException { |
130 |
if(s.startsWith("NAME: ")) { |
131 |
name = toNonEscapedString(s.substring("NAME: ".length())); |
132 |
} else if(s.startsWith("MIDI_CONTROLLER: ")) { |
133 |
s = s.substring("MIDI_CONTROLLER: ".length()); |
134 |
midiController = Parser.parseInt(s); |
135 |
} else if(s.startsWith("LEVEL: ")) { |
136 |
s = s.substring("LEVEL: ".length()); |
137 |
level = Parser.parseFloat(s); |
138 |
} else if(s.startsWith("AUDIO_OUTPUT_ROUTING: ")) { |
139 |
s = s.substring("AUDIO_OUTPUT_ROUTING: ".length()); |
140 |
aor = Parser.parseIntList(s); |
141 |
} else if(s.startsWith("EFFECT: ")) { |
142 |
s = s.substring("EFFECT: ".length()); |
143 |
if("NONE".equals(s)) { |
144 |
destChainId = destChainPos = -1; |
145 |
} else { |
146 |
Integer[] list = Parser.parseIntList(s); |
147 |
if(list.length != 2) { |
148 |
Client.getLogger().info("FxSend: EFFECT field format unknown"); |
149 |
} else { |
150 |
destChainId = list[0]; |
151 |
destChainPos = list[1]; |
152 |
} |
153 |
|
154 |
} |
155 |
|
156 |
} else return false; |
157 |
|
158 |
return true; |
159 |
} |
160 |
|
161 |
/** |
162 |
* Returns the name of this effect send. |
163 |
* @return The name of this effect send. |
164 |
*/ |
165 |
public String |
166 |
toString() { return getName(); } |
167 |
|
168 |
/** |
169 |
* Determines whether the specified object is of type |
170 |
* <code>FxSend</code> and has equal ID. |
171 |
* @param obj The reference object with which to compare. |
172 |
* @return <code>true</code> if the specified object is of type |
173 |
* <code>FxSend</code> and has equal ID. |
174 |
*/ |
175 |
public boolean |
176 |
equals(Object obj) { |
177 |
if(obj == null) return false; |
178 |
if(!(obj instanceof FxSend)) return false; |
179 |
FxSend fxs = (FxSend)obj; |
180 |
if(getFxSendId() != fxs.getFxSendId()) return false; |
181 |
|
182 |
return true; |
183 |
} |
184 |
} |