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