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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2288 - (hide annotations) (download)
Wed Nov 23 21:19:44 2011 UTC (12 years, 5 months ago) by iliev
File size: 2768 byte(s)
* Added option to select a sampler engine in Add/Edit Instrument dialog
* Moved all Swing dependent code outside the JSampler core

1 iliev 2195 /*
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 iliev 2288
26     import net.sf.juife.PDUtils;
27    
28 iliev 2195 import org.jsampler.event.EffectInstanceEvent;
29     import org.jsampler.event.EffectInstanceListener;
30     import org.jsampler.task.Audio;
31     import org.linuxsampler.lscp.EffectInstanceInfo;
32    
33     /**
34     *
35     * @author Grigor Iliev
36     */
37     public class EffectInstance {
38     private EffectInstanceInfo instance;
39    
40     private final ArrayList<EffectInstanceListener> listeners = new ArrayList<EffectInstanceListener>();
41    
42     public
43     EffectInstance(EffectInstanceInfo instance) {
44     this.instance = instance;
45     }
46    
47     /**
48     * Registers the specified listener to be notified when
49     * the settings of the effect instance are changed.
50     * @param l The <code>EffectInstanceListener</code> to register.
51     */
52     public void
53     addEffectInstanceListener(EffectInstanceListener l) { listeners.add(l); }
54    
55     /**
56     * Removes the specified listener.
57     * @param l The <code>EffectInstanceListener</code> to remove.
58     */
59     public void
60     removeEffectInstanceListener(EffectInstanceListener l) { listeners.remove(l); }
61    
62     public int
63     getInstanceId() { return instance.getInstanceId(); }
64    
65     public EffectInstanceInfo
66     getInfo() { return instance; }
67    
68     public void
69     setInfo(EffectInstanceInfo instance) {
70     this.instance = instance;
71     fireInstanceInfoChanged();
72     }
73    
74     public void
75     setBackendParameter(int prmIndex, float newValue) {
76     CC.getTaskQueue().add (
77     new Audio.SetEffectInstanceParameter(getInstanceId(), prmIndex, newValue)
78     );
79     }
80    
81     public void
82     fireInstanceInfoChanged() {
83     final EffectInstanceEvent e = new EffectInstanceEvent(this, this);
84 iliev 2288 PDUtils.runOnUiThread(new Runnable() {
85 iliev 2195 public void
86     run() { fireInstanceInfoChanged(e); }
87     });
88     }
89    
90     /**
91     * This method should be invoked from the event-dispatching thread.
92     */
93     private void
94     fireInstanceInfoChanged(EffectInstanceEvent e) {
95     CC.getSamplerModel().setModified(true);
96     for(EffectInstanceListener l : listeners) l.effectInstanceChanged(e);
97     }
98     }

  ViewVC Help
Powered by ViewVC