/[svn]/jlscp/trunk/src/org/linuxsampler/lscp/EffectInstanceInfo.java
ViewVC logotype

Contents of /jlscp/trunk/src/org/linuxsampler/lscp/EffectInstanceInfo.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2193 - (show annotations) (download)
Tue Jun 28 20:35:21 2011 UTC (12 years, 9 months ago) by iliev
File size: 3387 byte(s)
* minor refactoring

1 /*
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
23 package org.linuxsampler.lscp;
24
25 import java.util.Vector;
26
27 /**
28 *
29 * @author Grigor Iliev
30 */
31 public class EffectInstanceInfo extends Effect {
32 private int instanceId = -1;
33 private int parameterCount = -1;
34
35 private final Vector<EffectParameter> prmList = new Vector<EffectParameter>();
36
37 /** Creates a new instance of <code>EffectInstanceInfo</code> */
38 public
39 EffectInstanceInfo() { }
40
41 /**
42 * Creates a new instance of <code>EffectInstanceInfo</code> and parses the information
43 * about a specific effect instance described by <code>resultSet</code>.
44 * @param resultSet An array with information categories about an effect entity.
45 * @throws LscpException If the parse fail.
46 */
47 public
48 EffectInstanceInfo(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 instance.
55 * @return The numerical ID of this effect instance
56 * or -1 if the effect instance ID is not set.
57 */
58 public int
59 getInstanceId() { return instanceId; }
60
61 /**
62 * Sets the numerical ID of this effect instance.
63 * @param id The new effect instance ID.
64 */
65 public void
66 setInstanceId(int id) { instanceId = id; }
67
68 /**
69 * Gets the number of parameters (input controls) the effect instance provides,
70 * to allow controlling the effect parameters in realtime.
71 * @return The number of parameters the effect instance provides.
72 */
73 public int
74 getParameterCount() { return parameterCount; }
75
76 /** Gets the effect parameter at the specified position. */
77 public EffectParameter
78 getParameter(int index) { return prmList.get(index); }
79
80 /**
81 * Adds effect parameter.
82 * @param prm The effect parameter to be added.
83 */
84 public void
85 addParameter(EffectParameter prm) { prmList.add(prm); }
86
87 /**
88 * Gets all parameters available for this effect.
89 * @return <code>FloatParameter</code> array with all parameters available for this effect.
90 */
91 public EffectParameter[]
92 getParameters() { return prmList.toArray(new EffectParameter[prmList.size()]); }
93
94 /**
95 * Parses a line of text.
96 * @param s The string to be parsed.
97 * @return <code>true</code> if the line has been processed, <code>false</code> otherwise.
98 * @throws LscpException If some error occurs.
99 */
100 public boolean
101 parse(String s) throws LscpException {
102 if(super.parse(s)) return true;
103
104 if(s.startsWith("INPUT_CONTROLS: ")) {
105 s = s.substring("INPUT_CONTROLS: ".length());
106 parameterCount = Parser.parseInt(s);
107 } else return false;
108
109 return true;
110 }
111 }

  ViewVC Help
Powered by ViewVC