Example #1
0
 /**
  * Invoked when a sampler channel is removed.
  *
  * @param e A <code>SamplerChannelListEvent</code> instance providing the event information.
  */
 public void channelRemoved(SamplerChannelListEvent e) {
   // Some cleanup when the channel is removed.
   if (e.getChannelModel().getChannelID() == channelModel.getChannelID()) {
     CC.getSamplerModel().removeMidiDeviceListListener(getHandler());
     CC.getSamplerModel().removeAudioDeviceListListener(getHandler());
   }
 }
Example #2
0
  /** Creates a new instance of <code>JSMainFrame</code>. */
  public JSMainFrame() {
    super(JSampler.NAME + ' ' + JSampler.VERSION);

    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            onWindowClose();
          }
        });

    CC.getSamplerModel().addSamplerChannelListListener(new EventHandler());
  }
    ChannelRoutingTable() {
      super(new ChannelRoutingTableModel());

      JComboBox cb = new JComboBox();
      int devId = channel.getAudioOutputDevice();
      AudioDeviceModel adm = CC.getSamplerModel().getAudioDeviceModel(devId);

      if (adm == null) {
        setEnabled(false);
      } else {
        int chns = adm.getDeviceInfo().getAudioChannelCount();
        for (Integer i = 0; i < chns; i++) cb.addItem(i);
      }

      TableColumn column = getColumnModel().getColumn(1);
      column.setCellEditor(new DefaultCellEditor(cb));
    }
Example #4
0
  /** Invoked when the user clicks the mute button. */
  private void changeMute() {
    SamplerChannel sc = getChannelInfo();
    boolean b = true;

    /*
     * Changing the mute button icon now instead of
     * leaving the work to the notification mechanism of the LinuxSampler.
     */
    if (sc.isMuted() && !sc.isMutedBySolo()) {
      b = false;
      boolean hasSolo = CC.getSamplerModel().hasSoloChannel();

      if (sc.isSoloChannel() || !hasSolo) btnMute.setIcon(iconMuteOff);
      else btnMute.setIcon(iconMutedBySolo);
    } else btnMute.setIcon(iconMuteOn);

    getModel().setMute(b);
  }
Example #5
0
  /** Updates the audio device list. */
  private void updateAudioDevices() {
    SamplerModel sm = CC.getSamplerModel();
    SamplerChannel sc = getModel().getChannelInfo();

    setUpdate(true);

    try {
      cbAudioDevice.removeAllItems();

      for (AudioDeviceModel m : sm.getAudioDeviceModels()) cbAudioDevice.addItem(m.getDeviceInfo());

      AudioDeviceModel am = sm.getAudioDeviceModel(sc.getAudioOutputDevice());
      cbAudioDevice.setSelectedItem(am == null ? null : am.getDeviceInfo());
    } catch (Exception x) {
      CC.getLogger().log(Level.WARNING, "Unkown error", x);
    }

    setUpdate(false);
  }
Example #6
0
  /** Invoked when the user clicks the solo button. */
  private void changeSolo() {
    SamplerChannel sc = getChannelInfo();
    boolean b = !sc.isSoloChannel();

    /*
     * Changing the solo button icon (and related) now instead of
     * leaving the work to the notification mechanism of the LinuxSampler.
     */
    if (b) {
      btnSolo.setIcon(iconSoloOn);
      if (sc.isMutedBySolo()) btnMute.setIcon(iconMuteOff);
    } else {
      btnSolo.setIcon(iconSoloOff);
      if (!sc.isMuted() && CC.getSamplerModel().getSoloChannelCount() > 1)
        btnMute.setIcon(iconMutedBySolo);
    }

    getModel().setSolo(b);
  }
Example #7
0
  /** Updates the channel settings. This method is invoked when changes to the channel were made. */
  private void updateChannelProperties() {
    SamplerModel sm = CC.getSamplerModel();
    SamplerChannel sc = getModel().getChannelInfo();

    MidiDeviceModel mm = sm.getMidiDeviceModel(sc.getMidiInputDevice());
    AudioDeviceModel am = sm.getAudioDeviceModel(sc.getAudioOutputDevice());

    if (isUpdate()) CC.getLogger().warning("Unexpected update state!");

    setUpdate(true);

    try {
      cbMidiDevice.setSelectedItem(mm == null ? null : mm.getDeviceInfo());

      cbEngines.setSelectedItem(sc.getEngine());

      cbAudioDevice.setSelectedItem(am == null ? null : am.getDeviceInfo());
    } catch (Exception x) {
      CC.getLogger().log(Level.WARNING, "Unkown error", x);
    }

    setUpdate(false);
  }
Example #8
0
  /**
   * Creates a new instance of <code>ChannelProperties</code> using the specified non-null channel
   * model.
   *
   * @param model The model to be used by this channel properties pane.
   */
  ChannelProperties(SamplerChannelModel model) {
    channelModel = model;

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    add(new JSeparator());

    JPanel enginesPane = new JPanel();

    for (SamplerEngine e : CC.getSamplerModel().getEngines()) cbEngines.addItem(e);

    // cbEngines.setMaximumSize(cbEngines.getPreferredSize());

    enginesPane.add(cbEngines);
    String s = i18n.getLabel("ChannelProperties.enginesPane");
    enginesPane.setBorder(BorderFactory.createTitledBorder(s));

    JPanel devicesPane = new JPanel();
    devicesPane.setLayout(new BoxLayout(devicesPane, BoxLayout.X_AXIS));

    devicesPane.add(Box.createRigidArea(new Dimension(3, 0)));

    devicesPane.add(createMidiPane());

    devicesPane.add(Box.createRigidArea(new Dimension(3, 0)));

    devicesPane.add(enginesPane);

    devicesPane.add(Box.createRigidArea(new Dimension(3, 0)));

    JPanel audioPane = createAudioPane();
    Dimension d = audioPane.getPreferredSize();
    d.height = Short.MAX_VALUE;

    audioPane.setMaximumSize(d);
    devicesPane.add(audioPane);

    add(devicesPane);
    add(Box.createRigidArea(new Dimension(0, 6)));

    add(new JSeparator());

    cbMidiChannel.addItem("All");
    for (int i = 1; i <= 16; i++) cbMidiChannel.addItem(String.valueOf(i));

    cbMidiDevice.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setMidiDevice();
          }
        });

    cbMidiPort.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setMidiPort();
          }
        });

    cbMidiChannel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setMidiChannel();
          }
        });

    cbEngines.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setEngineType();
          }
        });

    cbAudioDevice.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setAudioDevice();
          }
        });

    getModel()
        .addSamplerChannelListener(
            new SamplerChannelAdapter() {
              public void channelChanged(SamplerChannelEvent e) {
                updateChannelProperties();
              }
            });

    CC.getSamplerModel().addMidiDeviceListListener(getHandler());
    CC.getSamplerModel().addAudioDeviceListListener(getHandler());
    CC.getSamplerModel().addSamplerChannelListListener(getHandler());

    btnAudioProps.setToolTipText(i18n.getLabel("ChannelProperties.routing"));
    btnAudioProps.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            SamplerChannel c = getModel().getChannelInfo();
            new ChannelOutputRoutingDlg(CC.getMainFrame(), c).setVisible(true);
          }
        });

    updateMidiDevices();
    updateAudioDevices();
    updateChannelProperties();
  }