/[svn]/jsampler/trunk/src/org/jsampler/task/Global.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/task/Global.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1818 - (show annotations) (download)
Wed Dec 24 17:29:47 2008 UTC (15 years, 4 months ago) by iliev
File size: 7419 byte(s)
* Added support for controlling the global sampler-wide limit of
  maximum voices and disk streams
  (choose Edit/Preferences, then click the `General' tab)
* Fantasia: store the view configuration of audio/MIDI devices and sampler
  channels in the LSCP script when exporting sampler configuration
* Fantasia: Implemented multiple sampler channels' selection
* Fantasia: Added option to move sampler channels up and down
  in the channels list
* Fantasia: Added option to move sampler channels
  to another channels panels

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com>
5 *
6 * This file is part of JSampler.
7 *
8 * JSampler 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 * JSampler 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 JSampler; 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.jsampler.task;
24
25 import java.util.logging.Level;
26
27 import org.jsampler.CC;
28 import org.jsampler.HF;
29
30 import org.linuxsampler.lscp.ServerInfo;
31 import org.linuxsampler.lscp.Instrument;
32
33 import static org.jsampler.JSI18n.i18n;
34
35
36 /**
37 * Provides tasks for managing the global settings of the sampler.
38 * @author Grigor Iliev
39 */
40 public class Global {
41
42 /** Forbits the instantiation of this class. */
43 private Global() { }
44
45 /**
46 * This task retrieves information about the LinuxSampler instance.
47 * @author Grigor Iliev
48 */
49 public static class GetServerInfo extends EnhancedTask<ServerInfo> {
50 /** Creates a new instance of <code>GetServerInfo</code>. */
51 public
52 GetServerInfo() {
53 setTitle("Global.GetServerInfo_task");
54 setDescription(i18n.getMessage("Global.GetServerInfo.desc"));
55 }
56
57 /** The entry point of the task. */
58 @Override
59 public void
60 run() {
61 try { setResult(CC.getClient().getServerInfo()); }
62 catch(Exception x) {
63 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
64 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
65 }
66 }
67 }
68
69 /**
70 * This task resets the whole sampler.
71 * @author Grigor Iliev
72 */
73 public static class ResetSampler extends EnhancedTask {
74 /** Creates a new instance of <code>ResetSampler</code>. */
75 public
76 ResetSampler() {
77 setTitle("Global.ResetSampler_task");
78 setDescription(i18n.getMessage("Global.ResetSampler.desc"));
79 }
80
81 /** The entry point of the task. */
82 @Override
83 public void
84 run() {
85 try { CC.getClient().resetSampler(); }
86 catch(Exception x) {
87 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
88 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
89 }
90 }
91 }
92
93 /**
94 * This task gets the global volume of the sampler.
95 */
96 public static class GetVolume extends EnhancedTask<Float> {
97 /** Creates a new instance of <code>GetVolume</code>. */
98 public
99 GetVolume() {
100 setTitle("Global.GetVolume_task");
101 setDescription(i18n.getMessage("Global.GetVolume.desc"));
102 }
103
104 /** The entry point of the task. */
105 @Override
106 public void
107 run() {
108 try { setResult(CC.getClient().getVolume()); }
109 catch(Exception x) {
110 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
111 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
112 }
113 }
114 }
115
116
117 /**
118 * This task sets the global volume of the sampler.
119 */
120 public static class SetVolume extends EnhancedTask {
121 private float volume;
122
123 /**
124 * Creates new instance of <code>SetVolume</code>.
125 * @param volume The new volume value.
126 */
127 public
128 SetVolume(float volume) {
129 setTitle("Global.SetVolume_task");
130 setDescription(i18n.getMessage("Global.SetVolume.desc"));
131 this.volume = volume;
132 }
133
134 /** The entry point of the task. */
135 @Override
136 public void
137 run() {
138 try {
139 CC.getClient().setVolume(volume);
140 } catch(Exception x) {
141 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
142 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
143 }
144 }
145 }
146
147
148 /**
149 * This task sets the global sampler-wide limits of maximum voices and streams.
150 */
151 public static class SetPolyphony extends EnhancedTask {
152 private int maxVoices;
153 private int maxStreams;
154
155 /**
156 * Creates new instance of <code>SetPolyphony</code>.
157 * @param maxVoices The new global limit of maximum voices or
158 * <code>-1</code> to ignore it.
159 * @param maxStreams The new global limit of maximum disk streams or
160 * <code>-1</code> to ignore it.
161 */
162 public
163 SetPolyphony(int maxVoices, int maxStreams) {
164 setTitle("Global.SetPolyphony_task");
165 setDescription(i18n.getMessage("Global.SetPolyphony.desc"));
166 this.maxVoices = maxVoices;
167 this.maxStreams = maxStreams;
168 }
169
170 /** The entry point of the task. */
171 @Override
172 public void
173 run() {
174 try {
175 if(maxVoices != -1) CC.getClient().setGlobalVoiceLimit(maxVoices);
176 if(maxStreams != -1) CC.getClient().setGlobalStreamLimit(maxStreams);
177 } catch(Exception x) {
178 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
179 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
180 }
181 }
182 }
183
184
185 /**
186 * This task sets the LSCP client's read timeout.
187 */
188 public static class SetClientReadTimeout extends EnhancedTask {
189 private int timeout;
190
191 /**
192 * Creates new instance of <code>SetClientReadTimeout</code>.
193 * @param timeout The new timeout value (in seconds).
194 */
195 public
196 SetClientReadTimeout(int timeout) {
197 setTitle("Global.SetClientReadTimeout_task");
198 setDescription(i18n.getMessage("Global.SetClientReadTimeout.desc"));
199 this.timeout = timeout;
200 }
201
202 /** The entry point of the task. */
203 @Override
204 public void
205 run() {
206 try {
207 CC.getClient().setSoTimeout(timeout * 1000);
208 } catch(Exception x) {
209 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
210 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
211 }
212 }
213 }
214
215 /**
216 * This task gets the list of instruments in the specified instrument file.
217 */
218 public static class GetFileInstruments extends EnhancedTask<Instrument[]> {
219 private final String filename;
220
221 /** Creates a new instance of <code>GetFileInstruments</code>. */
222 public
223 GetFileInstruments(String filename) {
224 this.filename = filename;
225 setTitle("Global.GetFileInstruments_task");
226 setDescription(i18n.getMessage("Global.GetFileInstruments.desc"));
227 }
228
229 /** The entry point of the task. */
230 @Override
231 public void
232 run() {
233 try { setResult(CC.getClient().getFileInstruments(filename)); }
234 catch(Exception x) {
235 String s = getDescription() + ": " + HF.getErrorMessage(x);
236 CC.getLogger().log(Level.FINE, s, x);
237 }
238 }
239 }
240
241 /**
242 * This task gets information about the specified instrument.
243 */
244 public static class GetFileInstrument extends EnhancedTask<Instrument> {
245 private final String filename;
246 private final int instrIdx;
247
248 /** Creates a new instance of <code>GetFileInstrument</code>. */
249 public
250 GetFileInstrument(String filename, int instrIdx) {
251 this.filename = filename;
252 this.instrIdx = instrIdx;
253 setTitle("Global.GetFileInstrument_task");
254 setDescription(i18n.getMessage("Global.GetFileInstrument.desc"));
255 }
256
257 /** The entry point of the task. */
258 @Override
259 public void
260 run() {
261 try { setResult(CC.getClient().getFileInstrumentInfo(filename, instrIdx)); }
262 catch(Exception x) {
263 String s = getDescription() + ": " + HF.getErrorMessage(x);
264 CC.getLogger().log(Level.FINE, s, x);
265 }
266 }
267 }
268
269 public static class DummyTask extends EnhancedTask {
270 @Override
271 public void
272 run() { }
273 }
274 }

  ViewVC Help
Powered by ViewVC