Package jrackattack.gui

Source Code of jrackattack.gui.OscPanel

/* For License see bottom */
/*
* OscPanel.java
*
* Created on 1. Juli 2007, 15:49
*/

package jrackattack.gui;


import javax.swing.SpinnerNumberModel;

import jonkoshare.util.VersionInformation;

import jrackattack.midi.MidiThread;
import jrackattack.midi.RackAttack;
import jrackattack.midi.SoundParameter;

/**
*
* TODO: OSC1 and OSC2 should be displayed in a single
* panel, so FM-Mod and paramters combining both OSCs
* make more sense...
*
* @author  methke01
*/
@VersionInformation (
  lastChanged="$LastChangedDate: 2009-07-25 04:59:33 -0500 (Sat, 25 Jul 2009) $",
  authors={"Alexander Methke"},
  revision="$LastChangedRevision: 11 $",
  lastEditor="$LastChangedBy: onkobu $",
  id="$Id"
)
public class OscPanel extends javax.swing.JPanel {

  public enum Mode {
    OSC1_MODE,
    OSC2_MODE
  };

  /** Creates new form OscPanel */
  public OscPanel() {
    initiating=true;
    initComponents();
    initValues();
    initiating=false;
  }

  protected void initValues() {
    shapeBox.removeAllItems();
    for (String shape:RackAttack.SHAPES) {
      shapeBox.addItem(shape);
    }
    startPhaseBox.removeAllItems();
    for (String phase:RackAttack.START_PHASE) {
      startPhaseBox.addItem(phase);
    }
    ((SpinnerNumberModel)pitchSpinner.getModel()).setMinimum(0);
    ((SpinnerNumberModel)pitchSpinner.getModel()).setMaximum(127);
    pitchSpinner.setValue(new Integer(0));
   
    ((SpinnerNumberModel)pitchModSpinner.getModel()).setMinimum(-64);
    ((SpinnerNumberModel)pitchModSpinner.getModel()).setMaximum(63);
    pitchModSpinner.setValue(new Integer(0));

    ((SpinnerNumberModel)pitchCtrlSpinner.getModel()).setMinimum(-64);
    ((SpinnerNumberModel)pitchCtrlSpinner.getModel()).setMaximum(63);
    pitchCtrlSpinner.setValue(new Integer(0));
   
    ((SpinnerNumberModel)detuneSpinner.getModel()).setMinimum(0);
    ((SpinnerNumberModel)detuneSpinner.getModel()).setMaximum(127);
    detuneSpinner.setValue(new Integer(0));
   
    pitchModKnob.setIntValue(64);
    pitchCtrlKnob.setIntValue(64);
    fmModKnob.setIntValue(64);
    fmCtrlKnob.setIntValue(64);
    fmModSrcBox.removeAllItems();
    pitchModSrcBox.removeAllItems();
    for(String src:RackAttack.MOD_SOURCE) {
      fmModSrcBox.addItem(src);
      pitchModSrcBox.addItem(src);
    }

    fmCtrlSrcBox.removeAllItems();
    pitchCtrlSrcBox.removeAllItems();
    for(String ctrl:RackAttack.CTRL_SOURCE) {
      fmCtrlSrcBox.addItem(ctrl);
      pitchCtrlSrcBox.addItem(ctrl);
    }
  }

// SoundParameterListener
  public void soundParameterChanged(SoundParameter sp) {
    initiating=true;
    if (sp==null) {
      pitchKnob.setIntValue(0);
      detuneKnob.setIntValue(0);
      pitchCtrlKnob.setIntValue(64);
      pitchModKnob.setIntValue(64);
      fmCtrlKnob.setIntValue(64);
      fmModKnob.setIntValue(64);
      shapeBox.setSelectedItem(0);
      startPhaseBox.setSelectedIndex(0);
      pitchModSrcBox.setSelectedItem(0);
      fmModSrcBox.setSelectedIndex(0);
      pitchCtrlSrcBox.setSelectedItem(0);
      fmCtrlSrcBox.setSelectedIndex(0);
    } else {
      if (mode==Mode.OSC1_MODE) {
        pitchKnob.setIntValue(sp.getOsc1Pitch());
        detuneKnob.setIntValue(sp.getOsc1Detune());
        pitchCtrlKnob.setIntValue(sp.getOsc1PitchCtrl());
        pitchModKnob.setIntValue(sp.getOsc1PitchMod());
        shapeBox.setSelectedItem(sp.getOsc1ShapeIndex());
        startPhaseBox.setSelectedIndex(sp.getOsc1StartPhaseIndex());
        pitchModSrcBox.setSelectedItem(sp.getOsc1PitchModSrcIndex());
        fmCtrlKnob.setIntValue(sp.getOsc1FMCtrl());
        fmModKnob.setIntValue(sp.getOsc1FMMod());
        fmModSrcBox.setSelectedIndex(sp.getOsc1FMModSrcIndex());
        pitchCtrlSrcBox.setSelectedItem(sp.getOsc1PitchCtrlSrcIndex());
        fmCtrlSrcBox.setSelectedIndex(sp.getOsc1FMCtrlSrcIndex());
        mixKnob.setIntValue(sp.getOsc1Level());
        mixSpinner.setValue(sp.getOsc1Level());
      } else {
        pitchKnob.setIntValue(sp.getOsc2Pitch());
        detuneKnob.setIntValue(sp.getOsc2Detune());
        pitchCtrlKnob.setIntValue(sp.getOsc2PitchCtrl());
        pitchModKnob.setIntValue(sp.getOsc2PitchMod());
        shapeBox.setSelectedItem(sp.getOsc2ShapeIndex());
        startPhaseBox.setSelectedIndex(sp.getOsc2StartPhaseIndex());
        mixKnob.setIntValue(sp.getOsc2Level());
        mixSpinner.setValue(sp.getOsc2Level());
      }
    }
    syncSpinner();
    initiating=false;
  }

  protected void syncSpinner() {
    fmCtrlSpinner.setValue(new Integer(fmCtrlKnob.getIntValue()-64));
    fmModSpinner.setValue(new Integer(fmModKnob.getIntValue()-64));
    pitchCtrlSpinner.setValue(new Integer(pitchCtrlKnob.getIntValue()-64));
    pitchModSpinner.setValue(new Integer(pitchModKnob.getIntValue()-64));
    pitchSpinner.setValue(new Integer(pitchKnob.getIntValue()));
    detuneSpinner.setValue(new Integer(detuneKnob.getIntValue()));
  }
 
  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        pitchKnob = new jrackattack.gui.JKnob();
        detuneKnob = new jrackattack.gui.JKnob();
        pitchModKnob = new jrackattack.gui.JKnob();
        pitchCtrlKnob = new jrackattack.gui.JKnob();
        pitchLabel = new javax.swing.JLabel();
        detuneLabel = new javax.swing.JLabel();
        pitchModLabel = new javax.swing.JLabel();
        pitchCtrlLabel = new javax.swing.JLabel();
        shapeBox = new javax.swing.JComboBox();
        shapeLabel = new javax.swing.JLabel();
        startPhaseBox = new javax.swing.JComboBox();
        startPhaseLabel = new javax.swing.JLabel();
        pitchSpinner = new javax.swing.JSpinner();
        detuneSpinner = new javax.swing.JSpinner();
        pitchModSpinner = new javax.swing.JSpinner();
        pitchCtrlSpinner = new javax.swing.JSpinner();
        fmModKnob = new jrackattack.gui.JKnob();
        fmCtrlKnob = new jrackattack.gui.JKnob();
        fmModSpinner = new javax.swing.JSpinner();
        fmCtrlSpinner = new javax.swing.JSpinner();
        fmModLabel = new javax.swing.JLabel();
        fmCtrlLabel = new javax.swing.JLabel();
        fmModSrcBox = new javax.swing.JComboBox();
        fmCtrlSrcBox = new javax.swing.JComboBox();
        pitchModSrcBox = new javax.swing.JComboBox();
        pitchCtrlSrcBox = new javax.swing.JComboBox();
        pitchModSrcLabel = new javax.swing.JLabel();
        pitchCtrlSrcLabel = new javax.swing.JLabel();
        fmModSrcLabel = new javax.swing.JLabel();
        fmCtrlSrcLabel = new javax.swing.JLabel();
        mixKnob = new jrackattack.gui.JKnob();
        mixSpinner = new javax.swing.JSpinner();
        mixLabel = new javax.swing.JLabel();

        setLayout(new java.awt.GridBagLayout());

        pitchKnob.setIntValue(0);
        pitchKnob.setMaximumValue(127);
        pitchKnob.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                pitchKnobStateChanged(evt);
            }
        });

        org.jdesktop.layout.GroupLayout pitchKnobLayout = new org.jdesktop.layout.GroupLayout(pitchKnob);
        pitchKnob.setLayout(pitchKnobLayout);
        pitchKnobLayout.setHorizontalGroup(
            pitchKnobLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 80, Short.MAX_VALUE)
        );
        pitchKnobLayout.setVerticalGroup(
            pitchKnobLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 80, Short.MAX_VALUE)
        );
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        add(pitchKnob, gridBagConstraints);

        detuneKnob.setIntValue(0);
        detuneKnob.setMaximumValue(127);
        detuneKnob.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                detuneKnobStateChanged(evt);
            }
        });

        org.jdesktop.layout.GroupLayout detuneKnobLayout = new org.jdesktop.layout.GroupLayout(detuneKnob);
        detuneKnob.setLayout(detuneKnobLayout);
        detuneKnobLayout.setHorizontalGroup(
            detuneKnobLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 80, Short.MAX_VALUE)
        );
        detuneKnobLayout.setVerticalGroup(
            detuneKnobLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 80, Short.MAX_VALUE)
        );
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        add(detuneKnob, gridBagConstraints);

        pitchModKnob.setMaximumValue(127);
        pitchModKnob.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                pitchModKnobStateChanged(evt);
            }
        });

        org.jdesktop.layout.GroupLayout pitchModKnobLayout = new org.jdesktop.layout.GroupLayout(pitchModKnob);
        pitchModKnob.setLayout(pitchModKnobLayout);
        pitchModKnobLayout.setHorizontalGroup(
            pitchModKnobLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 80, Short.MAX_VALUE)
        );
        pitchModKnobLayout.setVerticalGroup(
            pitchModKnobLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 80, Short.MAX_VALUE)
        );
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        add(pitchModKnob, gridBagConstraints);

        pitchCtrlKnob.setMaximumValue(127);
        pitchCtrlKnob.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                pitchCtrlKnobStateChanged(evt);
            }
        });

        org.jdesktop.layout.GroupLayout pitchCtrlKnobLayout = new org.jdesktop.layout.GroupLayout(pitchCtrlKnob);
        pitchCtrlKnob.setLayout(pitchCtrlKnobLayout);
        pitchCtrlKnobLayout.setHorizontalGroup(
            pitchCtrlKnobLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 80, Short.MAX_VALUE)
        );
        pitchCtrlKnobLayout.setVerticalGroup(
            pitchCtrlKnobLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 80, Short.MAX_VALUE)
        );
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 0;
        add(pitchCtrlKnob, gridBagConstraints);

        pitchLabel.setText(java.util.ResourceBundle.getBundle("jrackattack/gui").getString("label.pitch"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        add(pitchLabel, gridBagConstraints);

        detuneLabel.setText(java.util.ResourceBundle.getBundle("jrackattack/gui").getString("label.detune"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        add(detuneLabel, gridBagConstraints);

        pitchModLabel.setText(java.util.ResourceBundle.getBundle("jrackattack/gui").getString("label.pitch_mod"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        add(pitchModLabel, gridBagConstraints);

        pitchCtrlLabel.setText(java.util.ResourceBundle.getBundle("jrackattack/gui").getString("label.pitch_ctrl"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 2;
        add(pitchCtrlLabel, gridBagConstraints);

        shapeBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        shapeBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                shapeBoxItemStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        add(shapeBox, gridBagConstraints);

        shapeLabel.setText(java.util.ResourceBundle.getBundle("jrackattack/gui").getString("label.shape"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        add(shapeLabel, gridBagConstraints);

        startPhaseBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        add(startPhaseBox, gridBagConstraints);

        startPhaseLabel.setText(java.util.ResourceBundle.getBundle("jrackattack/gui").getString("label.osc_startphase"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        add(startPhaseLabel, gridBagConstraints);

        pitchSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                pitchSpinnerStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        add(pitchSpinner, gridBagConstraints);

        detuneSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                detuneSpinnerStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        add(detuneSpinner, gridBagConstraints);

        pitchModSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                pitchModSpinnerStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        add(pitchModSpinner, gridBagConstraints);

        pitchCtrlSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                pitchCtrlSpinnerStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        add(pitchCtrlSpinner, gridBagConstraints);

        fmModKnob.setIntValue(64);
        fmModKnob.setMaximumValue(127);
        fmModKnob.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                fmModKnobStateChanged(evt);
            }
        });

        org.jdesktop.layout.GroupLayout fmModKnobLayout = new org.jdesktop.layout.GroupLayout(fmModKnob);
        fmModKnob.setLayout(fmModKnobLayout);
        fmModKnobLayout.setHorizontalGroup(
            fmModKnobLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 80, Short.MAX_VALUE)
        );
        fmModKnobLayout.setVerticalGroup(
            fmModKnobLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 80, Short.MAX_VALUE)
        );
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 0;
        add(fmModKnob, gridBagConstraints);

        fmCtrlKnob.setMaximumValue(127);
        fmCtrlKnob.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                fmCtrlKnobStateChanged(evt);
            }
        });

        org.jdesktop.layout.GroupLayout fmCtrlKnobLayout = new org.jdesktop.layout.GroupLayout(fmCtrlKnob);
        fmCtrlKnob.setLayout(fmCtrlKnobLayout);
        fmCtrlKnobLayout.setHorizontalGroup(
            fmCtrlKnobLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 80, Short.MAX_VALUE)
        );
        fmCtrlKnobLayout.setVerticalGroup(
            fmCtrlKnobLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 80, Short.MAX_VALUE)
        );
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 0;
        add(fmCtrlKnob, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        add(fmModSpinner, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        add(fmCtrlSpinner, gridBagConstraints);

        fmModLabel.setText(java.util.ResourceBundle.getBundle("jrackattack/gui").getString("label.fm_mod"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 2;
        add(fmModLabel, gridBagConstraints);

        fmCtrlLabel.setText(java.util.ResourceBundle.getBundle("jrackattack/gui").getString("label.fm_ctrl"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 2;
        add(fmCtrlLabel, gridBagConstraints);

        fmModSrcBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        fmModSrcBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                fmModSrcBoxItemStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 3;
        add(fmModSrcBox, gridBagConstraints);

        fmCtrlSrcBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        fmCtrlSrcBox.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                fmCtrlSrcBoxItemStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 3;
        add(fmCtrlSrcBox, gridBagConstraints);

        pitchModSrcBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 3;
        add(pitchModSrcBox, gridBagConstraints);

        pitchCtrlSrcBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 3;
        add(pitchCtrlSrcBox, gridBagConstraints);

        pitchModSrcLabel.setText(java.util.ResourceBundle.getBundle("jrackattack/gui").getString("label.pitch_mod_src"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        add(pitchModSrcLabel, gridBagConstraints);

        pitchCtrlSrcLabel.setText(java.util.ResourceBundle.getBundle("jrackattack/gui").getString("label.pitch_ctrl_src"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 3;
        gridBagConstraints.gridy = 4;
        add(pitchCtrlSrcLabel, gridBagConstraints);

        fmModSrcLabel.setText(java.util.ResourceBundle.getBundle("jrackattack/gui").getString("label.fm_mod_src"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 4;
        gridBagConstraints.gridy = 4;
        add(fmModSrcLabel, gridBagConstraints);

        fmCtrlSrcLabel.setText(java.util.ResourceBundle.getBundle("jrackattack/gui").getString("label.fm_ctrl_src"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 5;
        gridBagConstraints.gridy = 4;
        add(fmCtrlSrcLabel, gridBagConstraints);

        mixKnob.setIntValue(0);
        mixKnob.setMaximumValue(127);
        mixKnob.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                mixKnobStateChanged(evt);
            }
        });

        org.jdesktop.layout.GroupLayout mixKnobLayout = new org.jdesktop.layout.GroupLayout(mixKnob);
        mixKnob.setLayout(mixKnobLayout);
        mixKnobLayout.setHorizontalGroup(
            mixKnobLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 80, Short.MAX_VALUE)
        );
        mixKnobLayout.setVerticalGroup(
            mixKnobLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 80, Short.MAX_VALUE)
        );
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 0;
        add(mixKnob, gridBagConstraints);

        mixSpinner.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                mixSpinnerStateChanged(evt);
            }
        });

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        add(mixSpinner, gridBagConstraints);

        mixLabel.setText(java.util.ResourceBundle.getBundle("jrackattack/gui").getString("label.osc_level"));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 6;
        gridBagConstraints.gridy = 2;
        add(mixLabel, gridBagConstraints);

    }// </editor-fold>//GEN-END:initComponents

  private void mixSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_mixSpinnerStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    mixKnob.setIntValue(((Integer)mixSpinner.getValue()).intValue());
  }//GEN-LAST:event_mixSpinnerStateChanged

  private void mixKnobStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_mixKnobStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    SoundParameter sp=getSoundBuffer().getActiveSoundParameter();
    if (mode==Mode.OSC1_MODE) {
      MidiThread.getInstance().emitParamChange(this, getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC1_LEVEL, mixKnob.getIntValue());
      sp.setOsc1Level(mixKnob.getIntValue());
    } else {
      MidiThread.getInstance().emitParamChange(this,getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC2_LEVEL, mixKnob.getIntValue());
      sp.setOsc2Level(mixKnob.getIntValue());
    }
    mixSpinner.setValue(new Integer(mixKnob.getIntValue()));
  }//GEN-LAST:event_mixKnobStateChanged

  private void fmCtrlSrcBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_fmCtrlSrcBoxItemStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    SoundParameter sp=getSoundBuffer().getActiveSoundParameter();
    if (mode==Mode.OSC1_MODE) {
      MidiThread.getInstance().emitParamChange(this, getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC1_SHAPE, fmCtrlSrcBox.getSelectedIndex());
      sp.setOsc1FMCtrlSrcIndex(fmCtrlSrcBox.getSelectedIndex());
    }
  }//GEN-LAST:event_fmCtrlSrcBoxItemStateChanged

  private void fmModSrcBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_fmModSrcBoxItemStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    SoundParameter sp=getSoundBuffer().getActiveSoundParameter();
    if (mode==Mode.OSC1_MODE) {
      MidiThread.getInstance().emitParamChange(this, getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC1_SHAPE, fmModSrcBox.getSelectedIndex());
      sp.setOsc1FMModSrcIndex(fmModSrcBox.getSelectedIndex());
    }
  }//GEN-LAST:event_fmModSrcBoxItemStateChanged

  private void fmCtrlKnobStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_fmCtrlKnobStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    SoundParameter sp=getSoundBuffer().getActiveSoundParameter();
    if (mode==Mode.OSC1_MODE) {
      MidiThread.getInstance().emitParamChange(this, getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC1_FM_CTRL, fmCtrlKnob.getIntValue());
      sp.setOsc1FMCtrl(fmCtrlKnob.getIntValue());
    }
    fmCtrlSpinner.setValue(new Integer(fmCtrlKnob.getIntValue()-64));
  }//GEN-LAST:event_fmCtrlKnobStateChanged

  private void fmModKnobStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_fmModKnobStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    SoundParameter sp=getSoundBuffer().getActiveSoundParameter();
    if (mode==Mode.OSC1_MODE) {
      MidiThread.getInstance().emitParamChange(this, getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC1_FM_MOD, fmModKnob.getIntValue());
      sp.setOsc1FMMod(fmModKnob.getIntValue());
    }
    fmModSpinner.setValue(new Integer(fmModKnob.getIntValue()-64));
  }//GEN-LAST:event_fmModKnobStateChanged

  private void pitchCtrlSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_pitchCtrlSpinnerStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    pitchCtrlKnob.setIntValue(((Integer)pitchCtrlSpinner.getValue()).intValue()+64);
  }//GEN-LAST:event_pitchCtrlSpinnerStateChanged

  private void pitchModSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_pitchModSpinnerStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    pitchModKnob.setIntValue(((Integer)pitchModSpinner.getValue()).intValue()+64);
  }//GEN-LAST:event_pitchModSpinnerStateChanged

  private void detuneSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_detuneSpinnerStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    detuneKnob.setIntValue(((Integer)detuneSpinner.getValue()).intValue());
  }//GEN-LAST:event_detuneSpinnerStateChanged

  private void pitchSpinnerStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_pitchSpinnerStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    pitchKnob.setIntValue(((Integer)pitchSpinner.getValue()).intValue());
  }//GEN-LAST:event_pitchSpinnerStateChanged

  private void pitchCtrlKnobStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_pitchCtrlKnobStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    SoundParameter sp=getSoundBuffer().getActiveSoundParameter();
    if (mode==Mode.OSC1_MODE) {
      MidiThread.getInstance().emitParamChange(this, getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC1_PITCH_CTRL, pitchCtrlKnob.getIntValue());
      sp.setOsc1PitchCtrl(pitchCtrlKnob.getIntValue());
    } else {
      MidiThread.getInstance().emitParamChange(this, getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC2_PITCH_CTRL, pitchCtrlKnob.getIntValue());
      sp.setOsc2PitchCtrl(pitchCtrlKnob.getIntValue());
    }
    pitchCtrlSpinner.setValue(new Integer(pitchCtrlKnob.getIntValue()-64));
  }//GEN-LAST:event_pitchCtrlKnobStateChanged

  private void pitchModKnobStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_pitchModKnobStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    SoundParameter sp=getSoundBuffer().getActiveSoundParameter();
    if (mode==Mode.OSC1_MODE) {
      MidiThread.getInstance().emitParamChange(this, getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC1_PITCH_MOD, pitchModKnob.getIntValue());
      sp.setOsc1PitchMod(pitchModKnob.getIntValue());
    } else {
      MidiThread.getInstance().emitParamChange(this, getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC2_PITCH_MOD, pitchModKnob.getIntValue());
      sp.setOsc2PitchMod(pitchModKnob.getIntValue());
    }
    pitchModSpinner.setValue(new Integer(pitchModKnob.getIntValue()-64));
  }//GEN-LAST:event_pitchModKnobStateChanged

  private void shapeBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_shapeBoxItemStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    SoundParameter sp=getSoundBuffer().getActiveSoundParameter();
    if (mode==Mode.OSC1_MODE) {
      MidiThread.getInstance().emitParamChange(this, getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC1_SHAPE, shapeBox.getSelectedIndex());
      sp.setOsc1ShapeIndex(shapeBox.getSelectedIndex());
    } else {
      MidiThread.getInstance().emitParamChange(this, getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC2_SHAPE, shapeBox.getSelectedIndex());
      sp.setOsc2ShapeIndex(shapeBox.getSelectedIndex());
    }
  }//GEN-LAST:event_shapeBoxItemStateChanged

  private void detuneKnobStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_detuneKnobStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    SoundParameter sp=getSoundBuffer().getActiveSoundParameter();
    if (mode==Mode.OSC1_MODE) {
      MidiThread.getInstance().emitParamChange(this, getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC1_DETUNE, pitchKnob.getIntValue());
      sp.setOsc1Detune(detuneKnob.getIntValue());
    } else {
      MidiThread.getInstance().emitParamChange(this, getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC2_DETUNE, pitchKnob.getIntValue());
      sp.setOsc2Detune(detuneKnob.getIntValue());
    }
    detuneSpinner.setValue(new Integer(detuneKnob.getIntValue()));
  }//GEN-LAST:event_detuneKnobStateChanged

  private void pitchKnobStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_pitchKnobStateChanged
// TODO add your handling code here:
    if (initiating) {
      return;
    }
    /*
    Exception ex=new Exception(getClass().getName()+" --- tracer ---");
    System.err.println(ex.getMessage());
    StackTraceElement[] stes=ex.getStackTrace();
    for(StackTraceElement ste:stes) {
      System.err.println("\t"+ste);
    }
    */
    SoundParameter sp=getSoundBuffer().getActiveSoundParameter();
    if (mode==Mode.OSC1_MODE) {
      MidiThread.getInstance().emitParamChange(this, getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC1_PITCH, pitchKnob.getIntValue());
      sp.setOsc1Pitch(pitchKnob.getIntValue());
    } else {
      MidiThread.getInstance().emitParamChange(this, getSoundBuffer().getActiveSoundNumber(),
        RackAttack.OSC2_PITCH, pitchKnob.getIntValue());
      sp.setOsc2Pitch(pitchKnob.getIntValue());
    }
    pitchSpinner.setValue(new Integer(pitchKnob.getIntValue()));
  }//GEN-LAST:event_pitchKnobStateChanged


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private jrackattack.gui.JKnob detuneKnob;
    private javax.swing.JLabel detuneLabel;
    private javax.swing.JSpinner detuneSpinner;
    private jrackattack.gui.JKnob fmCtrlKnob;
    private javax.swing.JLabel fmCtrlLabel;
    private javax.swing.JSpinner fmCtrlSpinner;
    private javax.swing.JComboBox fmCtrlSrcBox;
    private javax.swing.JLabel fmCtrlSrcLabel;
    private jrackattack.gui.JKnob fmModKnob;
    private javax.swing.JLabel fmModLabel;
    private javax.swing.JSpinner fmModSpinner;
    private javax.swing.JComboBox fmModSrcBox;
    private javax.swing.JLabel fmModSrcLabel;
    private jrackattack.gui.JKnob mixKnob;
    private javax.swing.JLabel mixLabel;
    private javax.swing.JSpinner mixSpinner;
    private jrackattack.gui.JKnob pitchCtrlKnob;
    private javax.swing.JLabel pitchCtrlLabel;
    private javax.swing.JSpinner pitchCtrlSpinner;
    private javax.swing.JComboBox pitchCtrlSrcBox;
    private javax.swing.JLabel pitchCtrlSrcLabel;
    private jrackattack.gui.JKnob pitchKnob;
    private javax.swing.JLabel pitchLabel;
    private jrackattack.gui.JKnob pitchModKnob;
    private javax.swing.JLabel pitchModLabel;
    private javax.swing.JSpinner pitchModSpinner;
    private javax.swing.JComboBox pitchModSrcBox;
    private javax.swing.JLabel pitchModSrcLabel;
    private javax.swing.JSpinner pitchSpinner;
    private javax.swing.JComboBox shapeBox;
    private javax.swing.JLabel shapeLabel;
    private javax.swing.JComboBox startPhaseBox;
    private javax.swing.JLabel startPhaseLabel;
    // End of variables declaration//GEN-END:variables

  private boolean initiating;

  /**
   * Holds value of property soundBuffer.
   */
  private SoundBuffer soundBuffer;

  /**
   * Getter for property soundBuffer.
   * @return Value of property soundBuffer.
   */
  public SoundBuffer getSoundBuffer() {
    return this.soundBuffer;
  }

  /**
   * Setter for property soundBuffer.
   * @param soundBuffer New value of property soundBuffer.
   */
  public void setSoundBuffer(SoundBuffer soundBuffer) {
    this.soundBuffer = soundBuffer;
  }

  /**
   * Holds value of property mode.
   */
  private Mode mode;

  /**
   * Getter for property mode.
   * @return Value of property mode.
   */
  public Mode getMode() {
    return this.mode;
  }

  /**
   * Setter for property mode.
   * @param mode New value of property mode.
   */
  public void setMode(Mode mode) {
    this.mode = mode;
    if (mode==Mode.OSC2_MODE) {
      fmModKnob.setEnabled(false);
      fmModSpinner.setEnabled(false);
      fmCtrlKnob.setEnabled(false);
      fmCtrlSpinner.setEnabled(false);
      fmModSrcBox.setEnabled(false);
      fmCtrlSrcBox.setEnabled(false);
      fmModLabel.setEnabled(false);
      fmCtrlLabel.setEnabled(false);
      fmModSrcLabel.setEnabled(false);
      fmCtrlSrcLabel.setEnabled(false);
    } else {
      fmModKnob.setEnabled(true);
      fmModSpinner.setEnabled(true);
      fmCtrlKnob.setEnabled(true);
      fmCtrlSpinner.setEnabled(true);
      fmModSrcBox.setEnabled(true);
      fmCtrlSrcBox.setEnabled(true);
      fmModLabel.setEnabled(true);
      fmCtrlLabel.setEnabled(true);
      fmModSrcLabel.setEnabled(true);
      fmCtrlSrcLabel.setEnabled(true);
    }
  }

  /**
   * Getter for property initiating.
   * @return Value of property initiating.
   */
  public boolean isInitiating() {
    return this.initiating;
  }

  /**
   * Setter for property initiating.
   * @param initiating New value of property initiating.
   */
  public void setInitiating(boolean initiating) {
    this.initiating = initiating;
  }
}
/*
    Copyright (C) 2008  Alexander Methke

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program (gplv3.txt).
*/
TOP

Related Classes of jrackattack.gui.OscPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.