27 |
* @author Grigor Iliev |
* @author Grigor Iliev |
28 |
*/ |
*/ |
29 |
public class SamplerChannel implements Parseable { |
public class SamplerChannel implements Parseable { |
30 |
|
/** Indicates that the channel is muted because of the presence of a solo channel. */ |
31 |
|
private final static int MUTED_BY_SOLO = -1; |
32 |
|
|
33 |
private int chnID = -1; |
private int chnID = -1; |
34 |
|
|
35 |
private String engine = null; |
private SamplerEngine engine = null; |
36 |
private int aoDevice = -1; |
private int aoDevice = -1; |
37 |
private int aoChannels = 0; |
private int aoChannels = 0; |
38 |
private Integer[] aor = null; |
private Integer[] aor = null; |
44 |
private int miPort = 0; |
private int miPort = 0; |
45 |
private int miChn = -1; |
private int miChn = -1; |
46 |
private float vol = 0; |
private float vol = 0; |
47 |
|
private int mute = 0; |
48 |
|
private boolean solo = false; |
49 |
|
|
50 |
/** Creates a new instance of SamplerChannel */ |
/** Creates a new instance of SamplerChannel */ |
51 |
public |
public |
79 |
setChannelID(int id) { chnID = id; } |
setChannelID(int id) { chnID = id; } |
80 |
|
|
81 |
/** |
/** |
82 |
* Gets the name of the engine that is deployed on the sampler channel. |
* Gets the engine that is deployed on the sampler channel. |
83 |
* @return The name of the engine that is deployed on the sampler channel |
* @return The engine that is deployed on the sampler channel |
84 |
* or <code>null</code> if there is no engine deployed yet for this sampler channel. |
* or <code>null</code> if there is no engine deployed yet for this sampler channel. |
85 |
*/ |
*/ |
86 |
public String |
public SamplerEngine |
87 |
getEngineName() { return engine; } |
getEngine() { return engine; } |
88 |
|
|
89 |
|
/** |
90 |
|
* Associates the specified sampler engine to this sampler channel. |
91 |
|
* @param engine A <code>SamplerEngine</code> instance containing the information |
92 |
|
* about the engine to be assigned to this channel. |
93 |
|
*/ |
94 |
|
public void |
95 |
|
setEngine(SamplerEngine engine) { this.engine = engine; } |
96 |
|
|
97 |
/** |
/** |
98 |
* Gets the numerical ID of the audio output device which is currently connected |
* Gets the numerical ID of the audio output device which is currently connected |
136 |
getInstrumentIndex() { return instrIdx; } |
getInstrumentIndex() { return instrIdx; } |
137 |
|
|
138 |
/** |
/** |
139 |
* Gets the instrument name of the loaded instrument. |
* Gets the name of the loaded instrument. |
140 |
* @return The instrument name of the loaded instrument. |
* @return The name of the loaded instrument or |
141 |
|
* <code>null</code> if there is no instrument loaded. |
142 |
*/ |
*/ |
143 |
public String |
public String |
144 |
getInstrumentName() { return instrName; } |
getInstrumentName() { return instrName; } |
187 |
getVolume() { return vol; } |
getVolume() { return vol; } |
188 |
|
|
189 |
/** |
/** |
190 |
|
* Determines whether this channel is muted. |
191 |
|
* @return <code>true</code> if the channel is muted, <code>false</code> otherwise. |
192 |
|
*/ |
193 |
|
public boolean |
194 |
|
isMuted() { return mute != 0; } |
195 |
|
|
196 |
|
/** |
197 |
|
* Determines whether this channel is muted because of the presence of a solo channel. |
198 |
|
* All channels, muted because of the presence of a solo channel, will be |
199 |
|
* automatically unmuted when there are no solo channels left. |
200 |
|
* @return <code>true</code> if the channel is muted because of the presence of a solo |
201 |
|
* channel, <code>false</code> otherwise. |
202 |
|
*/ |
203 |
|
public boolean |
204 |
|
isMutedBySolo() { return mute == MUTED_BY_SOLO; } |
205 |
|
|
206 |
|
/** |
207 |
|
* Determines whether this channel is a solo channel. |
208 |
|
* @return <code>true</code> if the channel is a solo channel, <code>false</code> otherwise. |
209 |
|
*/ |
210 |
|
public boolean |
211 |
|
isSoloChannel() { return solo; } |
212 |
|
|
213 |
|
/** |
214 |
* Parses a line of text. |
* Parses a line of text. |
215 |
* @param s The string to be parsed. |
* @param s The string to be parsed. |
216 |
* @return <code>true</code> if the line has been processed, <code>false</code> otherwise. |
* @return <code>true</code> if the line has been processed, <code>false</code> otherwise. |
221 |
if(s.startsWith("ENGINE_NAME: ")) { |
if(s.startsWith("ENGINE_NAME: ")) { |
222 |
s = s.substring("ENGINE_NAME: ".length()); |
s = s.substring("ENGINE_NAME: ".length()); |
223 |
if(s.equals("NONE")) engine = null; |
if(s.equals("NONE")) engine = null; |
224 |
else engine = s; |
else { |
225 |
|
engine = new SamplerEngine(); |
226 |
|
engine.setName(s); |
227 |
|
} |
228 |
} else if(s.startsWith("AUDIO_OUTPUT_DEVICE: ")) { |
} else if(s.startsWith("AUDIO_OUTPUT_DEVICE: ")) { |
229 |
s = s.substring("AUDIO_OUTPUT_DEVICE: ".length()); |
s = s.substring("AUDIO_OUTPUT_DEVICE: ".length()); |
230 |
if(s.equals("NONE")) aoDevice = -1; |
if(s.equals("NONE")) aoDevice = -1; |
245 |
if(s.equals("NONE")) instrIdx = -1; |
if(s.equals("NONE")) instrIdx = -1; |
246 |
else instrIdx = Parser.parseInt(s); |
else instrIdx = Parser.parseInt(s); |
247 |
} else if(s.startsWith("INSTRUMENT_NAME: ")) { |
} else if(s.startsWith("INSTRUMENT_NAME: ")) { |
248 |
instrName = s.substring("INSTRUMENT_NAME: ".length()); |
s = s.substring("INSTRUMENT_NAME: ".length()); |
249 |
|
if(s.equals("NONE")) instrName = null; |
250 |
|
else instrName = s; |
251 |
} else if(s.startsWith("INSTRUMENT_STATUS: ")) { |
} else if(s.startsWith("INSTRUMENT_STATUS: ")) { |
252 |
s = s.substring("INSTRUMENT_STATUS: ".length()); |
s = s.substring("INSTRUMENT_STATUS: ".length()); |
253 |
instrStat = Parser.parseInt(s); |
instrStat = Parser.parseInt(s); |
269 |
catch(NumberFormatException x) { throw new LscpException ( |
catch(NumberFormatException x) { throw new LscpException ( |
270 |
LscpI18n.getLogMsg("CommandFailed!"), x |
LscpI18n.getLogMsg("CommandFailed!"), x |
271 |
);} |
);} |
272 |
|
} else if(s.startsWith("MUTE: ")) { |
273 |
|
s = s.substring("MUTE: ".length()); |
274 |
|
if(s.equals("MUTED_BY_SOLO")) mute = MUTED_BY_SOLO; |
275 |
|
else mute = Boolean.parseBoolean(s) ? 1 : 0; |
276 |
|
} else if(s.startsWith("SOLO: ")) { |
277 |
|
s = s.substring("SOLO: ".length()); |
278 |
|
solo = Boolean.parseBoolean(s); |
279 |
} else return false; |
} else return false; |
280 |
|
|
281 |
return true; |
return true; |
282 |
} |
} |
283 |
|
|
284 |
|
/** |
285 |
|
* Returns the numerical ID of this sampler channel. |
286 |
|
* @return The numerical ID of this sampler channel. |
287 |
|
*/ |
288 |
|
public String |
289 |
|
toString() { return String.valueOf(getChannelID()); } |
290 |
} |
} |