/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/Channel.java
ViewVC logotype

Diff of /jsampler/trunk/src/org/jsampler/view/fantasia/Channel.java

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

revision 912 by iliev, Mon Aug 7 18:34:40 2006 UTC revision 1143 by iliev, Mon Apr 2 21:18:31 2007 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, 2006 Grigor Kirilov Iliev   *   Copyright (C) 2005-2006 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 57  import org.jsampler.MidiDeviceModel; Line 57  import org.jsampler.MidiDeviceModel;
57  import org.jsampler.SamplerChannelModel;  import org.jsampler.SamplerChannelModel;
58  import org.jsampler.SamplerModel;  import org.jsampler.SamplerModel;
59    
60  import org.jsampler.event.AudioDeviceListEvent;  import org.jsampler.event.ListEvent;
61  import org.jsampler.event.AudioDeviceListListener;  import org.jsampler.event.ListListener;
62  import org.jsampler.event.MidiDeviceListEvent;  import org.jsampler.event.MidiDeviceListEvent;
63  import org.jsampler.event.MidiDeviceListListener;  import org.jsampler.event.MidiDeviceListListener;
64  import org.jsampler.event.SamplerChannelAdapter;  import org.jsampler.event.SamplerChannelAdapter;
65  import org.jsampler.event.SamplerChannelEvent;  import org.jsampler.event.SamplerChannelEvent;
66  import org.jsampler.event.SamplerChannelListener;  import org.jsampler.event.SamplerChannelListener;
67    
 import org.jsampler.task.RemoveChannel;  
   
68  import org.linuxsampler.lscp.AudioOutputDevice;  import org.linuxsampler.lscp.AudioOutputDevice;
69  import org.linuxsampler.lscp.MidiInputDevice;  import org.linuxsampler.lscp.MidiInputDevice;
70  import org.linuxsampler.lscp.MidiPort;  import org.linuxsampler.lscp.MidiPort;
# Line 257  public class Channel extends org.jsample Line 255  public class Channel extends org.jsample
255                   */                   */
256                  float volume = dialVolume.getValue();                  float volume = dialVolume.getValue();
257                  volume /= 100;                  volume /= 100;
258                  getModel().setVolume(volume);                  getModel().setBackendVolume(volume);
259          }          }
260                    
261          /**          /**
# Line 369  public class Channel extends org.jsample Line 367  public class Channel extends org.jsample
367                                    
368                  public void                  public void
369                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
370                          CC.getTaskQueue().add(new RemoveChannel(getChannelID()));                          CC.getSamplerModel().removeBackendChannel(getChannelId());
371                  }                  }
372                                    
373                  public boolean                  public boolean
# Line 379  public class Channel extends org.jsample Line 377  public class Channel extends org.jsample
377          private class MuteButton extends PixmapButton implements ActionListener {          private class MuteButton extends PixmapButton implements ActionListener {
378                  MuteButton() {                  MuteButton() {
379                          super(Res.iconMuteOff);                          super(Res.iconMuteOff);
380                            setDisabledIcon(Res.iconMuteSoloDisabled);
381                          addActionListener(this);                          addActionListener(this);
382                  }                  }
383                                    
# Line 399  public class Channel extends org.jsample Line 398  public class Channel extends org.jsample
398                                  else setIcon(Res.iconMutedBySolo);                                  else setIcon(Res.iconMutedBySolo);
399                          } else setIcon(Res.iconMuteOn);                          } else setIcon(Res.iconMuteOn);
400                                                    
401                          Channel.this.getModel().setMute(b);                          Channel.this.getModel().setBackendMute(b);
402                  }                  }
403                                    
404                  public boolean                  public boolean
# Line 409  public class Channel extends org.jsample Line 408  public class Channel extends org.jsample
408          private class SoloButton extends PixmapButton implements ActionListener {          private class SoloButton extends PixmapButton implements ActionListener {
409                  SoloButton() {                  SoloButton() {
410                          super(Res.iconSoloOff);                          super(Res.iconSoloOff);
411                            setDisabledIcon(Res.iconMuteSoloDisabled);
412                          addActionListener(this);                          addActionListener(this);
413                  }                  }
414                                    
# Line 430  public class Channel extends org.jsample Line 430  public class Channel extends org.jsample
430                                          btnMute.setIcon(Res.iconMutedBySolo);                                          btnMute.setIcon(Res.iconMutedBySolo);
431                          }                          }
432                                    
433                          Channel.this.getModel().setSolo(b);                          Channel.this.getModel().setBackendSolo(b);
434                  }                  }
435                                    
436                  public boolean                  public boolean
# Line 440  public class Channel extends org.jsample Line 440  public class Channel extends org.jsample
440          private class OptionsButton extends PixmapToggleButton implements ActionListener {          private class OptionsButton extends PixmapToggleButton implements ActionListener {
441                  OptionsButton() {                  OptionsButton() {
442                          super(Res.iconOptionsOff, Res.iconOptionsOn);                          super(Res.iconOptionsOff, Res.iconOptionsOn);
443                            setRolloverIcon(Res.iconOptionsOffRO);
444                            this.setRolloverSelectedIcon(Res.iconOptionsOnRO);
445                          addActionListener(this);                          addActionListener(this);
446                  }                  }
447                                    
# Line 461  public class Channel extends org.jsample Line 463  public class Channel extends org.jsample
463                  }                  }
464                                    
465                  public boolean                  public boolean
466                  contains(int x, int y) { return y < 13; }                  contains(int x, int y) { return super.contains(x, y) & y < 13; }
467          }          }
468  }  }
469    
# Line 539  class ChannelScreen extends JPanel { Line 541  class ChannelScreen extends JPanel {
541                    
542                  btnReset.addActionListener(new ActionListener() {                  btnReset.addActionListener(new ActionListener() {
543                          public void                          public void
544                          actionPerformed(ActionEvent e) { channel.getModel().resetChannel(); }                          actionPerformed(ActionEvent e) { channel.getModel().resetBackendChannel(); }
545                  });                  });
546                                    
547                  btnDuplicate.addActionListener(new ActionListener() {                  btnDuplicate.addActionListener(new ActionListener() {
548                          public void                          public void
549                          actionPerformed(ActionEvent e) { channel.getModel().duplicateChannel(); }                          actionPerformed(ActionEvent e) {
550                                    channel.getModel().duplicateBackendChannel();
551                            }
552                  });                  });
553          }          }
554    
# Line 555  class ChannelScreen extends JPanel { Line 559  class ChannelScreen extends JPanel {
559                                    
560                  if(!dlg.isCancelled()) {                  if(!dlg.isCancelled()) {
561                          SamplerChannelModel m = channel.getModel();                          SamplerChannelModel m = channel.getModel();
562                          m.loadInstrument(dlg.getFileName(), dlg.getInstrumentIndex());                          m.loadBackendInstrument(dlg.getFileName(), dlg.getInstrumentIndex());
563                  }                  }
564          }          }
565                    
# Line 764  class ChannelOptions extends JPanel { Line 768  class ChannelOptions extends JPanel {
768                                    
769                  cbAudioDevice.addActionListener(new ActionListener() {                  cbAudioDevice.addActionListener(new ActionListener() {
770                          public void                          public void
771                          actionPerformed(ActionEvent e) { setAudioDevice(); }                          actionPerformed(ActionEvent e) { setBackendAudioDevice(); }
772                  });                  });
773                                    
774                  channel.getModel().addSamplerChannelListener(new SamplerChannelAdapter() {                  channel.getModel().addSamplerChannelListener(new SamplerChannelAdapter() {
# Line 864  class ChannelOptions extends JPanel { Line 868  class ChannelOptions extends JPanel {
868                  MidiInputDevice mid = (MidiInputDevice)cbMidiDevice.getSelectedItem();                  MidiInputDevice mid = (MidiInputDevice)cbMidiDevice.getSelectedItem();
869                                    
870                  if(!isUpdate()) {                  if(!isUpdate()) {
871                          if(mid != null) channel.getModel().setMidiInputDevice(mid.getDeviceID());                          if(mid != null) {
872                                    channel.getModel().setBackendMidiInputDevice(mid.getDeviceId());
873                            }
874                            
875                          return;                          return;
876                  }                  }
877                                    
# Line 894  class ChannelOptions extends JPanel { Line 901  class ChannelOptions extends JPanel {
901          setMidiPort() {          setMidiPort() {
902                  if(isUpdate()) return;                  if(isUpdate()) return;
903                                    
904                  channel.getModel().setMidiInputPort(cbMidiPort.getSelectedIndex());                  channel.getModel().setBackendMidiInputPort(cbMidiPort.getSelectedIndex());
905          }          }
906                    
907          private void          private void
# Line 907  class ChannelOptions extends JPanel { Line 914  class ChannelOptions extends JPanel {
914                                    
915                  int c = s.equals("All") ? -1 : Integer.parseInt(s.substring(8)) - 1;                  int c = s.equals("All") ? -1 : Integer.parseInt(s.substring(8)) - 1;
916                                    
917                  channel.getModel().setMidiInputChannel(c);                  channel.getModel().setBackendMidiInputChannel(c);
918          }          }
919                    
920          /** Invoked when the user selects an engine. */          /** Invoked when the user selects an engine. */
# Line 919  class ChannelOptions extends JPanel { Line 926  class ChannelOptions extends JPanel {
926                  if(oldEngine != null) { if(oldEngine.equals(newEngine)) return; }                  if(oldEngine != null) { if(oldEngine.equals(newEngine)) return; }
927                  else if(newEngine == null) return;                  else if(newEngine == null) return;
928                                    
929                  channel.getModel().setEngineType(newEngine.getName());                  channel.getModel().setBackendEngineType(newEngine.getName());
930                                    
931          }          }
932                    
933          private void          private void
934          setAudioDevice() {          setBackendAudioDevice() {
935                  if(isUpdate()) return;                  if(isUpdate()) return;
936                  AudioOutputDevice dev = (AudioOutputDevice)cbAudioDevice.getSelectedItem();                  AudioOutputDevice dev = (AudioOutputDevice)cbAudioDevice.getSelectedItem();
937                  if(dev != null) channel.getModel().setAudioOutputDevice(dev.getDeviceID());                  if(dev != null) channel.getModel().setBackendAudioOutputDevice(dev.getDeviceId());
938          }          }
939                    
940          /**          /**
# Line 952  class ChannelOptions extends JPanel { Line 959  class ChannelOptions extends JPanel {
959          private Handler          private Handler
960          getHandler() { return handler; }          getHandler() { return handler; }
961                    
962          private class Handler implements MidiDeviceListListener, AudioDeviceListListener {          private class Handler implements MidiDeviceListListener, ListListener<AudioDeviceModel> {
963                  /**                  /**
964                   * Invoked when a new MIDI device is created.                   * Invoked when a new MIDI device is created.
965                   * @param e A <code>MidiDeviceListEvent</code>                   * @param e A <code>MidiDeviceListEvent</code>
# Line 979  class ChannelOptions extends JPanel { Line 986  class ChannelOptions extends JPanel {
986                   * instance providing the event information.                   * instance providing the event information.
987                   */                   */
988                  public void                  public void
989                  deviceAdded(AudioDeviceListEvent e) {                  entryAdded(ListEvent<AudioDeviceModel> e) {
990                          cbAudioDevice.addItem(e.getAudioDeviceModel().getDeviceInfo());                          cbAudioDevice.addItem(e.getEntry().getDeviceInfo());
991                  }                  }
992                    
993                  /**                  /**
# Line 989  class ChannelOptions extends JPanel { Line 996  class ChannelOptions extends JPanel {
996                   * instance providing the event information.                   * instance providing the event information.
997                   */                   */
998                  public void                  public void
999                  deviceRemoved(AudioDeviceListEvent e) {                  entryRemoved(ListEvent<AudioDeviceModel> e) {
1000                          cbAudioDevice.removeItem(e.getAudioDeviceModel().getDeviceInfo());                          cbAudioDevice.removeItem(e.getEntry().getDeviceInfo());
1001                  }                  }
1002          }          }
1003  }  }

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

  ViewVC Help
Powered by ViewVC