1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005 Grigor Kirilov Iliev |
* Copyright (C) 2005-2006 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
30 |
import net.sf.juife.event.TaskEvent; |
import net.sf.juife.event.TaskEvent; |
31 |
import net.sf.juife.event.TaskListener; |
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; |
import org.jsampler.event.SamplerChannelEvent; |
36 |
import org.jsampler.event.SamplerChannelListener; |
import org.jsampler.event.SamplerChannelListener; |
37 |
|
|
38 |
|
import org.jsampler.task.Channel; |
39 |
|
import org.jsampler.task.Channel.SetMidiInputChannel; |
40 |
|
import org.jsampler.task.Channel.SetMidiInputDevice; |
41 |
|
import org.jsampler.task.Channel.SetMidiInputPort; |
42 |
|
import org.jsampler.task.Channel.SetMute; |
43 |
|
import org.jsampler.task.Channel.SetSolo; |
44 |
|
import org.jsampler.task.Channel.SetVolume; |
45 |
|
import org.jsampler.task.Channel.UpdateFxSendInfo; |
46 |
import org.jsampler.task.DuplicateChannels; |
import org.jsampler.task.DuplicateChannels; |
47 |
import org.jsampler.task.LoadEngine; |
import org.jsampler.task.LoadEngine; |
48 |
import org.jsampler.task.LoadInstrument; |
import org.jsampler.task.LoadInstrument; |
|
import org.jsampler.task.ResetChannel; |
|
|
import org.jsampler.task.SetChannelAudioOutputDevice; |
|
|
import org.jsampler.task.SetChannelMidiInputChannel; |
|
|
import org.jsampler.task.SetChannelMidiInputDevice; |
|
|
import org.jsampler.task.SetChannelMidiInputPort; |
|
|
import org.jsampler.task.SetChannelVolume; |
|
|
import org.jsampler.task.SetMuteChannel; |
|
|
import org.jsampler.task.SetSoloChannel; |
|
49 |
|
|
50 |
|
import org.linuxsampler.lscp.FxSend; |
51 |
import org.linuxsampler.lscp.SamplerChannel; |
import org.linuxsampler.lscp.SamplerChannel; |
52 |
|
|
53 |
|
|
54 |
/** |
/** |
55 |
* This class provides default implementation of the <code>SamplerChannelModel</code> interface. |
* 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 |
* @author Grigor Iliev |
59 |
*/ |
*/ |
60 |
public class DefaultSamplerChannelModel implements SamplerChannelModel { |
public class DefaultSamplerChannelModel implements SamplerChannelModel { |
65 |
private final Vector<SamplerChannelListener> listeners = |
private final Vector<SamplerChannelListener> listeners = |
66 |
new Vector<SamplerChannelListener>(); |
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 |
* Creates a new instance of <code>DefaultSamplerChannelModel</code> using the |
74 |
* specified channel settings. |
* specified channel settings. |
96 |
removeSamplerChannelListener(SamplerChannelListener l) { listeners.remove(l); } |
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. |
* Gets the sampler channel number. |
114 |
* @return The sampler channel number or -1 if the sampler channel number is not set. |
* @return The sampler channel number or -1 if the sampler channel number is not set. |
115 |
*/ |
*/ |
116 |
public int |
public int |
117 |
getChannelID() { return channel == null ? -1 : channel.getChannelID(); } |
getChannelId() { return channel == null ? -1 : channel.getChannelId(); } |
118 |
|
|
119 |
/** |
/** |
120 |
* Gets the current settings of the sampler channel. |
* Gets the current settings of the sampler channel. |
127 |
/** |
/** |
128 |
* Sets the current settings of the sampler channel. |
* Sets the current settings of the sampler channel. |
129 |
* Note that this method does not changes the channel settings on |
* Note that this method does not changes the channel settings on |
130 |
* the back-end. It is invoked to update them when the back-end |
* the backend. It is invoked just notify for channel settings' changes. |
|
* notifies that the channel settings are changed. |
|
131 |
* @param channel A <code>SamplerChannel</code> instance containing |
* @param channel A <code>SamplerChannel</code> instance containing |
132 |
* the new settings for this sampler channel. |
* the new settings for this sampler channel. |
133 |
* @throws IllegalArgumentException If <code>channel</code> is <code>null</code>. |
* @throws IllegalArgumentException If <code>channel</code> is <code>null</code>. |
150 |
|
|
151 |
/** |
/** |
152 |
* Sets the number of active disk streams. |
* 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. |
* @param count The new number of active disk streams. |
156 |
*/ |
*/ |
157 |
public void |
public void |
171 |
|
|
172 |
/** |
/** |
173 |
* Sets the number of active voices. |
* 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. |
* @param count The new number of active voices. |
177 |
*/ |
*/ |
178 |
public void |
public void |
184 |
} |
} |
185 |
|
|
186 |
/** |
/** |
187 |
* Sets the sampler engine type to be used. |
* 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. |
* @param engine The name of the engine type to be used. |
189 |
*/ |
*/ |
190 |
public void |
public void |
191 |
setEngineType(String engine) { |
setBackendEngineType(String engine) { |
192 |
final LoadEngine loadEngine = new LoadEngine(engine, getChannelID()); |
final LoadEngine loadEngine = new LoadEngine(engine, getChannelId()); |
193 |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
194 |
|
|
195 |
loadEngine.addTaskListener(new TaskListener() { |
loadEngine.addTaskListener(new TaskListener() { |
209 |
} |
} |
210 |
|
|
211 |
/** |
/** |
212 |
* Sets the mute mode of the channel. |
* 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 |
* @param mute Specifies the mute mode. If <code>true</code> the channel is muted, else |
214 |
* the channel is unmuted. |
* the channel is unmuted. |
215 |
*/ |
*/ |
216 |
public void |
public void |
217 |
setMute(boolean mute) { |
setBackendMute(boolean mute) { |
218 |
final SetMuteChannel smc = new SetMuteChannel(getChannelID(), mute); |
final SetMute smc = new SetMute(getChannelId(), mute); |
219 |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
220 |
|
|
221 |
smc.addTaskListener(new TaskListener() { |
smc.addTaskListener(new TaskListener() { |
235 |
} |
} |
236 |
|
|
237 |
/** |
/** |
238 |
* Sets the solo mode of the channel. |
* 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 |
* @param solo Specifies the solo mode. If <code>true</code> the channel is soloed, else |
240 |
* the channel is unsoloed. |
* the channel is unsoloed. |
241 |
*/ |
*/ |
242 |
public void |
public void |
243 |
setSolo(boolean solo) { |
setBackendSolo(boolean solo) { |
244 |
final SetSoloChannel ssc = new SetSoloChannel(getChannelID(), solo); |
final SetSolo ssc = new SetSolo(getChannelId(), solo); |
245 |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
246 |
|
|
247 |
ssc.addTaskListener(new TaskListener() { |
ssc.addTaskListener(new TaskListener() { |
261 |
} |
} |
262 |
|
|
263 |
/** |
/** |
264 |
* Sets the channel volume. |
* Schedules a new task for setting the channel volume on the backend side. |
265 |
* @param volume Specifies the new volume value. |
* @param volume Specifies the new volume value. |
266 |
*/ |
*/ |
267 |
public void |
public void |
268 |
setVolume(float volume) { |
setBackendVolume(float volume) { |
269 |
final SetChannelVolume scv = new SetChannelVolume(getChannelID(), volume); |
final SetVolume scv = new SetVolume(getChannelId(), volume); |
270 |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
271 |
|
|
272 |
scv.addTaskListener(new TaskListener() { |
scv.addTaskListener(new TaskListener() { |
286 |
} |
} |
287 |
|
|
288 |
/** |
/** |
289 |
* Sets the MIDI input device of the channel represented by this model. |
* Schedules a new task for setting on the backend side the MIDI input |
290 |
* @param deviceID Specifies the numerical ID of the MIDI input device to be set. |
* 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 |
public void |
294 |
setMidiInputDevice(int deviceID) { |
setBackendMidiInputDevice(int deviceId) { |
295 |
final Task scmid = new SetChannelMidiInputDevice(getChannelID(), deviceID); |
final Task scmid = new SetMidiInputDevice(getChannelId(), deviceId); |
296 |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
297 |
|
|
298 |
scmid.addTaskListener(new TaskListener() { |
scmid.addTaskListener(new TaskListener() { |
312 |
} |
} |
313 |
|
|
314 |
/** |
/** |
315 |
* Sets the MIDI input port of the channel represented by this model. |
* 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. |
* @param port Specifies the number of the MIDI input port. |
318 |
*/ |
*/ |
319 |
public void |
public void |
320 |
setMidiInputPort(int port) { |
setBackendMidiInputPort(int port) { |
321 |
final Task scmip = new SetChannelMidiInputPort(getChannelID(), port); |
final Task scmip = new SetMidiInputPort(getChannelId(), port); |
322 |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
323 |
|
|
324 |
scmip.addTaskListener(new TaskListener() { |
scmip.addTaskListener(new TaskListener() { |
338 |
} |
} |
339 |
|
|
340 |
/** |
/** |
341 |
* Sets the MIDI channel that the channel represented by this model should listen to. |
* 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 |
* @param channel Specifies the MIDI channel that the channel |
344 |
* represented by this model should listen to. |
* represented by this model should listen to. |
345 |
*/ |
*/ |
346 |
public void |
public void |
347 |
setMidiInputChannel(int channel) { |
setBackendMidiInputChannel(int channel) { |
348 |
final Task scmic = new SetChannelMidiInputChannel(getChannelID(), channel); |
final Task scmic = new SetMidiInputChannel(getChannelId(), channel); |
349 |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
350 |
|
|
351 |
scmic.addTaskListener(new TaskListener() { |
scmic.addTaskListener(new TaskListener() { |
365 |
} |
} |
366 |
|
|
367 |
/** |
/** |
368 |
* Sets the audio output device of the channel represented by this model. |
* Schedules a new task for setting (on the backend side) the audio output |
369 |
* @param deviceID Specifies the numerical ID of the audio output device to be set. |
* 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 |
public void |
373 |
setAudioOutputDevice(int deviceID) { |
setBackendAudioOutputDevice(int deviceId) { |
374 |
final Task scaod = new SetChannelAudioOutputDevice(getChannelID(), deviceID); |
final Task scaod = new Channel.SetAudioOutputDevice(getChannelId(), deviceId); |
375 |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
final SamplerChannelEvent event = new SamplerChannelEvent(this); |
376 |
|
|
377 |
scaod.addTaskListener(new TaskListener() { |
scaod.addTaskListener(new TaskListener() { |
391 |
} |
} |
392 |
|
|
393 |
/** |
/** |
394 |
* Loads and assigns the specified instrument |
* 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. |
* to the sampler channel represented by this model. |
449 |
* @param filename The file name of the instrument to be loaded. |
* @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. |
* @param InstrIndex The index of the instrument in the instrument file to be loaded. |
451 |
*/ |
*/ |
452 |
public void |
public void |
453 |
loadInstrument(String filename, int InstrIndex) { |
loadBackendInstrument(String filename, int InstrIndex) { |
454 |
final Task li = new LoadInstrument(filename, InstrIndex, getChannelID()); |
final Task li = new LoadInstrument(filename, InstrIndex, getChannelId()); |
455 |
CC.getTaskQueue().add(li); |
CC.getTaskQueue().add(li); |
456 |
|
|
457 |
// We leave this event to be notified by the LinuxSampler notification system. |
// We leave this event to be notified by the LinuxSampler notification system. |
458 |
} |
} |
459 |
|
|
460 |
/** Resets the channel. */ |
/** Schedules a new task for reseting the channel. */ |
461 |
public void |
public void |
462 |
resetChannel() { |
resetBackendChannel() { |
463 |
CC.getTaskQueue().add(new ResetChannel(getChannelID())); |
CC.getTaskQueue().add(new org.jsampler.task.Channel.Reset(getChannelId())); |
464 |
|
|
465 |
// We leave this event to be notified by the LinuxSampler notification system. |
// We leave this event to be notified by the LinuxSampler notification system. |
466 |
} |
} |
467 |
|
|
468 |
/** Duplicates the channel. */ |
/** Schedules a new task for duplicating the channel. */ |
469 |
public void |
public void |
470 |
duplicateChannel() { |
duplicateBackendChannel() { |
471 |
CC.getTaskQueue().add(new DuplicateChannels(getChannelInfo())); |
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. */ |
/** Notifies listeners that the sampler channel settings has changed. */ |
681 |
protected void |
protected void |
682 |
fireSamplerChannelChanged() { |
fireSamplerChannelChanged() { |
736 |
fireVoiceCountChanged(SamplerChannelEvent e) { |
fireVoiceCountChanged(SamplerChannelEvent e) { |
737 |
for(SamplerChannelListener l : listeners) l.voiceCountChanged(e); |
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 |
} |
} |