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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1204 - (show annotations) (download)
Thu May 24 21:43:45 2007 UTC (16 years, 10 months ago) by iliev
File size: 27341 byte(s)
upgrading to version 0.5a

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2007 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 net.sf.juife.Task;
28
29 import org.jsampler.CC;
30 import org.jsampler.HF;
31 import org.jsampler.SamplerChannelModel;
32 import org.jsampler.SamplerModel;
33
34 import org.linuxsampler.lscp.FxSend;
35
36 import static org.jsampler.JSI18n.i18n;
37
38
39 /**
40 * Provides the sampler channel's specific tasks.
41 * @author Grigor Iliev
42 */
43 public class Channel {
44
45 /** Forbits the instantiation of this class. */
46 private Channel() { }
47
48
49 /**
50 * This task creates a new sampler channel.\
51 */
52 public static class Add extends EnhancedTask<Integer> {
53 /** Creates a new instance of <code>Add</code>. */
54 public
55 Add() {
56 setTitle("Channel.Add_task");
57 setDescription(i18n.getMessage("Channel.Add.desc"));
58 }
59
60 /** The entry point of the task. */
61 public void
62 run() {
63 try { setResult(CC.getClient().addSamplerChannel()); }
64 catch(Exception x) {
65 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
66 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
67 }
68 }
69 }
70
71 /**
72 * This task removes the specified sampler channel.
73 */
74 public static class Remove extends EnhancedTask {
75 private int channel;
76
77 /**
78 * Creates new instance of <code>Remove</code>.
79 * @param channel The numerical ID of the channel to remove.
80 */
81 public
82 Remove(int channel) {
83 setTitle("Channel.Remove_task");
84 setDescription(i18n.getMessage("Channel.Remove.desc", channel));
85
86 this.channel = channel;
87 }
88
89 /** The entry point of the task. */
90 public void
91 run() {
92 try { CC.getClient().removeSamplerChannel(channel); }
93 catch(Exception x) {
94 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
95 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
96 }
97 }
98 }
99
100 /**
101 * This task resets the specified sampler channel.
102 */
103 public static class Reset extends EnhancedTask {
104 private int channel;
105
106 /**
107 * Creates new instance of <code>Reset</code>.
108 * @param channel The numerical ID of the channel to reset.
109 */
110 public
111 Reset(int channel) {
112 setTitle("Channel.Reset_task");
113 setDescription(i18n.getMessage("Channel.Reset.desc", channel));
114
115 this.channel = channel;
116 }
117
118 /** The entry point of the task. */
119 public void
120 run() {
121 try { CC.getClient().resetChannel(channel); }
122 catch(Exception x) {
123 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
124 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
125 }
126 }
127 }
128
129 /**
130 * This task sets an audio output channel of a specific sampler channel.
131 */
132 public static class SetAudioOutputChannel extends EnhancedTask {
133 private int chn;
134 private int audioOut;
135 private int audioIn;
136
137 /**
138 * Creates new instance of <code>SetAudioOutputChannel</code>.
139 * @param channel The sampler channel number.
140 * @param audioOut The sampler channel's audio output
141 * channel which should be rerouted.
142 * @param audioIn The audio channel of the selected audio output device where
143 * <code>audioOut</code> should be routed to.
144 */
145 public
146 SetAudioOutputChannel(int channel, int audioOut, int audioIn) {
147 setTitle("Channel.SetAudioOutputChannel_task");
148 String s = i18n.getMessage("Channel.SetAudioOutputChannel.desc", channel);
149 setDescription(s);
150
151 this.chn = channel;
152 this.audioOut = audioOut;
153 this.audioIn = audioIn;
154 }
155
156 /** The entry point of the task. */
157 public void
158 run() {
159 try { CC.getClient().setChannelAudioOutputChannel(chn, audioOut, audioIn); }
160 catch(Exception x) {
161 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
162 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
163 }
164 }
165 }
166
167 /**
168 * This task sets the audio output device of a specific sampler channel.
169 */
170 public static class SetAudioOutputDevice extends EnhancedTask {
171 private int channel;
172 private int deviceID;
173
174 /**
175 * Creates new instance of <code>SetAudioOutputDevice</code>.
176 * @param channel The sampler channel number.
177 * @param deviceID The numerical ID of the audio output device.
178 */
179 public
180 SetAudioOutputDevice(int channel, int deviceID) {
181 setTitle("Channel.SetAudioOutputDevice_task");
182 String s = i18n.getMessage("Channel.SetAudioOutputDevice.desc", channel);
183 setDescription(s);
184
185 this.channel = channel;
186 this.deviceID = deviceID;
187 }
188
189 /** The entry point of the task. */
190 public void
191 run() {
192 try { CC.getClient().setChannelAudioOutputDevice(channel, deviceID); }
193 catch(Exception x) {
194 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
195 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
196 }
197 }
198 }
199
200 /**
201 * This task sets the MIDI input channel the specified sampler channel should listen to.
202 */
203 public static class SetMidiInputChannel extends EnhancedTask {
204 private int channel;
205 private int midiChannel;
206
207 /**
208 * Creates new instance of <code>SetMidiInputChannel</code>.
209 * @param channel The sampler channel number.
210 * @param midiChannel The number of the new MIDI input channel where
211 * <code>channel</code> should listen to or -1 to listen on all 16 MIDI channels.
212 */
213 public
214 SetMidiInputChannel(int channel, int midiChannel) {
215 setTitle("Channel.SetMidiInputChannel_task");
216 String s = i18n.getMessage("Channel.SetMidiInputChannel.desc", channel);
217 setDescription(s);
218
219 this.channel = channel;
220 this.midiChannel = midiChannel;
221 }
222
223 /** The entry point of the task. */
224 public void
225 run() {
226 try { CC.getClient().setChannelMidiInputChannel(channel, midiChannel); }
227 catch(Exception x) {
228 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
229 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
230 }
231 }
232 }
233
234 /**
235 * This task sets the MIDI input device on a specific sampler channel.
236 */
237 public static class SetMidiInputDevice extends EnhancedTask {
238 private int channel;
239 private int deviceID;
240
241 /**
242 * Creates new instance of <code>SetMidiInputDevice</code>.
243 * @param channel The sampler channel number.
244 * @param deviceID The numerical ID of the MIDI input device.
245 */
246 public
247 SetMidiInputDevice(int channel, int deviceID) {
248 setTitle("Channel.SetMidiInputDevice_task");
249 String s = i18n.getMessage("Channel.SetMidiInputDevice.desc", channel);
250 setDescription(s);
251
252 this.channel = channel;
253 this.deviceID = deviceID;
254 }
255
256 /** The entry point of the task. */
257 public void
258 run() {
259 try { CC.getClient().setChannelMidiInputDevice(channel, deviceID); }
260 catch(Exception x) {
261 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
262 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
263 }
264 }
265 }
266
267 /**
268 * This task sets the MIDI input port of a specific sampler channel.
269 */
270 public static class SetMidiInputPort extends EnhancedTask {
271 private int channel;
272 private int port;
273
274 /**
275 * Creates new instance of <code>SetMidiInputPort</code>.
276 * @param channel The sampler channel number.
277 * @param port The MIDI input port number
278 * of the MIDI input device connected to the specified sampler channel.
279 */
280 public
281 SetMidiInputPort(int channel, int port) {
282 setTitle("Channel.SetMidiInputPort_task");
283 setDescription(i18n.getMessage("Channel.SetMidiInputPort.desc", channel));
284
285 this.channel = channel;
286 this.port = port;
287 }
288
289 /** The entry point of the task. */
290 public void
291 run() {
292 try { CC.getClient().setChannelMidiInputPort(channel, port); }
293 catch(Exception x) {
294 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
295 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
296 }
297 }
298 }
299
300 /**
301 * This task loads a sampler engine in a specific sampler channel.
302 * @author Grigor Iliev
303 */
304 public static class LoadEngine extends EnhancedTask {
305 private String engine;
306 private int channel;
307
308 /**
309 * Creates new instance of <code>LoadEngine</code>.
310 * @param engine The name of the engine to load.
311 * @param channel The number of the sampler channel
312 * the deployed engine should be assigned to.
313 */
314 public
315 LoadEngine(String engine, int channel) {
316 this.engine = engine;
317 this.channel = channel;
318
319 setTitle("Channel.LoadEngine_task");
320
321 Object[] objs = { engine, new Integer(channel) };
322 setDescription(i18n.getMessage("Channel.LoadEngine.desc", objs));
323 }
324
325 /** The entry point of the task. */
326 public void
327 run() {
328 try { CC.getClient().loadSamplerEngine(engine, channel); }
329 catch(Exception x) {
330 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
331 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
332 }
333 }
334 }
335
336 /**
337 * This task loads and assigns an instrument to a sampler channel.
338 * @author Grigor Iliev
339 */
340 public static class LoadInstrument extends EnhancedTask {
341 private String filename;
342 private int instrIndex;
343 private int channel;
344
345 /**
346 * Creates new instance of <code>LoadInstrument</code>.
347 * @param filename The name of the instrument file
348 * on the LinuxSampler instance's host system.
349 * @param instrIndex The index of the instrument in the instrument file.
350 * @param channel The number of the sampler channel the
351 * instrument should be assigned to.
352 */
353 public
354 LoadInstrument(String filename, int instrIndex, int channel) {
355 this.filename = filename;
356 this.instrIndex = instrIndex;
357 this.channel = channel;
358
359 setTitle("Channel.LoadInstrument_task");
360 setDescription(i18n.getMessage("Channel.LoadInstrument.desc"));
361 }
362
363 /** The entry point of the task. */
364 public void
365 run() {
366 try { CC.getClient().loadInstrument(filename, instrIndex, channel, true); }
367 catch(Exception x) {
368 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
369 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
370 }
371 }
372 }
373
374 /**
375 * This task assigns the specifed MIDI instrument map to the specified sampler channel.
376 */
377 public static class SetMidiInstrumentMap extends EnhancedTask {
378 private int channel;
379 private int mapId;
380
381 /**
382 * Creates new instance of <code>SetMidiInstrumentMap</code>.
383 * @param channel The sampler channel number.
384 * @param mapId The numerical ID of the MIDI instrument
385 * map that should be assigned to the specified sampler
386 * channel or <code>-1</code> to remove the current map binding.
387 */
388 public
389 SetMidiInstrumentMap(int channel, int mapId) {
390 setTitle("Channel.SetMidiInstrumentMap_task");
391 String s = i18n.getMessage("Channel.SetMidiInstrumentMap.desc", channel);
392 setDescription(s);
393
394 this.channel = channel;
395 this.mapId = mapId;
396 }
397
398 /** The entry point of the task. */
399 public void
400 run() {
401 try { CC.getClient().setChannelMidiInstrumentMap(channel, mapId); }
402 catch(Exception x) {
403 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
404 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
405 }
406 }
407 }
408
409 /**
410 * This task mutes/unmutes a specific sampler channel.
411 */
412 public static class SetMute extends EnhancedTask {
413 private int channel;
414 private boolean mute;
415
416 /**
417 * Creates new instance of <code>SetMute</code>.
418 * @param channel The sampler channel to be muted/unmuted.
419 * @param mute If <code>true</code> the specified channel is muted,
420 * else the channel is unmuted.
421 */
422 public
423 SetMute(int channel, boolean mute) {
424 setTitle("Channel.SetMute_task");
425 setDescription(i18n.getMessage("Channel.SetMute.desc", channel));
426
427 this.channel = channel;
428 this.mute = mute;
429 }
430
431 /** The entry point of the task. */
432 public void
433 run() {
434 try { CC.getClient().setChannelMute(channel, mute); }
435 catch(Exception x) {
436 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
437 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
438 }
439 }
440 }
441
442 /**
443 * This task solos/unsolos a specific sampler channel.
444 */
445 public static class SetSolo extends EnhancedTask {
446 private int channel;
447 private boolean solo;
448
449 /**
450 * Creates new instance of <code>SetSolo</code>.
451 * @param channel The sampler channel number.
452 * @param solo Specify <code>true</code> to solo the specified channel,
453 * <code>false</code> otherwise.
454 */
455 public
456 SetSolo(int channel, boolean solo) {
457 setTitle("Channel.SetSolo_task");
458 setDescription(i18n.getMessage("Channel.SetSolo.desc", channel));
459
460 this.channel = channel;
461 this.solo = solo;
462 }
463
464 /** The entry point of the task. */
465 public void
466 run() {
467 try { CC.getClient().setChannelSolo(channel, solo); }
468 catch(Exception x) {
469 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
470 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
471 }
472 }
473 }
474
475 /**
476 * This taks sets the volume of a specific sampler channel.
477 */
478 public static class SetVolume extends EnhancedTask {
479 private int channel;
480 private float volume;
481
482 /**
483 * Creates new instance of <code>SetVolume</code>.
484 * @param channel The sampler channel number.
485 * @param volume The new volume value.
486 */
487 public
488 SetVolume(int channel, float volume) {
489 setTitle("Channel.SetVolume_task");
490 setDescription(i18n.getMessage("Channel.SetVolume.desc", channel));
491
492 this.channel = channel;
493 this.volume = volume;
494 }
495
496 /** The entry point of the task. */
497 public void
498 run() {
499 /*
500 * Because of the rapid flow of volume change tasks in some cases
501 * we need to do some optimization to decrease the traffic.
502 */
503 boolean b = true;
504 Task[] tS = CC.getTaskQueue().getPendingTasks();
505
506 for(int i = tS.length - 1; i >= 0; i--) {
507 Task t = tS[i];
508
509 if(t instanceof SetVolume) {
510 SetVolume scv = (SetVolume)t;
511 if(scv.getChannelId() == channel) {
512 CC.getTaskQueue().removeTask(scv);
513 }
514 }
515 }
516
517 try { CC.getClient().setChannelVolume(channel, volume); }
518 catch(Exception x) {
519 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
520 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
521 }
522 }
523
524 /**
525 * Gets the ID of the channel whose volume should be changed.
526 * @return The ID of the channel whose volume should be changed.
527 */
528 public int
529 getChannelId() { return channel; }
530 }
531
532 /**
533 * This task updates the settings of a specific sampler channel.
534 */
535 public static class UpdateInfo extends EnhancedTask {
536 private int channel;
537
538 /**
539 * Creates new instance of <code>UpdateInfo</code>.
540 * @param channel The sampler channel to be updated.
541 */
542 public
543 UpdateInfo(int channel) {
544 setTitle("Channel.UpdateInfo_task");
545 setDescription(i18n.getMessage("Channel.UpdateInfo.desc"));
546
547 this.channel = channel;
548 }
549
550 /** The entry point of the task. */
551 public void
552 run() {
553 try {
554 SamplerModel sm = CC.getSamplerModel();
555 sm.updateChannel(CC.getClient().getSamplerChannelInfo(channel));
556 } catch(Exception x) {
557 /*
558 * We don't want to bother the user if error occurs when updating
559 * a channel because in most cases this happens due to a race
560 * condition between delete/update events. So we just log this
561 * error instead to indicate the failure of this task.
562 */
563 String msg = getDescription() + ": " + HF.getErrorMessage(x);
564 CC.getLogger().log(Level.INFO, msg, x);
565 }
566 }
567
568 /**
569 * Gets the ID of the channel for which information should be obtained.
570 * @return The ID of the channel for which information should be obtained.
571 */
572 public int
573 getChannelId() { return channel; }
574 }
575
576 /**
577 * This task creates an additional effect send on the specified sampler channel.
578 */
579 public static class AddFxSend extends EnhancedTask<Integer> {
580 private int channel;
581 private int midiCtrl;
582 private String name;
583
584 /**
585 * Creates a new instance of <code>AddFxSend</code>.
586 * @param channel The sampler channel, on which a new effect send should be added.
587 * @param midiCtrl Defines the MIDI controller, which
588 * will be able alter the effect send level.
589 */
590 public
591 AddFxSend(int channel, int midiCtrl) {
592 this(channel, midiCtrl, null);
593 }
594
595 /**
596 * Creates a new instance of <code>AddFxSend</code>.
597 * @param channel The sampler channel, on which a new effect send should be added.
598 * @param midiCtrl Defines the MIDI controller, which
599 * will be able alter the effect send level.
600 * @param name The name of the effect send entity.
601 * The name does not have to be unique.
602 */
603 public
604 AddFxSend(int channel, int midiCtrl, String name) {
605 setTitle("Channel.AddFxSend_task");
606 setDescription(i18n.getMessage("Channel.AddFxSend.desc"));
607 this.channel = channel;
608 this.midiCtrl = midiCtrl;
609 this.name = name;
610 }
611
612 /** The entry point of the task. */
613 public void
614 run() {
615 try { setResult(CC.getClient().createFxSend(channel, midiCtrl, name)); }
616 catch(Exception x) {
617 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
618 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
619 x.printStackTrace();
620 }
621 }
622 }
623
624 /**
625 * This task removes the specified effect send on the specified sampler channel.
626 */
627 public static class RemoveFxSend extends EnhancedTask {
628 private int channel;
629 private int fxSend;
630
631 /**
632 * Creates a new instance of <code>RemoveFxSend</code>.
633 * @param channel The sampler channel, from which an effect send should be removed.
634 * @param fxSend The ID of the effect send that should be removed.
635 */
636 public
637 RemoveFxSend(int channel, int fxSend) {
638 setTitle("Channel.RemoveFxSend_task");
639 String s = i18n.getMessage("Channel.RemoveFxSend.desc", channel, fxSend);
640 setDescription(s);
641 this.channel = channel;
642 this.fxSend = fxSend;
643 }
644
645 /** The entry point of the task. */
646 public void
647 run() {
648 try { CC.getClient().destroyFxSend(channel, fxSend); }
649 catch(Exception x) {
650 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
651 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
652 }
653 }
654 }
655
656 /**
657 * This task gets the list of effect sends on the specified sampler channel.
658 */
659 public static class GetFxSends extends EnhancedTask<FxSend[]> {
660 private int channel;
661
662 /**
663 * Creates a new instance of <code>GetFxSends</code>.
664 */
665 public
666 GetFxSends() { this(-1); }
667
668 /**
669 * Creates a new instance of <code>GetFxSends</code>.
670 */
671 public
672 GetFxSends(int channel) {
673 setTitle("Channel.GetFxSends_task");
674 setDescription(i18n.getMessage("Channel.GetFxSends.desc", channel));
675
676 this.channel = channel;
677 }
678
679 /** The entry point of the task. */
680 public void
681 run() {
682 try {
683 setResult(CC.getClient().getFxSends(channel));
684 } catch(Exception x) {
685 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
686 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
687 }
688 }
689
690 /**
691 * Gets the channel ID.
692 */
693 public int
694 getChannel() { return channel; }
695
696 /**
697 * Sets the channel, for which effect sends should be obtained.
698 */
699 public void
700 setChannel(int channel) {
701 this.channel = channel;
702 setDescription(i18n.getMessage("Channel.GetFxSends.desc", channel));
703 }
704 }
705
706 /**
707 * This task updates the list of effect sends on the specified sampler channel.
708 */
709 public static class UpdateFxSends extends EnhancedTask {
710 private int channel;
711
712 /**
713 * Creates a new instance of <code>UpdateFxSends</code>.
714 * @param channel The numerical ID of the sampler channel
715 * whose effect send list should be updated.
716 */
717 public
718 UpdateFxSends(int channel) {
719 setTitle("Channel.UpdateFxSends_task");
720 setDescription(i18n.getMessage("Channel.UpdateFxSends.desc", channel));
721
722 this.channel = channel;
723 }
724
725 /** The entry point of the task. */
726 public void
727 run() {
728 try {
729 SamplerChannelModel scm;
730 scm = CC.getSamplerModel().getChannelById(channel);
731 Integer[] fxSendIDs = CC.getClient().getFxSendIDs(channel);
732
733 boolean found = false;
734
735 for(FxSend fxs : scm.getFxSends()) {
736 for(int i = 0; i < fxSendIDs.length; i++) {
737 if(fxSendIDs[i] == fxs.getFxSendId()) {
738 fxSendIDs[i] = -1;
739 found = true;
740 }
741 }
742
743 if(!found) scm.removeFxSendById(fxs.getFxSendId());
744 found = false;
745 }
746
747 FxSend fxs;
748
749 for(int id : fxSendIDs) {
750 if(id >= 0) {
751 fxs = CC.getClient().getFxSendInfo(channel, id);
752 scm.addFxSend(fxs);
753 }
754 }
755 } catch(Exception x) {
756 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
757 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
758 }
759 }
760 }
761
762 /**
763 * This task updates the settings of a specific effect send.
764 */
765 public static class UpdateFxSendInfo extends EnhancedTask {
766 private int channel;
767 private int fxSend;
768
769 /**
770 * Creates new instance of <code>UpdateFxSendInfo</code>.
771 * @param channel The numerical ID of the sampler channel
772 * containing the effect send entity that should be updated.
773 * @param fxSend The numerical ID of the effect send
774 * that should be updated.
775 */
776 public
777 UpdateFxSendInfo(int channel, int fxSend) {
778 setTitle("Channel.UpdateFxSendInfo_task");
779 String s = "Channel.UpdateFxSendInfo.desc";
780 setDescription(i18n.getMessage(s, channel, fxSend));
781
782 this.channel = channel;
783 this.fxSend = fxSend;
784 }
785
786 /** The entry point of the task. */
787 public void
788 run() {
789 try {
790 SamplerChannelModel scm;
791 scm = CC.getSamplerModel().getChannelById(channel);
792 scm.updateFxSend(CC.getClient().getFxSendInfo(channel, fxSend));
793 } catch(Exception x) {
794 /*
795 * We don't want to bother the user if error occurs when updating
796 * an effect send because in most cases this happens due to a race
797 * condition between delete/update events. So we just log this
798 * error instead to indicate the failure of this task.
799 */
800 String msg = getDescription() + ": " + HF.getErrorMessage(x);
801 CC.getLogger().log(Level.INFO, msg, x);
802 }
803 }
804 }
805
806 /**
807 * This taks changes the name of a specific effect send.
808 */
809 public static class SetFxSendName extends EnhancedTask {
810 private int channel;
811 private int fxSend;
812 private String name;
813
814 /**
815 * Creates new instance of <code>SetFxSendName</code>.
816 * @param channel The sampler channel number.
817 * @param fxSend The numerical ID of the effect
818 * send, which name should be changed.
819 * @param name The new name of the effect send entity.
820 */
821 public
822 SetFxSendName(int channel, int fxSend, String name) {
823 setTitle("Channel.SetFxSendName_task");
824 String s = "Channel.SetFxSendName.desc";
825 setDescription(i18n.getMessage(s, channel, fxSend));
826
827 this.channel = channel;
828 this.fxSend = fxSend;
829 this.name = name;
830 }
831
832 /** The entry point of the task. */
833 public void
834 run() {
835 try { CC.getClient().setFxSendName(channel, fxSend, name); }
836 catch(Exception x) {
837 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
838 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
839 }
840 }
841 }
842
843 /**
844 * This taks sets the MIDI controller of a specific effect send.
845 */
846 public static class SetFxSendAudioOutputChannel extends EnhancedTask {
847 private int channel;
848 private int fxSend;
849 private int audioSrc;
850 private int audioDst;
851
852 /**
853 * Creates new instance of <code>SetFxSendAudioOutputChannel</code>.
854 * @param channel The sampler channel number.
855 * @param fxSend The numerical ID of the effect send entity to be rerouted.
856 * @param audioSrc The numerical ID of the effect send's audio output channel,
857 * which should be rerouted.
858 * @param audioDst The audio channel of the selected audio output device
859 * where <code>audioSrc</code> should be routed to.
860 */
861 public
862 SetFxSendAudioOutputChannel(int channel, int fxSend, int audioSrc, int audioDst) {
863 setTitle("Channel.SetFxSendAudioOutputChannel_task");
864 String s = "Channel.SetFxSendAudioOutputChannel.desc";
865 setDescription(i18n.getMessage(s, channel, fxSend));
866
867 this.channel = channel;
868 this.fxSend = fxSend;
869 this.audioSrc = audioSrc;
870 this.audioDst = audioDst;
871 }
872
873 /** The entry point of the task. */
874 public void
875 run() {
876 try {
877 CC.getClient().setFxSendAudioOutputChannel (
878 channel, fxSend, audioSrc, audioDst
879 );
880 }
881 catch(Exception x) {
882 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
883 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
884 }
885 }
886 }
887
888 /**
889 * This taks sets the volume of a specific effect send.
890 */
891 public static class SetFxSendLevel extends EnhancedTask {
892 private int channel;
893 private int fxSend;
894 private float volume;
895
896 /**
897 * Creates new instance of <code>SetFxSendLevel</code>.
898 * @param channel The sampler channel number.
899 * @param fxSend The numerical ID of the effect send, which
900 * volume should be changed.
901 * @param volume The new volume value.
902 */
903 public
904 SetFxSendLevel(int channel, int fxSend, float volume) {
905 setTitle("Channel.SetFxSendLevel_task");
906 String s = i18n.getMessage("Channel.SetFxSendLevel.desc", channel, fxSend);
907 setDescription(s);
908
909 this.channel = channel;
910 this.fxSend = fxSend;
911 this.volume = volume;
912 }
913
914 /** The entry point of the task. */
915 public void
916 run() {
917 try { CC.getClient().setFxSendLevel(channel, fxSend, volume); }
918 catch(Exception x) {
919 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
920 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
921 }
922 }
923 }
924
925 /**
926 * This taks sets the MIDI controller of a specific effect send.
927 */
928 public static class SetFxSendMidiController extends EnhancedTask {
929 private int channel;
930 private int fxSend;
931 private int midiCtrl;
932
933 /**
934 * Creates new instance of <code>SetFxSendMidiController</code>.
935 * @param channel The sampler channel number.
936 * @param fxSend The numerical ID of the effect
937 * send, which MIDI controller should be changed.
938 * @param midiCtrl The MIDI controller which shall be
939 * able to modify the effect send's send level.
940 */
941 public
942 SetFxSendMidiController(int channel, int fxSend, int midiCtrl) {
943 setTitle("Channel.SetFxSendMidiController_task");
944 String s = "Channel.SetFxSendMidiController.desc";
945 setDescription(i18n.getMessage(s, channel, fxSend));
946
947 this.channel = channel;
948 this.fxSend = fxSend;
949 this.midiCtrl = midiCtrl;
950 }
951
952 /** The entry point of the task. */
953 public void
954 run() {
955 try { CC.getClient().setFxSendMidiController(channel, fxSend, midiCtrl); }
956 catch(Exception x) {
957 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
958 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
959 }
960 }
961 }
962
963 }

  ViewVC Help
Powered by ViewVC