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

Contents of /jsampler/trunk/src/org/jsampler/DefaultSamplerChannelModel.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: 25738 byte(s)
upgrading to version 0.5a

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2006 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;
24
25 import java.util.Vector;
26
27 import javax.swing.SwingUtilities;
28
29 import net.sf.juife.Task;
30 import net.sf.juife.event.TaskEvent;
31 import net.sf.juife.event.TaskListener;
32
33 import org.jsampler.event.EffectSendsEvent;
34 import org.jsampler.event.EffectSendsListener;
35 import org.jsampler.event.SamplerChannelEvent;
36 import org.jsampler.event.SamplerChannelListener;
37
38 import org.jsampler.task.Channel;
39 import org.jsampler.task.Channel.LoadEngine;
40 import org.jsampler.task.Channel.LoadInstrument;
41 import org.jsampler.task.Channel.SetMidiInputChannel;
42 import org.jsampler.task.Channel.SetMidiInputDevice;
43 import org.jsampler.task.Channel.SetMidiInputPort;
44 import org.jsampler.task.Channel.SetMute;
45 import org.jsampler.task.Channel.SetSolo;
46 import org.jsampler.task.Channel.SetVolume;
47 import org.jsampler.task.Channel.UpdateFxSendInfo;
48 import org.jsampler.task.DuplicateChannels;
49
50 import org.linuxsampler.lscp.FxSend;
51 import org.linuxsampler.lscp.SamplerChannel;
52
53
54 /**
55 * This class provides default implementation of the <code>SamplerChannelModel</code> interface.
56 * Note that all methods that begin with <code>setBackend</code> alter the settings
57 * on the backend side.
58 * @author Grigor Iliev
59 */
60 public class DefaultSamplerChannelModel implements SamplerChannelModel {
61 private SamplerChannel channel;
62 private int streamCount = 0;
63 private int voiceCount = 0;
64
65 private final Vector<SamplerChannelListener> listeners =
66 new Vector<SamplerChannelListener>();
67
68 private final Vector<EffectSendsListener> fxListeners = new Vector<EffectSendsListener>();
69
70 private final Vector<FxSend> fxSends = new Vector<FxSend>();
71
72 /**
73 * Creates a new instance of <code>DefaultSamplerChannelModel</code> using the
74 * specified channel settings.
75 * @param channel A non-null <code>SamplerChannel</code> instance containing the current
76 * settings of the channel which will be represented by this sampler channel model.
77 * @throws IllegalArgumentException If <code>channel</code> is <code>null</code>.
78 */
79 public DefaultSamplerChannelModel(SamplerChannel channel) {
80 if(channel == null) throw new IllegalArgumentException("channel must be non null");
81 this.channel = channel;
82 }
83
84 /**
85 * Registers the specified listener for receiving event messages.
86 * @param l The <code>SamplerChannelListener</code> to register.
87 */
88 public void
89 addSamplerChannelListener(SamplerChannelListener l) { listeners.add(l); }
90
91 /**
92 * Removes the specified listener.
93 * @param l The <code>SamplerChannelListener</code> to remove.
94 */
95 public void
96 removeSamplerChannelListener(SamplerChannelListener l) { listeners.remove(l); }
97
98 /**
99 * Registers the specified listener for receiving event messages.
100 * @param l The <code>EffectSendsListener</code> to register.
101 */
102 public void
103 addEffectSendsListener(EffectSendsListener l) { fxListeners.add(l); }
104
105 /**
106 * Removes the specified listener.
107 * @param l The <code>EffectSendsListener</code> to remove.
108 */
109 public void
110 removeEffectSendsListener(EffectSendsListener l) { fxListeners.remove(l); }
111
112 /**
113 * Gets the sampler channel number.
114 * @return The sampler channel number or -1 if the sampler channel number is not set.
115 */
116 public int
117 getChannelId() { return channel == null ? -1 : channel.getChannelId(); }
118
119 /**
120 * Gets the current settings of the sampler channel.
121 * @return <code>SamplerChannel</code> instance containing
122 * the current settings of the sampler channel.
123 */
124 public SamplerChannel
125 getChannelInfo() { return channel; }
126
127 /**
128 * Sets the current settings of the sampler channel.
129 * Note that this method does not changes the channel settings on
130 * the backend. It is invoked just notify for channel settings' changes.
131 * @param channel A <code>SamplerChannel</code> instance containing
132 * the new settings for this sampler channel.
133 * @throws IllegalArgumentException If <code>channel</code> is <code>null</code>.
134 */
135 public void
136 setChannelInfo(SamplerChannel channel) {
137 if(channel == null) throw new IllegalArgumentException("channel must be non null");
138 if(this.channel == channel) return;
139
140 this.channel = channel;
141 fireSamplerChannelChanged();
142 }
143
144 /**
145 * Gets the number of active disk streams.
146 * @return The number of active disk streams.
147 */
148 public int
149 getStreamCount() { return streamCount; }
150
151 /**
152 * Sets the number of active disk streams.
153 * Note that this method does <b>not</b> alter the number
154 * of active disk streams on the backend side.
155 * @param count The new number of active disk streams.
156 */
157 public void
158 setStreamCount(int count) {
159 if(streamCount == count) return;
160
161 streamCount = count;
162 fireStreamCountChanged();
163 }
164
165 /**
166 * Gets the number of active voices.
167 * @return The number of active voices.
168 */
169 public int
170 getVoiceCount() { return voiceCount; }
171
172 /**
173 * Sets the number of active voices.
174 * Note that this method does <b>not</b> alter the number
175 * of active voices on the backend side.
176 * @param count The new number of active voices.
177 */
178 public void
179 setVoiceCount(int count) {
180 if(voiceCount == count) return;
181
182 voiceCount = count;
183 fireVoiceCountChanged();
184 }
185
186 /**
187 * Schedules a new task for setting the sampler engine type to be used.
188 * @param engine The name of the engine type to be used.
189 */
190 public void
191 setBackendEngineType(String engine) {
192 final LoadEngine loadEngine = new LoadEngine(engine, getChannelId());
193 final SamplerChannelEvent event = new SamplerChannelEvent(this);
194
195 loadEngine.addTaskListener(new TaskListener() {
196 public void
197 taskPerformed(TaskEvent e) {
198 /*
199 * Because with the invokation of the method the task is considered
200 * to be done, if the task fails, we must notify for a channel
201 * changes. This should be done to revert the old channel settings.
202 */
203 if(loadEngine.doneWithErrors()) fireSamplerChannelChanged(event);
204 }
205 });
206 CC.getTaskQueue().add(loadEngine);
207
208 // We leave this event to be notified by the LinuxSampler notification system.
209 }
210
211 /**
212 * Schedules a new task for setting the mute mode of the channel.
213 * @param mute Specifies the mute mode. If <code>true</code> the channel is muted, else
214 * the channel is unmuted.
215 */
216 public void
217 setBackendMute(boolean mute) {
218 final SetMute smc = new SetMute(getChannelId(), mute);
219 final SamplerChannelEvent event = new SamplerChannelEvent(this);
220
221 smc.addTaskListener(new TaskListener() {
222 public void
223 taskPerformed(TaskEvent e) {
224 /*
225 * Because with the invokation of the method the task is considered
226 * to be done, if the task fails, we must notify for a channel
227 * changes. This should be done to revert the old channel settings.
228 */
229 if(smc.doneWithErrors()) fireSamplerChannelChanged(event);
230 }
231 });
232 CC.getTaskQueue().add(smc);
233
234 // We leave this event to be notified by the LinuxSampler notification system.
235 }
236
237 /**
238 * Schedules a new task for setting on the backend side the solo mode of the channel.
239 * @param solo Specifies the solo mode. If <code>true</code> the channel is soloed, else
240 * the channel is unsoloed.
241 */
242 public void
243 setBackendSolo(boolean solo) {
244 final SetSolo ssc = new SetSolo(getChannelId(), solo);
245 final SamplerChannelEvent event = new SamplerChannelEvent(this);
246
247 ssc.addTaskListener(new TaskListener() {
248 public void
249 taskPerformed(TaskEvent e) {
250 /*
251 * Because with the invokation of the method the task is considered
252 * to be done, if the task fails, we must notify for a channel
253 * changes. This should be done to revert the old channel settings.
254 */
255 if(ssc.doneWithErrors()) fireSamplerChannelChanged(event);
256 }
257 });
258 CC.getTaskQueue().add(ssc);
259
260 // We leave this event to be notified by the LinuxSampler notification system.
261 }
262
263 /**
264 * Schedules a new task for setting the channel volume on the backend side.
265 * @param volume Specifies the new volume value.
266 */
267 public void
268 setBackendVolume(float volume) {
269 final SetVolume scv = new SetVolume(getChannelId(), volume);
270 final SamplerChannelEvent event = new SamplerChannelEvent(this);
271
272 scv.addTaskListener(new TaskListener() {
273 public void
274 taskPerformed(TaskEvent e) {
275 /*
276 * Because with the invokation of the method the task is considered
277 * to be done, if the task fails, we must notify for a channel
278 * changes. This should be done to revert the old channel settings.
279 */
280 if(scv.doneWithErrors()) fireSamplerChannelChanged(event);
281 }
282 });
283 CC.getTaskQueue().add(scv);
284
285 // We leave this event to be notified by the LinuxSampler notification system.
286 }
287
288 /**
289 * Schedules a new task for setting on the backend side the MIDI input
290 * device of the channel represented by this model.
291 * @param deviceId Specifies the numerical ID of the MIDI input device to be set.
292 */
293 public void
294 setBackendMidiInputDevice(int deviceId) {
295 final Task scmid = new SetMidiInputDevice(getChannelId(), deviceId);
296 final SamplerChannelEvent event = new SamplerChannelEvent(this);
297
298 scmid.addTaskListener(new TaskListener() {
299 public void
300 taskPerformed(TaskEvent e) {
301 /*
302 * Because with the invokation of the method the task is considered
303 * to be done, if the task fails, we must notify for a channel
304 * changes. This should be done to revert the old channel settings.
305 */
306 if(scmid.doneWithErrors()) fireSamplerChannelChanged(event);
307 }
308 });
309 CC.getTaskQueue().add(scmid);
310
311 // We leave this event to be notified by the LinuxSampler notification system.
312 }
313
314 /**
315 * Schedules a new task for setting (on the backend side) the
316 * MIDI input port of the channel represented by this model.
317 * @param port Specifies the number of the MIDI input port.
318 */
319 public void
320 setBackendMidiInputPort(int port) {
321 final Task scmip = new SetMidiInputPort(getChannelId(), port);
322 final SamplerChannelEvent event = new SamplerChannelEvent(this);
323
324 scmip.addTaskListener(new TaskListener() {
325 public void
326 taskPerformed(TaskEvent e) {
327 /*
328 * Because with the invokation of the method the task is considered
329 * to be done, if the task fails, we must notify for a channel
330 * changes. This should be done to revert the old channel settings.
331 */
332 if(scmip.doneWithErrors()) fireSamplerChannelChanged(event);
333 }
334 });
335 CC.getTaskQueue().add(scmip);
336
337 // We leave this event to be notified by the LinuxSampler notification system.
338 }
339
340 /**
341 * Schedules a new task for setting (on the backend side) the MIDI channel
342 * that the channel represented by this model should listen to.
343 * @param channel Specifies the MIDI channel that the channel
344 * represented by this model should listen to.
345 */
346 public void
347 setBackendMidiInputChannel(int channel) {
348 final Task scmic = new SetMidiInputChannel(getChannelId(), channel);
349 final SamplerChannelEvent event = new SamplerChannelEvent(this);
350
351 scmic.addTaskListener(new TaskListener() {
352 public void
353 taskPerformed(TaskEvent e) {
354 /*
355 * Because with the invokation of the method the task is considered
356 * to be done, if the task fails, we must notify for a channel
357 * changes. This should be done to revert the old channel settings.
358 */
359 if(scmic.doneWithErrors()) fireSamplerChannelChanged(event);
360 }
361 });
362 CC.getTaskQueue().add(scmic);
363
364 // We leave this event to be notified by the LinuxSampler notification system.
365 }
366
367 /**
368 * Schedules a new task for setting (on the backend side) the audio output
369 * device of the channel represented by this model.
370 * @param deviceId Specifies the numerical ID of the audio output device to be set.
371 */
372 public void
373 setBackendAudioOutputDevice(int deviceId) {
374 final Task scaod = new Channel.SetAudioOutputDevice(getChannelId(), deviceId);
375 final SamplerChannelEvent event = new SamplerChannelEvent(this);
376
377 scaod.addTaskListener(new TaskListener() {
378 public void
379 taskPerformed(TaskEvent e) {
380 /*
381 * Because with the invokation of the method the task is considered
382 * to be done, if the task fails, we must notify for a channel
383 * changes. This should be done to revert the old channel settings.
384 */
385 if(scaod.doneWithErrors()) fireSamplerChannelChanged(event);
386 }
387 });
388 CC.getTaskQueue().add(scaod);
389
390 // We leave this event to be notified by the LinuxSampler notification system.
391 }
392
393 /**
394 * Sets the destination of the destination of the specified audio channel.
395 * @param audioSrc The numerical ID of the sampler channel's audio
396 * output channel, which should be rerouted.
397 * @param audioDst The audio channel of the selected audio output device
398 * where <code>audioSrc</code> should be routed to.
399 */
400 public void
401 setBackendAudioOutputChannel(int audioSrc, int audioDst) {
402 final Task t;
403 t = new Channel.SetAudioOutputChannel(getChannelId(), audioSrc, audioDst);
404 final SamplerChannelEvent event = new SamplerChannelEvent(this);
405
406 t.addTaskListener(new TaskListener() {
407 public void
408 taskPerformed(TaskEvent e) {
409 /*
410 * Because with the invokation of the method the task is considered
411 * to be done, if the task fails, we must notify for a channel
412 * changes. This should be done to revert the old channel settings.
413 */
414 if(t.doneWithErrors()) fireSamplerChannelChanged(event);
415 }
416 });
417 CC.getTaskQueue().add(t);
418 }
419
420 /**
421 * Schedules a new task for assigning (on the backend side) the
422 * specified MIDI instrument map to this sampler channel.
423 * @param mapId Specify the numerical ID of the MIDI instrument
424 * map that should be assigned to this sampler
425 * channel or <code>-1</code> to remove the current map binding.
426 */
427 public void
428 setBackendMidiInstrumentMap(int mapId) {
429 final Task t = new Channel.SetMidiInstrumentMap(getChannelId(), mapId);
430 final SamplerChannelEvent event = new SamplerChannelEvent(this);
431
432 t.addTaskListener(new TaskListener() {
433 public void
434 taskPerformed(TaskEvent e) {
435 /*
436 * Because with the invokation of the method the task is considered
437 * to be done, if the task fails, we must notify for a channel
438 * changes. This should be done to revert the old channel settings.
439 */
440 if(t.doneWithErrors()) fireSamplerChannelChanged(event);
441 }
442 });
443 CC.getTaskQueue().add(t);
444 }
445
446 /**
447 * Schedules a new task for loading and assigning the specified instrument
448 * to the sampler channel represented by this model.
449 * @param filename The file name of the instrument to be loaded.
450 * @param InstrIndex The index of the instrument in the instrument file to be loaded.
451 */
452 public void
453 loadBackendInstrument(String filename, int InstrIndex) {
454 final Task li = new LoadInstrument(filename, InstrIndex, getChannelId());
455 CC.getTaskQueue().add(li);
456
457 // We leave this event to be notified by the LinuxSampler notification system.
458 }
459
460 /** Schedules a new task for reseting the channel. */
461 public void
462 resetBackendChannel() {
463 CC.getTaskQueue().add(new org.jsampler.task.Channel.Reset(getChannelId()));
464
465 // We leave this event to be notified by the LinuxSampler notification system.
466 }
467
468 /** Schedules a new task for duplicating the channel. */
469 public void
470 duplicateBackendChannel() {
471 CC.getTaskQueue().add(new DuplicateChannels(getChannelInfo()));
472 }
473
474 /**
475 * Schedules a new task for adding a new effect send on the
476 * backend side. The effect send will be actually added to this model
477 * when the backend notifies for its creation.
478 * @param midiCtrl Defines the MIDI controller, which
479 * will be able alter the effect send level.
480 */
481 public void
482 addBackendFxSend(int midiCtrl) {
483 CC.getTaskQueue().add(new Channel.AddFxSend(getChannelId(), midiCtrl));
484 // We leave this event to be notified by the LinuxSampler notification system.
485 }
486
487 /**
488 * Schedules a new task for adding a new effect send on the
489 * backend side. The effect send will be actually added to this model
490 * when the backend notifies for its creation.
491 * @param midiCtrl Defines the MIDI controller, which
492 * will be able alter the effect send level.
493 * @param name The name of the effect send entity.
494 * The name does not have to be unique.
495 */
496 public void
497 addBackendFxSend(int midiCtrl, String name) {
498 CC.getTaskQueue().add(new Channel.AddFxSend(getChannelId(), midiCtrl, name));
499 // We leave this event to be notified by the LinuxSampler notification system.
500 }
501
502 /**
503 * Adds the specified effect send.
504 * @param fxSend The effect send to be added.
505 */
506 public void
507 addFxSend(FxSend fxSend) {
508 fxSends.add(fxSend);
509 fireFxSendAdded(fxSend);
510 }
511
512 /**
513 * Schedules a new task for removing the specified effect send on the backend side.
514 * @param fxSendId The ID of the effect send to remove.
515 */
516 public void
517 removeBackendFxSend(int fxSendId) {
518 CC.getTaskQueue().add(new Channel.RemoveFxSend(getChannelId(), fxSendId));
519 }
520
521 /**
522 * Gets the effect send at the specified position.
523 * @param index The index of the effect send to be returned.
524 * @return The effect send at the specified position.
525 */
526 public FxSend
527 getFxSend(int index) { return fxSends.get(index); }
528
529 /**
530 * Gets the effect send with the specified ID.
531 * @param fxSendId The ID of the effect send to return.
532 * @return The effect send with the specified ID or <code>null</code>
533 * if there is no effect send with ID <code>fxSendId</code>.
534 */
535 public FxSend
536 getFxSendById(int fxSendId) {
537 for(FxSend fxs : fxSends) {
538 if(fxs.getFxSendId() == fxSendId) return fxs;
539 }
540
541 return null;
542 }
543
544 /**
545 * Removes the effect send at the specified position.
546 * @param index The position of the effect send to remove.
547 * @return The removed effect send.
548 */
549 public FxSend
550 removeFxSend(int index) {
551 FxSend fxs = fxSends.remove(index);
552 fireFxSendRemoved(fxs);
553 return fxs;
554 }
555
556 /**
557 * Removes the specified effect send.
558 * @param fxSendId The ID of the effect send to remove.
559 * @return <code>true</code> if the effect send is removed successfully, <code>false</code>
560 * if the channel does not contain effect send with ID <code>fxSendId</code>.
561 */
562 public boolean
563 removeFxSendById(int fxSendId) {
564 for(int i = 0; i < fxSends.size(); i++) {
565 FxSend fxs = fxSends.get(i);
566 if(fxs.getFxSendId() == fxSendId) {
567 fxSends.remove(i);
568 fireFxSendRemoved(fxs);
569 return true;
570 }
571 }
572
573 return false;
574 }
575
576 /** Removes all effect sends from this channel. */
577 public void
578 removeAllFxSends() {
579 for(int i = fxSends.size() - 1; i >= 0; i--) {
580 FxSend fxs = fxSends.get(i);
581 fxSends.removeElementAt(i);
582 fireFxSendRemoved(fxs);
583 }
584 }
585
586 /**
587 * Updates the specified effect send.
588 * @param fxSend The effect send to update.
589 */
590 public void
591 updateFxSend(FxSend fxSend) {
592 for(int i = 0; i < fxSends.size(); i++) {
593 FxSend fxs = fxSends.get(i);
594 if(fxs.getFxSendId() == fxSend.getFxSendId()) {
595 fxSends.setElementAt(fxSend, i);
596 fireFxSendUpdated(fxSend);
597 return;
598 }
599 }
600 }
601
602 /**
603 * Gets the current number of effect sends.
604 * @return The current number of effect sends.
605 */
606 public int
607 getFxSendCount() { return fxSends.size(); }
608
609 /**
610 * Gets the current list of effect sends.
611 * @return The current list of effect sends.
612 */
613 public FxSend[]
614 getFxSends() { return fxSends.toArray(new FxSend[fxSends.size()]); }
615
616 /**
617 * Sets the name of the specified effect send.
618 * @param fxSend The numerical ID of the effect send.
619 * @param name The new name of the effect send entity.
620 */
621 public void
622 setBackendFxSendName(final int fxSend, String name) {
623 final Task t = new Channel.SetFxSendName(getChannelId(), fxSend, name);
624 t.addTaskListener(new TaskListener() {
625 public void
626 taskPerformed(TaskEvent e) {
627 /*
628 * Because with the invokation of the method the task is considered
629 * to be done, if the task fails, we must update the settings.
630 */
631 if(t.doneWithErrors()) {
632 int id = getChannelId();
633 CC.getTaskQueue().add(new UpdateFxSendInfo(id, fxSend));
634 }
635 }
636 });
637 CC.getTaskQueue().add(t);
638 }
639
640 /**
641 * Sets the destination of an effect send's audio channel.
642 * @param fxSend The numerical ID of the effect send entity to be rerouted.
643 * @param audioSrc The numerical ID of the effect send's audio output channel,
644 * which should be rerouted.
645 * @param audioDst The audio channel of the selected audio output device
646 * where <code>audioSrc</code> should be routed to.
647 */
648 public void
649 setBackendFxSendAudioOutputChannel(int fxSend, int audioSrc, int audioDst) {
650 Task t = new Channel.SetFxSendAudioOutputChannel (
651 getChannelId(), fxSend, audioSrc, audioDst
652 );
653
654 CC.getTaskQueue().add(t);
655 }
656
657 /**
658 * Sets the MIDI controller of the specified effect send.
659 * @param fxSend The numerical ID of the effect send.
660 * @param midiCtrl The MIDI controller which shall be
661 * able to modify the effect send's send level.
662 */
663 public void
664 setBackendFxSendMidiController(int fxSend, int midiCtrl) {
665 Task t = new Channel.SetFxSendMidiController(getChannelId(), fxSend, midiCtrl);
666 CC.getTaskQueue().add(t);
667 }
668
669 /**
670 * Sets the volume of the specified effect send.
671 * @param fxSend The numerical ID of the effect
672 * send, which volume should be changed.
673 * @param level The new volume value.
674 */
675 public void
676 setBackendFxSendLevel(int fxSend, float level) {
677 CC.getTaskQueue().add(new Channel.SetFxSendLevel(getChannelId(), fxSend, level));
678 }
679
680 /** Notifies listeners that the sampler channel settings has changed. */
681 protected void
682 fireSamplerChannelChanged() {
683 final SamplerChannelEvent e = new SamplerChannelEvent(this);
684
685 SwingUtilities.invokeLater(new Runnable() {
686 public void
687 run() { fireSamplerChannelChanged(e); }
688 });
689 }
690
691 /**
692 * Notifies listeners that the sampler channel settings has changed.
693 * This method should be invoked from the event-dispatching thread.
694 */
695 protected void
696 fireSamplerChannelChanged(SamplerChannelEvent e) {
697 for(SamplerChannelListener l : listeners) l.channelChanged(e);
698 }
699
700 /** Notifies listeners that the number of active disk streams has changed. */
701 protected void
702 fireStreamCountChanged() {
703 final SamplerChannelEvent e = new SamplerChannelEvent(this);
704
705 SwingUtilities.invokeLater(new Runnable() {
706 public void
707 run() { fireStreamCountChanged(e); }
708 });
709 }
710
711 /**
712 * Notifies listeners that the number of active disk streams has changed.
713 * This method should be invoked from the event-dispatching thread.
714 */
715 protected void
716 fireStreamCountChanged(SamplerChannelEvent e) {
717 for(SamplerChannelListener l : listeners) l.streamCountChanged(e);
718 }
719
720 /** Notifies listeners that the number of active voices has changed. */
721 protected void
722 fireVoiceCountChanged() {
723 final SamplerChannelEvent e = new SamplerChannelEvent(this);
724
725 SwingUtilities.invokeLater(new Runnable() {
726 public void
727 run() { fireVoiceCountChanged(e); }
728 });
729 }
730
731 /**
732 * Notifies listeners that the number of active voices has changed.
733 * This method should be invoked from the event-dispatching thread.
734 */
735 protected void
736 fireVoiceCountChanged(SamplerChannelEvent e) {
737 for(SamplerChannelListener l : listeners) l.voiceCountChanged(e);
738 }
739
740 /**
741 * Notifies listeners that the specified effect send has been added to the channel.
742 */
743 protected void
744 fireFxSendAdded(FxSend fxSend) {
745 final EffectSendsEvent e = new EffectSendsEvent(this, fxSend);
746
747 SwingUtilities.invokeLater(new Runnable() {
748 public void
749 run() { fireFxSendAdded(e); }
750 });
751 }
752
753 /**
754 * Notifies listeners that the specified effect send has been added to the channel.
755 * This method should be invoked from the event-dispatching thread.
756 */
757 protected void
758 fireFxSendAdded(EffectSendsEvent e) {
759 for(EffectSendsListener l : fxListeners) l.effectSendAdded(e);
760 }
761
762 /** Notifies listeners that the specified effect send has been removed. */
763 protected void
764 fireFxSendRemoved(FxSend fxSend) {
765 final EffectSendsEvent e = new EffectSendsEvent(this, fxSend);
766
767 SwingUtilities.invokeLater(new Runnable() {
768 public void
769 run() { fireFxSendRemoved(e); }
770 });
771 }
772
773 /**
774 * Notifies listeners that the specified effect send has been removed.
775 * This method should be invoked from the event-dispatching thread.
776 */
777 protected void
778 fireFxSendRemoved(EffectSendsEvent e) {
779 for(EffectSendsListener l : fxListeners) l.effectSendRemoved(e);
780 }
781
782 /** Notifies listeners that the specified effect send has been updated. */
783 protected void
784 fireFxSendUpdated(FxSend fxSend) {
785 final EffectSendsEvent e = new EffectSendsEvent(this, fxSend);
786
787 SwingUtilities.invokeLater(new Runnable() {
788 public void
789 run() { fireFxSendUpdated(e); }
790 });
791 }
792
793 /**
794 * Notifies listeners that the specified effect send has been updated.
795 * This method should be invoked from the event-dispatching thread.
796 */
797 protected void
798 fireFxSendUpdated(EffectSendsEvent e) {
799 for(EffectSendsListener l : fxListeners) l.effectSendChanged(e);
800 }
801 }

  ViewVC Help
Powered by ViewVC