/[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 2195 - (hide annotations) (download)
Tue Jun 28 22:44:39 2011 UTC (12 years, 10 months ago) by iliev
File size: 2777 byte(s)
* Sampler Browser (work in progress): initial implementation of main pane

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

  ViewVC Help
Powered by ViewVC