1 |
iliev |
1140 |
/* |
2 |
|
|
* jlscp - a java LinuxSampler control protocol API |
3 |
|
|
* |
4 |
|
|
* Copyright (C) 2005-2007 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 |
iliev |
1421 |
import static org.linuxsampler.lscp.Parser.*; |
26 |
|
|
|
27 |
iliev |
1140 |
/** |
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 |
|
|
|
38 |
|
|
|
39 |
|
|
/** Creates a new instance of <code>FxSend</code> */ |
40 |
|
|
public |
41 |
|
|
FxSend() { } |
42 |
|
|
|
43 |
|
|
/** |
44 |
|
|
* Creates a new instance of <code>FxSend</code> and parses the information |
45 |
|
|
* about a specific effect send described by <code>resultSet</code>. |
46 |
|
|
* @param resultSet An array with information categories about an effect send entity. |
47 |
|
|
* @throws LscpException If the parse fail. |
48 |
|
|
*/ |
49 |
|
|
public |
50 |
|
|
FxSend(String[] resultSet) throws LscpException { |
51 |
|
|
for(String s : resultSet) |
52 |
|
|
if(!parse(s)) Client.getLogger().info(LscpI18n.getLogMsg("unknownLine", s)); |
53 |
|
|
} |
54 |
|
|
|
55 |
|
|
/** |
56 |
|
|
* Gets the numerical ID of this effect send. |
57 |
|
|
* @return The numerical ID of this effect |
58 |
|
|
* send or -1 if the effect send number is not set. |
59 |
|
|
*/ |
60 |
|
|
public int |
61 |
|
|
getFxSendId() { return fxSendId; } |
62 |
|
|
|
63 |
|
|
/** |
64 |
|
|
* Sets the numerical ID of this effect send. |
65 |
|
|
* @param id The new effect send number. |
66 |
|
|
*/ |
67 |
|
|
public void |
68 |
|
|
setFxSendId(int id) { fxSendId = id; } |
69 |
|
|
|
70 |
|
|
/** |
71 |
|
|
* Gets the name of this effect send. |
72 |
|
|
* @return The name of this effect send. |
73 |
|
|
*/ |
74 |
|
|
public String |
75 |
|
|
getName() { return name; } |
76 |
|
|
|
77 |
|
|
/** |
78 |
|
|
* Sets the name of this effect send. |
79 |
|
|
* @param name The new name of this effect send. |
80 |
|
|
*/ |
81 |
|
|
public void |
82 |
|
|
setName(String name) { this.name = name; } |
83 |
|
|
|
84 |
|
|
/** |
85 |
|
|
* Gets the MIDI controller, which is able to modify the send level. |
86 |
|
|
* @return The MIDI controller, which is able to modify the |
87 |
|
|
* send level, or -1 if the effect send number is not set. |
88 |
|
|
*/ |
89 |
|
|
public int |
90 |
|
|
getMidiController() { return midiController; } |
91 |
|
|
|
92 |
|
|
/** |
93 |
|
|
* Gets the current send level. |
94 |
|
|
* @return The current send level. |
95 |
|
|
*/ |
96 |
|
|
public float |
97 |
|
|
getLevel() { return level; } |
98 |
|
|
|
99 |
|
|
/** |
100 |
|
|
* Gets a list which reflects to which audio channel of the selected |
101 |
|
|
* audio output device each effect send output channel is routed to. |
102 |
|
|
* The number of the array's position represents the effect send output channel |
103 |
|
|
* and the value at the specified position represents |
104 |
|
|
* to which channel of the selected audio output device the |
105 |
|
|
* effect send output channel is routed to. |
106 |
|
|
* @return A list which reflects to which audio channel of the selected audio |
107 |
|
|
* output device each effect send output channel is routed to. |
108 |
|
|
*/ |
109 |
|
|
public Integer[] |
110 |
|
|
getAudioOutputRouting() { return aor; } |
111 |
|
|
|
112 |
|
|
/** |
113 |
|
|
* Parses a line of text. |
114 |
|
|
* @param s The string to be parsed. |
115 |
|
|
* @return <code>true</code> if the line has been processed, <code>false</code> otherwise. |
116 |
|
|
* @throws LscpException If some error occurs. |
117 |
|
|
*/ |
118 |
|
|
public boolean |
119 |
|
|
parse(String s) throws LscpException { |
120 |
|
|
if(s.startsWith("NAME: ")) { |
121 |
iliev |
1421 |
name = toNonEscapedString(s.substring("NAME: ".length())); |
122 |
iliev |
1140 |
} else if(s.startsWith("MIDI_CONTROLLER: ")) { |
123 |
|
|
s = s.substring("MIDI_CONTROLLER: ".length()); |
124 |
|
|
midiController = Parser.parseInt(s); |
125 |
|
|
} else if(s.startsWith("LEVEL: ")) { |
126 |
|
|
s = s.substring("LEVEL: ".length()); |
127 |
|
|
level = Parser.parseFloat(s); |
128 |
|
|
} else if(s.startsWith("AUDIO_OUTPUT_ROUTING: ")) { |
129 |
|
|
s = s.substring("AUDIO_OUTPUT_ROUTING: ".length()); |
130 |
|
|
aor = Parser.parseIntList(s); |
131 |
|
|
} else return false; |
132 |
|
|
|
133 |
|
|
return true; |
134 |
|
|
} |
135 |
|
|
|
136 |
|
|
/** |
137 |
|
|
* Returns the name of this effect send. |
138 |
|
|
* @return The name of this effect send. |
139 |
|
|
*/ |
140 |
|
|
public String |
141 |
|
|
toString() { return getName(); } |
142 |
|
|
|
143 |
|
|
/** |
144 |
|
|
* Determines whether the specified object is of type |
145 |
|
|
* <code>FxSend</code> and has equal ID. |
146 |
|
|
* @param obj The reference object with which to compare. |
147 |
|
|
* @return <code>true</code> if the specified object is of type |
148 |
|
|
* <code>FxSend</code> and has equal ID. |
149 |
|
|
*/ |
150 |
|
|
public boolean |
151 |
|
|
equals(Object obj) { |
152 |
|
|
if(obj == null) return false; |
153 |
|
|
if(!(obj instanceof FxSend)) return false; |
154 |
|
|
FxSend fxs = (FxSend)obj; |
155 |
|
|
if(getFxSendId() != fxs.getFxSendId()) return false; |
156 |
|
|
|
157 |
|
|
return true; |
158 |
|
|
} |
159 |
|
|
} |