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

Diff of /jsampler/trunk/src/org/jsampler/CC.java

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

revision 1786 by iliev, Wed Oct 8 22:38:15 2008 UTC revision 1866 by iliev, Sun Mar 15 19:40:29 2009 UTC
# Line 1  Line 1 
1  /*  /*
2   *   JSampler - a java front-end for LinuxSampler   *   JSampler - a java front-end for LinuxSampler
3   *   *
4   *   Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com>   *   Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 126  public class CC { Line 126  public class CC {
126           * @return The task queue to be used for scheduling tasks           * @return The task queue to be used for scheduling tasks
127           * for execution out of the event-dispatching thread.           * for execution out of the event-dispatching thread.
128           */           */
129          public static TaskQueue          public static synchronized TaskQueue
130          getTaskQueue() { return taskQueue; }          getTaskQueue() { return taskQueue; }
131                    
132          /**          /**
133           * Adds the specified task to the task queue. All task in the           * Adds the specified task to the task queue. All task in the
134           * queue equal to the specified task are removed from the queue.           * queue equal to the specified task are removed from the queue.
135           */           */
136          public static void          public static synchronized void
137          scheduleTask(Task t) {          scheduleTask(Task t) {
138                  while(getTaskQueue().removeTask(t)) { }                  while(getTaskQueue().removeTask(t)) { }
139                                    
# Line 142  public class CC { Line 142  public class CC {
142                    
143          /**          /**
144           * Adds the specified task to the task queue only if the last           * Adds the specified task to the task queue only if the last
145           * task in the is not equal to <code>t</code>.           * task in the queue is not equal to <code>t</code>.
146           */           */
147          public static void          public static synchronized void
148          addTask(Task t) {          addTask(Task t) {
149                  Task[] tasks = getTaskQueue().getPendingTasks();                  Task[] tasks = getTaskQueue().getPendingTasks();
150                  if(tasks.length > 0 && tasks[tasks.length - 1].equals(t)) return;                  if(tasks.length > 0 && tasks[tasks.length - 1].equals(t)) return;
# Line 255  public class CC { Line 255  public class CC {
255                          actionPerformed(ActionEvent e) { CC.getProgressIndicator().start(); }                          actionPerformed(ActionEvent e) { CC.getProgressIndicator().start(); }
256                  });                  });
257                                    
258                  taskQueue.addTaskQueueListener(getHandler());                  getTaskQueue().addTaskQueueListener(getHandler());
259                                    
260                  taskQueue.start();                  getTaskQueue().start();
261                                    
262                  getClient().removeChannelCountListener(getHandler());                  getClient().removeChannelCountListener(getHandler());
263                  getClient().addChannelCountListener(getHandler());                  getClient().addChannelCountListener(getHandler());
# Line 851  public class CC { Line 851  public class CC {
851                                  getTaskQueue().add(new Audio.UpdateDevices());                                  getTaskQueue().add(new Audio.UpdateDevices());
852                                  addTask(uc);                                  addTask(uc);
853                                                                    
854                                    int vl = preferences().getIntProperty(JSPrefs.GLOBAL_VOICE_LIMIT);
855                                    int sl = preferences().getIntProperty(JSPrefs.GLOBAL_STREAM_LIMIT);
856                                    
857                                    getTaskQueue().add(new Global.SetPolyphony(vl, sl));
858                                    
859                                  fireConnectionEstablishedEvent();                                  fireConnectionEstablishedEvent();
860                          }                          }
861                  });                  });
# Line 1108  public class CC { Line 1113  public class CC {
1113                          sb.append("\r\n");                          sb.append("\r\n");
1114                  }                  }
1115                                    
1116                  //sb.append(getViewConfig().exportSessionViewConfig());                  sb.append(getViewConfig().exportSessionViewConfig());
1117                                    
1118                  return sb.toString();                  return sb.toString();
1119          }          }
# Line 1218  public class CC { Line 1223  public class CC {
1223                          for(int i = 0; i < fxSends.length; i++) {                          for(int i = 0; i < fxSends.length; i++) {
1224                                  FxSend f = fxSends[i];                                  FxSend f = fxSends[i];
1225                                  lscpClient.createFxSend(chnId, f.getMidiController(), f.getName());                                  lscpClient.createFxSend(chnId, f.getMidiController(), f.getName());
1226                                    lscpClient.setFxSendLevel(chnId, i, f.getLevel());
1227                                                                    
1228                                  Integer[] r = f.getAudioOutputRouting();                                  Integer[] r = f.getAudioOutputRouting();
1229                                  for(int j = 0; j < r.length; j++) {                                  for(int j = 0; j < r.length; j++) {
# Line 1251  public class CC { Line 1257  public class CC {
1257                                    
1258                  return true;                  return true;
1259          }          }
1260    
1261            public static boolean
1262            isMacOS() {
1263                    return System.getProperty("os.name").toLowerCase().startsWith("mac os x");
1264            }
1265                    
1266                    
1267          private final static EventHandler eventHandler = new EventHandler();          private final static EventHandler eventHandler = new EventHandler();
# Line 1268  public class CC { Line 1279  public class CC {
1279                  @Override                  @Override
1280                  public void                  public void
1281                  channelCountChanged( ChannelCountEvent e) {                  channelCountChanged( ChannelCountEvent e) {
1282                            if(e.getChannelCount() == 0) {
1283                                    /*
1284                                     * This special case is handled because this might be due to
1285                                     * loading a lscp script containing sampler view configuration.
1286                                     */
1287                                    CC.getSamplerModel().removeAllChannels();
1288                                    return;
1289                            }
1290                          addTask(new UpdateChannels());                          addTask(new UpdateChannels());
1291                  }                  }
1292                                    
# Line 1383  public class CC { Line 1402  public class CC {
1402                  @Override                  @Override
1403                  public void                  public void
1404                  totalVoiceCountChanged(TotalVoiceCountEvent e) {                  totalVoiceCountChanged(TotalVoiceCountEvent e) {
1405                          getTaskQueue().add(new UpdateTotalVoiceCount());                          scheduleTask(new UpdateTotalVoiceCount());
1406                  }                  }
1407                                    
1408                  /** Invoked when the number of MIDI instruments in a MIDI instrument map is changed. */                  /** Invoked when the number of MIDI instruments in a MIDI instrument map is changed. */
# Line 1411  public class CC { Line 1430  public class CC {
1430                          getSamplerModel().setVolume(e.getVolume());                          getSamplerModel().setVolume(e.getVolume());
1431                  }                  }
1432                                    
1433                    @Override
1434                    public void
1435                    voiceLimitChanged(GlobalInfoEvent e) { }
1436                    
1437                    @Override
1438                    public void
1439                    streamLimitChanged(GlobalInfoEvent e) { }
1440                    
1441                  /**                  /**
1442                   * Invoked to indicate that the state of a task queue is changed.                   * Invoked to indicate that the state of a task queue is changed.
1443                   * This method is invoked only from the event-dispatching thread.                   * This method is invoked only from the event-dispatching thread.

Legend:
Removed from v.1786  
changed lines
  Added in v.1866

  ViewVC Help
Powered by ViewVC