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

Diff of /jsampler/trunk/src/org/jsampler/task/SetChannelVolume.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 910 by iliev, Thu Mar 16 18:08:34 2006 UTC revision 911 by iliev, Mon Aug 7 18:25:58 2006 UTC
# Line 24  package org.jsampler.task; Line 24  package org.jsampler.task;
24    
25  import java.util.logging.Level;  import java.util.logging.Level;
26    
27    import net.sf.juife.Task;
28    
29  import org.jsampler.CC;  import org.jsampler.CC;
30  import org.jsampler.HF;  import org.jsampler.HF;
31    
# Line 31  import static org.jsampler.JSI18n.i18n; Line 33  import static org.jsampler.JSI18n.i18n;
33    
34    
35  /**  /**
36   *   * This taks sets the volume of a specific sampler channel.
37   * @author Grigor Iliev   * @author Grigor Iliev
38   */   */
39  public class SetChannelVolume extends EnhancedTask {  public class SetChannelVolume extends EnhancedTask {
40          private int channel;          private int channel;
41          private float volume;          private float volume;
42                    
43            /**
44             * Creates new instance of <code>SetChannelVolume</code>.
45             * @param channel The sampler channel number.
46             * @param volume The new volume value.
47             */
48          public          public
49          SetChannelVolume(int channel, float volume) {          SetChannelVolume(int channel, float volume) {
50                  setTitle("SetChannelVolume_task");                  setTitle("SetChannelVolume_task");
# Line 47  public class SetChannelVolume extends En Line 54  public class SetChannelVolume extends En
54                  this.volume = volume;                  this.volume = volume;
55          }          }
56                    
57            /** The entry point of the task. */
58          public void          public void
59          run() {          run() {
60                    /*
61                     * Because of the rapid flow of volume change tasks in some cases
62                     * we need to do some optimization to decrease the traffic.
63                     */
64                    boolean b = true;
65                    Task[] tS = CC.getTaskQueue().getPendingTasks();
66                    
67                    for(int i = tS.length - 1; i >= 0; i--) {
68                            Task t = tS[i];
69                            
70                            if(t instanceof SetChannelVolume) {
71                                    SetChannelVolume scv = (SetChannelVolume)t;
72                                    if(scv.getChannelID() == channel) {
73                                            CC.getTaskQueue().removeTask(scv);
74                                    }
75                            }
76                    }
77                    
78                  try { CC.getClient().setChannelVolume(channel, volume); }                  try { CC.getClient().setChannelVolume(channel, volume); }
79                  catch(Exception x) {                  catch(Exception x) {
80                          setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));                          setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
81                          CC.getLogger().log(Level.FINE, getErrorMessage(), x);                          CC.getLogger().log(Level.FINE, getErrorMessage(), x);
82                  }                  }
83          }          }
84            
85            /**
86             * Gets the ID of the channel whose volume should be changed.
87             * @return The ID of the channel whose volume should be changed.
88             */
89            public int
90            getChannelID() { return channel; }
91  }  }

Legend:
Removed from v.910  
changed lines
  Added in v.911

  ViewVC Help
Powered by ViewVC