1 |
iliev |
2190 |
/* |
2 |
|
|
* jlscp - a java LinuxSampler control protocol API |
3 |
|
|
* |
4 |
|
|
* Copyright (C) 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 |
|
|
package org.linuxsampler.lscp; |
23 |
|
|
|
24 |
|
|
/** |
25 |
|
|
* |
26 |
|
|
* @author Grigor Iliev |
27 |
|
|
*/ |
28 |
|
|
public class EffectParameter extends FloatParameter { |
29 |
iliev |
2194 |
private final int instanceId; |
30 |
|
|
private final int index; |
31 |
iliev |
2190 |
|
32 |
iliev |
2194 |
public EffectParameter(int instanceId, int index) { |
33 |
|
|
this.instanceId = instanceId; |
34 |
|
|
this.index = index; |
35 |
|
|
} |
36 |
iliev |
2190 |
|
37 |
iliev |
2194 |
/** Gets the numerical ID of the effect instance to which this parameter belongs. */ |
38 |
|
|
public int |
39 |
|
|
getEffectInstanceId() { return instanceId; } |
40 |
|
|
|
41 |
|
|
/** Gets the position of the parameter in the effect instance's parameter list. */ |
42 |
|
|
public int |
43 |
|
|
getIndex() { return index; } |
44 |
|
|
|
45 |
iliev |
2190 |
/** |
46 |
|
|
* Parses a line of text. |
47 |
|
|
* @param s The string to be parsed. |
48 |
|
|
* @return <code>true</code> if the line has been processed, <code>false</code> otherwise. |
49 |
|
|
* @throws LscpException If some error occurs. |
50 |
|
|
*/ |
51 |
|
|
@Override |
52 |
|
|
public boolean |
53 |
|
|
parse(String s) throws LscpException { |
54 |
iliev |
2193 |
if(s.startsWith("DESCRIPTION: ")) { |
55 |
|
|
s = s.substring("DESCRIPTION: ".length(), s.length()); |
56 |
|
|
setDescription(Parser.toNonEscapedString(s)); |
57 |
|
|
return true; |
58 |
|
|
} |
59 |
|
|
|
60 |
iliev |
2190 |
if(super.parse(s)) return true; |
61 |
|
|
else if(s.startsWith("VALUE: ")) { |
62 |
|
|
s = s.substring("VALUE: ".length(), s.length()); |
63 |
|
|
setValue(Parser.parseFloat(s)); |
64 |
|
|
return true; |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
return false; |
68 |
|
|
} |
69 |
iliev |
2194 |
|
70 |
|
|
@Override |
71 |
|
|
public String |
72 |
|
|
toString() { return getDescription() != null ? getDescription() : super.toString(); } |
73 |
iliev |
2190 |
} |