/[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 1143 by iliev, Mon Apr 2 21:18:31 2007 UTC revision 1204 by iliev, Thu May 24 21:43:45 2007 UTC
# Line 59  import org.jsampler.task.*; Line 59  import org.jsampler.task.*;
59    
60  import org.jsampler.view.JSMainFrame;  import org.jsampler.view.JSMainFrame;
61  import org.jsampler.view.JSProgress;  import org.jsampler.view.JSProgress;
62    import org.jsampler.view.InstrumentsDbTreeModel;
63    
64  import org.linuxsampler.lscp.AudioOutputChannel;  import org.linuxsampler.lscp.AudioOutputChannel;
65  import org.linuxsampler.lscp.AudioOutputDevice;  import org.linuxsampler.lscp.AudioOutputDevice;
# Line 122  public class CC { Line 123  public class CC {
123          getTaskQueue() { return taskQueue; }          getTaskQueue() { return taskQueue; }
124                    
125          /**          /**
126             * Adds the specified task to the task queue. All task in the
127             * queue equal to the specified task are removed from the queue.
128             */
129            public static void
130            scheduleTask(Task t) {
131                    while(getTaskQueue().removeTask(t)) { }
132                    
133                    if(getTaskQueue().getPendingTaskCount() == 0) {
134                            if(t.equals(getTaskQueue().getRunningTask())) return;
135                    }
136                    
137                    getTaskQueue().add(t);
138            }
139            
140            /**
141           * Returns the main window of this application.           * Returns the main window of this application.
142           * @return The main window of this application.           * @return The main window of this application.
143           */           */
# Line 190  public class CC { Line 206  public class CC {
206                  handler.setLevel(Level.FINE);                  handler.setLevel(Level.FINE);
207                  getLogger().addHandler(handler);                  getLogger().addHandler(handler);
208                  getLogger().setLevel(Level.FINE);                  getLogger().setLevel(Level.FINE);
                 Logger.getLogger("org.linuxsampler.lscp").addHandler(handler);  
209                  Logger.getLogger("org.linuxsampler.lscp").setLevel(Level.FINE);                  Logger.getLogger("org.linuxsampler.lscp").setLevel(Level.FINE);
210                    Logger.getLogger("org.linuxsampler.lscp").addHandler(handler);
211                                    
212                  // Flushing logs on every second                  // Flushing logs on every second
213                  new java.util.Timer().schedule(new java.util.TimerTask() {                  new java.util.Timer().schedule(new java.util.TimerTask() {
# Line 337  public class CC { Line 353  public class CC {
353          public static OrchestraListModel          public static OrchestraListModel
354          getOrchestras() { return orchestras; }          getOrchestras() { return orchestras; }
355                    
356            private static InstrumentsDbTreeModel instrumentsDbTreeModel = null;
357            /**
358             * Gets the tree model of the instruments database.
359             * If the currently used view doesn't have instruments
360             * database support the tree model is initialized on first use.
361             * @return The tree model of the instruments database or
362             * <code>null</code> if the backend doesn't have instruments database support.
363             * @see org.jsampler.view.JSMainFrame#getInstrumentsDbSupport
364             */
365            public static InstrumentsDbTreeModel
366            getInstrumentsDbTreeModel() {
367                    if(!CC.getSamplerModel().getServerInfo().hasInstrumentsDbSupport()) return null;
368                    
369                    if(instrumentsDbTreeModel == null) {
370                            instrumentsDbTreeModel = new InstrumentsDbTreeModel();
371                    }
372                    
373                    return instrumentsDbTreeModel;
374            }
375            
376          /**          /**
377           * Loads the orchestras described in <code>&lt;jsampler_home&gt;/orchestras.xml</code>.           * Loads the orchestras described in <code>&lt;jsampler_home&gt;/orchestras.xml</code>.
378           * If file with name <code>orchestras.xml.bkp</code> exist in the JSampler's home           * If file with name <code>orchestras.xml.bkp</code> exist in the JSampler's home
# Line 505  public class CC { Line 541  public class CC {
541          initSamplerModel() {          initSamplerModel() {
542                  final DefaultSamplerModel model = (DefaultSamplerModel)getSamplerModel();                  final DefaultSamplerModel model = (DefaultSamplerModel)getSamplerModel();
543                                    
544                  final GetServerInfo gsi = new GetServerInfo();                  final Global.GetServerInfo gsi = new Global.GetServerInfo();
545                  gsi.addTaskListener(new TaskListener() {                  gsi.addTaskListener(new TaskListener() {
546                          public void                          public void
547                          taskPerformed(TaskEvent e) {                          taskPerformed(TaskEvent e) {
548                                  if(!gsi.doneWithErrors()) model.setServerInfo(gsi.getResult());                                  if(gsi.doneWithErrors()) return;
549                                    
550                                    model.setServerInfo(gsi.getResult());
551                                    
552                                    if(CC.getMainFrame().getInstrumentsDbSupport()) {
553                                            getInstrumentsDbTreeModel();
554                                    }
555                          }                          }
556                  });                  });
557                                    
# Line 565  public class CC { Line 607  public class CC {
607                  uc.addTaskListener(new TaskListener() {                  uc.addTaskListener(new TaskListener() {
608                          public void                          public void
609                          taskPerformed(TaskEvent e) {                          taskPerformed(TaskEvent e) {
610                                  for(SamplerChannelModel c : model.getChannelModels()) {                                  for(SamplerChannelModel c : model.getChannels()) {
611                                          if(c.getChannelInfo().getEngine() == null) continue;                                          if(c.getChannelInfo().getEngine() == null) continue;
612                                                                                    
613                                          Channel.GetFxSends gfs = new Channel.GetFxSends();                                          Channel.GetFxSends gfs = new Channel.GetFxSends();
# Line 602  public class CC { Line 644  public class CC {
644                  taskPerformed(TaskEvent e) {                  taskPerformed(TaskEvent e) {
645                          Channel.GetFxSends gfs = (Channel.GetFxSends)e.getSource();                          Channel.GetFxSends gfs = (Channel.GetFxSends)e.getSource();
646                          if(gfs.doneWithErrors()) return;                          if(gfs.doneWithErrors()) return;
647                          SamplerChannelModel m = getSamplerModel().getChannelModel(gfs.getChannel());                          SamplerChannelModel m = getSamplerModel().getChannelById(gfs.getChannel());
648                          m.removeAllFxSends();                          m.removeAllFxSends();
649                                                    
650                          for(FxSend fxs : gfs.getResult()) m.addFxSend(fxs);                          for(FxSend fxs : gfs.getResult()) m.addFxSend(fxs);
# Line 673  public class CC { Line 715  public class CC {
715                          sb.append("\r\n");                          sb.append("\r\n");
716                  } catch(Exception e) { CC.getLogger().log(Level.FINE, HF.getErrorMessage(e), e); }                  } catch(Exception e) { CC.getLogger().log(Level.FINE, HF.getErrorMessage(e), e); }
717                                                                    
718                  MidiDeviceModel[] mDevs = getSamplerModel().getMidiDeviceModels();                  MidiDeviceModel[] mDevs = getSamplerModel().getMidiDevices();
719                  for(int i = 0; i < mDevs.length; i++) {                  for(int i = 0; i < mDevs.length; i++) {
720                          exportMidiDeviceToLscpScript(mDevs[i].getDeviceInfo(), i, lscpClient);                          exportMidiDeviceToLscpScript(mDevs[i].getDeviceInfo(), i, lscpClient);
721                          sb.append(out.toString());                          sb.append(out.toString());
# Line 681  public class CC { Line 723  public class CC {
723                          sb.append("\r\n");                          sb.append("\r\n");
724                  }                  }
725                                    
726                  AudioDeviceModel[] aDevs = getSamplerModel().getAudioDeviceModels();                  AudioDeviceModel[] aDevs = getSamplerModel().getAudioDevices();
727                  for(int i = 0; i < aDevs.length; i++) {                  for(int i = 0; i < aDevs.length; i++) {
728                          exportAudioDeviceToLscpScript(aDevs[i].getDeviceInfo(), i, lscpClient);                          exportAudioDeviceToLscpScript(aDevs[i].getDeviceInfo(), i, lscpClient);
729                          sb.append(out.toString());                          sb.append(out.toString());
# Line 689  public class CC { Line 731  public class CC {
731                          sb.append("\r\n");                          sb.append("\r\n");
732                  }                  }
733                                    
734                  SamplerChannelModel[] channels = getSamplerModel().getChannelModels();                  SamplerChannelModel[] channels = getSamplerModel().getChannels();
735                                    
736                  for(int i = 0; i < channels.length; i++) {                  for(int i = 0; i < channels.length; i++) {
737                          SamplerChannelModel scm = getSamplerModel().getChannelModel(i);                          SamplerChannelModel scm = getSamplerModel().getChannelById(i);
738                          exportChannelToLscpScript(scm.getChannelInfo(), i, lscpClient);                          exportChannelToLscpScript(scm.getChannelInfo(), i, lscpClient);
739                          sb.append(out.toString());                          sb.append(out.toString());
740                          out.reset();                          out.reset();
# Line 890  public class CC { Line 932  public class CC {
932                  public void                  public void
933                  streamCountChanged(StreamCountEvent e) {                  streamCountChanged(StreamCountEvent e) {
934                          SamplerChannelModel scm =                          SamplerChannelModel scm =
935                                  getSamplerModel().getChannelModel(e.getSamplerChannel());                                  getSamplerModel().getChannelById(e.getSamplerChannel());
936                                                    
937                          if(scm == null) {                          if(scm == null) {
938                                  CC.getLogger().log (                                  CC.getLogger().log (
# Line 912  public class CC { Line 954  public class CC {
954                  public void                  public void
955                  voiceCountChanged(VoiceCountEvent e) {                  voiceCountChanged(VoiceCountEvent e) {
956                          SamplerChannelModel scm =                          SamplerChannelModel scm =
957                                  getSamplerModel().getChannelModel(e.getSamplerChannel());                                  getSamplerModel().getChannelById(e.getSamplerChannel());
958                                                    
959                          if(scm == null) {                          if(scm == null) {
960                                  CC.getLogger().log (                                  CC.getLogger().log (
# Line 969  public class CC { Line 1011  public class CC {
1011                                  break;                                  break;
1012                          case TASK_DONE:                          case TASK_DONE:
1013                                  EnhancedTask t = (EnhancedTask)e.getSource();                                  EnhancedTask t = (EnhancedTask)e.getSource();
1014                                  if(t.doneWithErrors() && !t.isStopped())                                  if(t.doneWithErrors() && !t.isStopped()) {
1015                                          HF.showErrorMessage(t.getErrorMessage());                                          if(t.getErrorDetails() == null) {
1016                                                    HF.showErrorMessage(t.getErrorMessage());
1017                                            } else {
1018                                                    getMainFrame().showDetailedErrorMessage (
1019                                                            getMainFrame(),
1020                                                            t.getErrorMessage(),
1021                                                            t.getErrorDetails()
1022                                                    );
1023                                            }
1024                                    }
1025                                  break;                                  break;
1026                          case NOT_IDLE:                          case NOT_IDLE:
1027                                  timer.start();                                  timer.start();

Legend:
Removed from v.1143  
changed lines
  Added in v.1204

  ViewVC Help
Powered by ViewVC