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

Contents of /jsampler/trunk/src/org/jsampler/EffectChain.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2192 - (show annotations) (download)
Fri Jun 24 21:34:51 2011 UTC (12 years, 10 months ago) by iliev
File size: 3020 byte(s)
* Initial implementation of Sampler Browser
  (choose Window/Sampler Browser) - another way to view/edit
  the sampler configuration (work in progress - for now only
  support for viewing/editing send effects)

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2011 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 package org.jsampler;
23
24 import java.util.ArrayList;
25 import java.util.Arrays;
26 import javax.swing.SwingUtilities;
27 import org.jsampler.event.EffectChainEvent;
28 import org.jsampler.event.EffectChainListener;
29 import org.linuxsampler.lscp.EffectInstance;
30
31 /**
32 *
33 * @author Grigor Iliev
34 */
35 public class EffectChain extends org.linuxsampler.lscp.EffectChain {
36 private final ArrayList<EffectChainListener> listeners = new ArrayList<EffectChainListener>();
37
38 public
39 EffectChain(org.linuxsampler.lscp.EffectChain chain) {
40 setChainId(chain.getChainId());
41
42 effectInstances = new EffectInstance[chain.getEffectInstanceCount()];
43 for(int i = 0; i < chain.getEffectInstanceCount(); i++) {
44 effectInstances[i] = chain.getEffectInstance(i);
45 }
46 }
47
48 /**
49 * Registers the specified listener to be notified when
50 * the settings of the effect chain are changed.
51 * @param l The <code>EffectChainListener</code> to register.
52 */
53 public void
54 addAudioDeviceListener(EffectChainListener l) { listeners.add(l); }
55
56 /**
57 * Removes the specified listener.
58 * @param l The <code>EffectChainListener</code> to remove.
59 */
60 public void
61 removeAudioDeviceListener(EffectChainListener l) { listeners.remove(l); }
62
63 public EffectInstance[]
64 getEffectInstances() {
65 return Arrays.copyOf(effectInstances, effectInstances.length);
66 }
67
68 public void
69 setEffectInstances(EffectInstance[] instances) {
70 effectInstances = instances;
71 fireEffectInstanceListChanged(instances);
72
73 }
74
75 public int
76 getIndex(int instanceId) {
77 for(int i = 0; i < effectInstances.length; i++) {
78 if(effectInstances[i].getInstanceId() == instanceId) {
79 return i;
80 }
81 }
82 return -1;
83 }
84
85 private void
86 fireEffectInstanceListChanged(EffectInstance[] instances) {
87 final EffectChainEvent e = new EffectChainEvent(this, this, instances);
88 SwingUtilities.invokeLater(new Runnable() {
89 public void
90 run() { fireEffectInstanceListChanged(e); }
91 });
92 }
93
94 /**
95 * This method should be invoked from the event-dispatching thread.
96 */
97 private void
98 fireEffectInstanceListChanged(EffectChainEvent e) {
99 CC.getSamplerModel().setModified(true);
100 for(EffectChainListener l : listeners) l.effectInstanceListChanged(e);
101 }
102 }

  ViewVC Help
Powered by ViewVC