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

Annotation of /jsampler/trunk/src/org/jsampler/DefaultSamplerChannelModel.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1776 - (hide annotations) (download)
Thu Sep 11 18:48:36 2008 UTC (15 years, 7 months ago) by iliev
File size: 27381 byte(s)
* Implemented virtual MIDI keyboard

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

  ViewVC Help
Powered by ViewVC