/** * Copyright (c) 2005 - Bob Lang (http://www.cems.uwe.ac.uk/~lrlang/) * * http://www.frinika.com * * This file is part of Frinika. * * Frinika 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 2 of the License, or * (at your option) any later version. * Frinika 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 Frinika; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package com.frinika.contrib.boblang; // Source file generated by UWE GUI BUILDER Version 1.6 beta Free-Ware // File Pass 1...(Class file creation) import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.border.*; import java.util.*; import java.text.*; public class BezierWaves extends JFrame implements ActionListener, WindowListener, ItemListener, ChangeListener { private static final long serialVersionUID = 1L; FrinikaBezierSynth player; // Listener objects ActionListener actionListener = this; WindowListener windowListener = this; ItemListener itemListener = this; ChangeListener changeListener = this; JComboBox presets = new JComboBox (presetsChoices); JComboBox envx1 = new JComboBox (envx1Choices); static String [] envx1Choices = { "Steady", "Rise-Fall", "Rising", "Falling", }; JComboBox envy1 = new JComboBox (envy1Choices); static String [] envy1Choices = { "Steady", "Rise-Fall", "Rising", "Falling", }; JComboBox envx2 = new JComboBox (envx2Choices); static String [] envx2Choices = { "Steady", "Rise-Fall", "Rising", "Falling", }; JComboBox envy2 = new JComboBox (envy2Choices); static String [] envy2Choices = { "Steady", "Rise-Fall", "Rising", "Falling", }; // Components for Panel presetPanel JPanel presetPanel = new JPanel (); // Components for Panel px1modenv JPanel px1modenv = new JPanel (); JSlider x1time0 = new JSlider (JSlider.HORIZONTAL, 0, 500, 0); JTextField x1time1 = new JTextField (".....", 5); // Components for Panel px1centre JPanel px1centre = new JPanel (); JSlider x1centre0 = new JSlider (JSlider.VERTICAL, 0, 100, 0); JTextField x1centre1 = new JTextField (".....", 5); // Components for Panel px1amp JPanel px1amp = new JPanel (); JSlider x1amp0 = new JSlider (JSlider.VERTICAL, 0, 100, 0); JTextField x1amp1 = new JTextField (".....", 5); // Components for Panel px1frhz JPanel px1frhz = new JPanel (); JSlider x1frhz0 = new JSlider (JSlider.VERTICAL, 0, 200, 0); JTextField x1frhz1 = new JTextField (".....", 5); // Components for Panel px1frratio JPanel px1frratio = new JPanel (); JSlider x1frin0 = new JSlider (JSlider.VERTICAL, 0, 10, 0); JSlider x1frfr0 = new JSlider (JSlider.VERTICAL, 0, 99, 0); JTextField x1fratio1 = new JTextField (".....", 5); // Components for Panel px1phase JPanel px1phase = new JPanel (); JSlider x1phase0 = new JSlider (JSlider.VERTICAL, 0, 360, 0); JTextField x1phase1 = new JTextField (".....", 5); // Components for Panel px1bordercentre JPanel px1bordercentre = new JPanel (); // Components for Panel synthx1 JPanel synthx1 = new JPanel (); // Components for Panel py1modenv JPanel py1modenv = new JPanel (); JSlider y1time0 = new JSlider (JSlider.HORIZONTAL, 0, 500, 0); JTextField y1time1 = new JTextField (".....", 5); // Components for Panel py1centre JPanel py1centre = new JPanel (); JSlider y1centre0 = new JSlider (JSlider.VERTICAL, 0, 100, 0); JTextField y1centre1 = new JTextField (".....", 5); // Components for Panel py1amp JPanel py1amp = new JPanel (); JSlider y1amp0 = new JSlider (JSlider.VERTICAL, 0, 100, 0); JTextField y1amp1 = new JTextField (".....", 5); // Components for Panel py1frhz JPanel py1frhz = new JPanel (); JSlider y1frhz0 = new JSlider (JSlider.VERTICAL, 0, 200, 0); JTextField y1frhz1 = new JTextField (".....", 5); // Components for Panel py1frratio JPanel py1frratio = new JPanel (); JSlider y1frin0 = new JSlider (JSlider.VERTICAL, 0, 10, 0); JSlider y1frfr0 = new JSlider (JSlider.VERTICAL, 0, 99, 0); JTextField y1fratio1 = new JTextField (".....", 5); // Components for Panel py1phase JPanel py1phase = new JPanel (); JSlider y1phase0 = new JSlider (JSlider.VERTICAL, 0, 360, 0); JTextField y1phase1 = new JTextField (".....", 5); // Components for Panel py1bordercentre JPanel py1bordercentre = new JPanel (); // Components for Panel synthy1 JPanel synthy1 = new JPanel (); // Components for Panel px2modenv JPanel px2modenv = new JPanel (); JSlider x2time0 = new JSlider (JSlider.HORIZONTAL, 0, 500, 0); JTextField x2time1 = new JTextField (".....", 5); // Components for Panel px2centre JPanel px2centre = new JPanel (); JSlider x2centre0 = new JSlider (JSlider.VERTICAL, 0, 100, 0); JTextField x2centre1 = new JTextField (".....", 5); // Components for Panel px2amp JPanel px2amp = new JPanel (); JSlider x2amp0 = new JSlider (JSlider.VERTICAL, 0, 100, 0); JTextField x2amp1 = new JTextField (".....", 5); // Components for Panel px2frhz JPanel px2frhz = new JPanel (); JSlider x2frhz0 = new JSlider (JSlider.VERTICAL, 0, 200, 0); JTextField x2frhz1 = new JTextField (".....", 5); // Components for Panel px2frratio JPanel px2frratio = new JPanel (); JSlider x2frin0 = new JSlider (JSlider.VERTICAL, 0, 10, 0); JSlider x2frfr0 = new JSlider (JSlider.VERTICAL, 0, 99, 0); JTextField x2fratio1 = new JTextField (".....", 5); // Components for Panel px2phase JPanel px2phase = new JPanel (); JSlider x2phase0 = new JSlider (JSlider.VERTICAL, 0, 360, 0); JTextField x2phase1 = new JTextField (".....", 5); // Components for Panel px2bordercentre JPanel px2bordercentre = new JPanel (); // Components for Panel synthx2 JPanel synthx2 = new JPanel (); // Components for Panel py2modenv JPanel py2modenv = new JPanel (); JSlider y2time0 = new JSlider (JSlider.HORIZONTAL, 0, 500, 0); JTextField y2time1 = new JTextField (".....", 5); // Components for Panel py2centre JPanel py2centre = new JPanel (); JSlider y2centre0 = new JSlider (JSlider.VERTICAL, 0, 100, 0); JTextField y2centre1 = new JTextField (".....", 5); // Components for Panel py2amp JPanel py2amp = new JPanel (); JSlider y2amp0 = new JSlider (JSlider.VERTICAL, 0, 100, 0); JTextField y2amp1 = new JTextField (".....", 5); // Components for Panel py2frhz JPanel py2frhz = new JPanel (); JSlider y2frhz0 = new JSlider (JSlider.VERTICAL, 0, 200, 0); JTextField y2frhz1 = new JTextField (".....", 5); // Components for Panel py2frratio JPanel py2frratio = new JPanel (); JSlider y2frin0 = new JSlider (JSlider.VERTICAL, 0, 10, 0); JSlider y2frfr0 = new JSlider (JSlider.VERTICAL, 0, 99, 0); JTextField y2fratio1 = new JTextField (".....", 5); // Components for Panel py2phase JPanel py2phase = new JPanel (); JSlider y2phase0 = new JSlider (JSlider.VERTICAL, 0, 360, 0); JTextField y2phase1 = new JTextField (".....", 5); // Components for Panel py2bordercentre JPanel py2bordercentre = new JPanel (); // Components for Panel synthy2 JPanel synthy2 = new JPanel (); // Components for Panel synth1Panel JPanel synth1Panel = new JPanel (); // Components for Panel synth2Panel JPanel synth2Panel = new JPanel (); // Components for Panel penvAttack JPanel penvAttack = new JPanel (); JSlider attack0 = new JSlider (JSlider.HORIZONTAL, 0, 500, 0); JLabel label1 = new JLabel (" ", JLabel.CENTER); JTextField attack1 = new JTextField (".....", 5); JLabel label2 = new JLabel (" ", JLabel.CENTER); // Components for Panel penvDecay JPanel penvDecay = new JPanel (); JSlider decay0 = new JSlider (JSlider.HORIZONTAL, 0, 500, 0); JLabel label3 = new JLabel (" ", JLabel.CENTER); JTextField decay1 = new JTextField (".....", 5); JLabel label4 = new JLabel (" ", JLabel.CENTER); // Components for Panel penvSustain JPanel penvSustain = new JPanel (); JSlider sustain0 = new JSlider (JSlider.HORIZONTAL, 0, 100, 0); JLabel label5 = new JLabel (" ", JLabel.CENTER); JTextField sustain1 = new JTextField (".....", 5); JLabel label6 = new JLabel (" ", JLabel.CENTER); // Components for Panel penvRelease JPanel penvRelease = new JPanel (); JSlider release0 = new JSlider (JSlider.HORIZONTAL, 0, 500, 0); JLabel label7 = new JLabel (" ", JLabel.CENTER); JTextField release1 = new JTextField (".....", 5); JLabel label8 = new JLabel (" ", JLabel.CENTER); // Components for Panel envelopePanel JPanel envelopePanel = new JPanel (); // Components for Tabbed Pane tabbedPanel JTabbedPane tabbedPanel = new JTabbedPane (); // Components for Panel controls JPanel controls = new JPanel (); JButton plot = new JButton ("Plot"); JLabel label9 = new JLabel (" ", JLabel.CENTER); //JButton quit = new JButton ("Quit"); JLabel label10 = new JLabel ("Bezier Synthesizer Version 3.2 - http://www.cems.uwe.ac.uk/~lrlang/BezierSynth/index.html", JLabel.CENTER); // File Pass 2...(Constructor creation) // Public constructor public BezierWaves (String title) { // Call parent constructor to give title to frame super (title); // Make this frame its own window listener addWindowListener (windowListener); presets.addItemListener (itemListener); envx1.addItemListener (itemListener); envy1.addItemListener (itemListener); envx2.addItemListener (itemListener); envy2.addItemListener (itemListener); // Panel components: presetPanel presetPanel.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Preset Voices")); presetPanel.setLayout (new FlowLayout(FlowLayout.CENTER)); presetPanel.add (presets); // Panel components: px1modenv px1modenv.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Modulation Envelope")); px1modenv.setLayout (new FlowLayout(FlowLayout.CENTER)); px1modenv.add (envx1); px1modenv.add (x1time0); x1time0.addChangeListener (changeListener); x1time0.setMajorTickSpacing (100); x1time0.setMinorTickSpacing (50); x1time0.setPaintLabels (true); relabel (x1time0, "0", 100); x1time0.setPreferredSize (new Dimension (140, 35)); px1modenv.add (x1time1); // Panel components: px1centre px1centre.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Centre%")); GridBagLayout px1centreGridBag = new GridBagLayout (); GridBagConstraints px1centreConstr = new GridBagConstraints (); px1centre.setLayout (px1centreGridBag); px1centreConstr.anchor = GridBagConstraints.CENTER; px1centreConstr.weightx = 1.0; px1centreConstr.weighty = 1.0; px1centreConstr.fill = GridBagConstraints.BOTH; px1centreConstr.gridx = 0; px1centreConstr.gridy = 0; px1centreConstr.gridwidth = 1; px1centreConstr.gridheight = 1; px1centreGridBag.setConstraints (x1centre0, px1centreConstr); px1centre.add (x1centre0); x1centre0.addChangeListener (changeListener); x1centre0.setMajorTickSpacing (10); x1centre0.setMinorTickSpacing (5); x1centre0.setPaintLabels (true); x1centre0.setPreferredSize (new Dimension (40, 140)); px1centreConstr.gridx = 0; px1centreConstr.gridy = 1; px1centreConstr.gridwidth = 1; px1centreConstr.gridheight = 1; px1centreGridBag.setConstraints (x1centre1, px1centreConstr); px1centre.add (x1centre1); // Panel components: px1amp px1amp.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Mod Amp")); GridBagLayout px1ampGridBag = new GridBagLayout (); GridBagConstraints px1ampConstr = new GridBagConstraints (); px1amp.setLayout (px1ampGridBag); px1ampConstr.anchor = GridBagConstraints.CENTER; px1ampConstr.weightx = 1.0; px1ampConstr.weighty = 1.0; px1ampConstr.fill = GridBagConstraints.BOTH; px1ampConstr.gridx = 0; px1ampConstr.gridy = 0; px1ampConstr.gridwidth = 1; px1ampConstr.gridheight = 1; px1ampGridBag.setConstraints (x1amp0, px1ampConstr); px1amp.add (x1amp0); x1amp0.addChangeListener (changeListener); x1amp0.setMajorTickSpacing (10); x1amp0.setMinorTickSpacing (5); x1amp0.setPaintLabels (true); x1amp0.setPreferredSize (new Dimension (40, 140)); px1ampConstr.gridx = 0; px1ampConstr.gridy = 1; px1ampConstr.gridwidth = 1; px1ampConstr.gridheight = 1; px1ampGridBag.setConstraints (x1amp1, px1ampConstr); px1amp.add (x1amp1); // Panel components: px1frhz px1frhz.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Freq (Hz)")); GridBagLayout px1frhzGridBag = new GridBagLayout (); GridBagConstraints px1frhzConstr = new GridBagConstraints (); px1frhz.setLayout (px1frhzGridBag); px1frhzConstr.anchor = GridBagConstraints.CENTER; px1frhzConstr.weightx = 1.0; px1frhzConstr.weighty = 1.0; px1frhzConstr.fill = GridBagConstraints.BOTH; px1frhzConstr.gridx = 0; px1frhzConstr.gridy = 0; px1frhzConstr.gridwidth = 1; px1frhzConstr.gridheight = 1; px1frhzGridBag.setConstraints (x1frhz0, px1frhzConstr); px1frhz.add (x1frhz0); x1frhz0.addChangeListener (changeListener); x1frhz0.setMajorTickSpacing (20); x1frhz0.setPaintLabels (true); relabel (x1frhz0, "0.0", 10); x1frhz0.setPreferredSize (new Dimension (40, 140)); px1frhzConstr.gridx = 0; px1frhzConstr.gridy = 1; px1frhzConstr.gridwidth = 1; px1frhzConstr.gridheight = 1; px1frhzGridBag.setConstraints (x1frhz1, px1frhzConstr); px1frhz.add (x1frhz1); // Panel components: px1frratio px1frratio.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Fr Ratio")); GridBagLayout px1frratioGridBag = new GridBagLayout (); GridBagConstraints px1frratioConstr = new GridBagConstraints (); px1frratio.setLayout (px1frratioGridBag); px1frratioConstr.anchor = GridBagConstraints.CENTER; px1frratioConstr.weightx = 1.0; px1frratioConstr.weighty = 1.0; px1frratioConstr.fill = GridBagConstraints.BOTH; px1frratioConstr.gridx = 0; px1frratioConstr.gridy = 0; px1frratioConstr.gridwidth = 1; px1frratioConstr.gridheight = 1; px1frratioGridBag.setConstraints (x1frin0, px1frratioConstr); px1frratio.add (x1frin0); x1frin0.addChangeListener (changeListener); x1frin0.setMajorTickSpacing (1); x1frin0.setPaintLabels (true); x1frin0.setPreferredSize (new Dimension (40, 140)); px1frratioConstr.gridx = 1; px1frratioConstr.gridy = 0; px1frratioConstr.gridwidth = 1; px1frratioConstr.gridheight = 1; px1frratioGridBag.setConstraints (x1frfr0, px1frratioConstr); px1frratio.add (x1frfr0); x1frfr0.addChangeListener (changeListener); x1frfr0.setMajorTickSpacing (10); x1frfr0.setPaintLabels (true); relabel (x1frfr0, ".0", 100); x1frfr0.setPreferredSize (new Dimension (40, 140)); px1frratioConstr.gridx = 0; px1frratioConstr.gridy = 1; px1frratioConstr.gridwidth = 2; px1frratioConstr.gridheight = 1; px1frratioGridBag.setConstraints (x1fratio1, px1frratioConstr); px1frratio.add (x1fratio1); // Panel components: px1phase px1phase.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Phase")); GridBagLayout px1phaseGridBag = new GridBagLayout (); GridBagConstraints px1phaseConstr = new GridBagConstraints (); px1phase.setLayout (px1phaseGridBag); px1phaseConstr.anchor = GridBagConstraints.CENTER; px1phaseConstr.weightx = 1.0; px1phaseConstr.weighty = 1.0; px1phaseConstr.fill = GridBagConstraints.BOTH; px1phaseConstr.gridx = 0; px1phaseConstr.gridy = 0; px1phaseConstr.gridwidth = 1; px1phaseConstr.gridheight = 1; px1phaseGridBag.setConstraints (x1phase0, px1phaseConstr); px1phase.add (x1phase0); x1phase0.addChangeListener (changeListener); x1phase0.setMajorTickSpacing (90); x1phase0.setMinorTickSpacing (45); x1phase0.setPaintLabels (true); x1phase0.setPreferredSize (new Dimension (40, 140)); px1phaseConstr.gridx = 0; px1phaseConstr.gridy = 1; px1phaseConstr.gridwidth = 1; px1phaseConstr.gridheight = 1; px1phaseGridBag.setConstraints (x1phase1, px1phaseConstr); px1phase.add (x1phase1); // Panel components: px1bordercentre px1bordercentre.setLayout (new FlowLayout(FlowLayout.CENTER)); px1bordercentre.add (px1centre); px1bordercentre.add (px1amp); px1bordercentre.add (px1frhz); px1bordercentre.add (px1frratio); px1bordercentre.add (px1phase); // Panel components: synthx1 synthx1.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Control Point X One")); synthx1.setLayout (new BorderLayout ()); synthx1.add ("Center", px1bordercentre); synthx1.add ("South", px1modenv); // Panel components: py1modenv py1modenv.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Modulation Envelope")); py1modenv.setLayout (new FlowLayout(FlowLayout.CENTER)); py1modenv.add (envy1); py1modenv.add (y1time0); y1time0.addChangeListener (changeListener); y1time0.setMajorTickSpacing (100); y1time0.setMinorTickSpacing (50); y1time0.setPaintLabels (true); relabel (y1time0, "0", 100); y1time0.setPreferredSize (new Dimension (140, 35)); py1modenv.add (y1time1); // Panel components: py1centre py1centre.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Centre%")); GridBagLayout py1centreGridBag = new GridBagLayout (); GridBagConstraints py1centreConstr = new GridBagConstraints (); py1centre.setLayout (py1centreGridBag); py1centreConstr.anchor = GridBagConstraints.CENTER; py1centreConstr.weightx = 1.0; py1centreConstr.weighty = 1.0; py1centreConstr.fill = GridBagConstraints.BOTH; py1centreConstr.gridx = 0; py1centreConstr.gridy = 0; py1centreConstr.gridwidth = 1; py1centreConstr.gridheight = 1; py1centreGridBag.setConstraints (y1centre0, py1centreConstr); py1centre.add (y1centre0); y1centre0.addChangeListener (changeListener); y1centre0.setMajorTickSpacing (10); y1centre0.setMinorTickSpacing (5); y1centre0.setPaintLabels (true); y1centre0.setPreferredSize (new Dimension (40, 140)); py1centreConstr.gridx = 0; py1centreConstr.gridy = 1; py1centreConstr.gridwidth = 1; py1centreConstr.gridheight = 1; py1centreGridBag.setConstraints (y1centre1, py1centreConstr); py1centre.add (y1centre1); // Panel components: py1amp py1amp.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Mod Amp")); GridBagLayout py1ampGridBag = new GridBagLayout (); GridBagConstraints py1ampConstr = new GridBagConstraints (); py1amp.setLayout (py1ampGridBag); py1ampConstr.anchor = GridBagConstraints.CENTER; py1ampConstr.weightx = 1.0; py1ampConstr.weighty = 1.0; py1ampConstr.fill = GridBagConstraints.BOTH; py1ampConstr.gridx = 0; py1ampConstr.gridy = 0; py1ampConstr.gridwidth = 1; py1ampConstr.gridheight = 1; py1ampGridBag.setConstraints (y1amp0, py1ampConstr); py1amp.add (y1amp0); y1amp0.addChangeListener (changeListener); y1amp0.setMajorTickSpacing (10); y1amp0.setMinorTickSpacing (5); y1amp0.setPaintLabels (true); y1amp0.setPreferredSize (new Dimension (40, 140)); py1ampConstr.gridx = 0; py1ampConstr.gridy = 1; py1ampConstr.gridwidth = 1; py1ampConstr.gridheight = 1; py1ampGridBag.setConstraints (y1amp1, py1ampConstr); py1amp.add (y1amp1); // Panel components: py1frhz py1frhz.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Freq (Hz)")); GridBagLayout py1frhzGridBag = new GridBagLayout (); GridBagConstraints py1frhzConstr = new GridBagConstraints (); py1frhz.setLayout (py1frhzGridBag); py1frhzConstr.anchor = GridBagConstraints.CENTER; py1frhzConstr.weightx = 1.0; py1frhzConstr.weighty = 1.0; py1frhzConstr.fill = GridBagConstraints.BOTH; py1frhzConstr.gridx = 0; py1frhzConstr.gridy = 0; py1frhzConstr.gridwidth = 1; py1frhzConstr.gridheight = 1; py1frhzGridBag.setConstraints (y1frhz0, py1frhzConstr); py1frhz.add (y1frhz0); y1frhz0.addChangeListener (changeListener); y1frhz0.setMajorTickSpacing (20); y1frhz0.setPaintLabels (true); relabel (y1frhz0, "0.0", 10); y1frhz0.setPreferredSize (new Dimension (40, 140)); py1frhzConstr.gridx = 0; py1frhzConstr.gridy = 1; py1frhzConstr.gridwidth = 1; py1frhzConstr.gridheight = 1; py1frhzGridBag.setConstraints (y1frhz1, py1frhzConstr); py1frhz.add (y1frhz1); // Panel components: py1frratio py1frratio.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Fr Ratio")); GridBagLayout py1frratioGridBag = new GridBagLayout (); GridBagConstraints py1frratioConstr = new GridBagConstraints (); py1frratio.setLayout (py1frratioGridBag); py1frratioConstr.anchor = GridBagConstraints.CENTER; py1frratioConstr.weightx = 1.0; py1frratioConstr.weighty = 1.0; py1frratioConstr.fill = GridBagConstraints.BOTH; py1frratioConstr.gridx = 0; py1frratioConstr.gridy = 0; py1frratioConstr.gridwidth = 1; py1frratioConstr.gridheight = 1; py1frratioGridBag.setConstraints (y1frin0, py1frratioConstr); py1frratio.add (y1frin0); y1frin0.addChangeListener (changeListener); y1frin0.setMajorTickSpacing (1); y1frin0.setPaintLabels (true); y1frin0.setPreferredSize (new Dimension (40, 140)); py1frratioConstr.gridx = 1; py1frratioConstr.gridy = 0; py1frratioConstr.gridwidth = 1; py1frratioConstr.gridheight = 1; py1frratioGridBag.setConstraints (y1frfr0, py1frratioConstr); py1frratio.add (y1frfr0); y1frfr0.addChangeListener (changeListener); y1frfr0.setMajorTickSpacing (10); y1frfr0.setPaintLabels (true); relabel (y1frfr0, ".0", 100); y1frfr0.setPreferredSize (new Dimension (40, 140)); py1frratioConstr.gridx = 0; py1frratioConstr.gridy = 1; py1frratioConstr.gridwidth = 2; py1frratioConstr.gridheight = 1; py1frratioGridBag.setConstraints (y1fratio1, py1frratioConstr); py1frratio.add (y1fratio1); // Panel components: py1phase py1phase.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Phase")); GridBagLayout py1phaseGridBag = new GridBagLayout (); GridBagConstraints py1phaseConstr = new GridBagConstraints (); py1phase.setLayout (py1phaseGridBag); py1phaseConstr.anchor = GridBagConstraints.CENTER; py1phaseConstr.weightx = 1.0; py1phaseConstr.weighty = 1.0; py1phaseConstr.fill = GridBagConstraints.BOTH; py1phaseConstr.gridx = 0; py1phaseConstr.gridy = 0; py1phaseConstr.gridwidth = 1; py1phaseConstr.gridheight = 1; py1phaseGridBag.setConstraints (y1phase0, py1phaseConstr); py1phase.add (y1phase0); y1phase0.addChangeListener (changeListener); y1phase0.setMajorTickSpacing (90); y1phase0.setMinorTickSpacing (45); y1phase0.setPaintLabels (true); y1phase0.setPreferredSize (new Dimension (40, 140)); py1phaseConstr.gridx = 0; py1phaseConstr.gridy = 1; py1phaseConstr.gridwidth = 1; py1phaseConstr.gridheight = 1; py1phaseGridBag.setConstraints (y1phase1, py1phaseConstr); py1phase.add (y1phase1); // Panel components: py1bordercentre py1bordercentre.setLayout (new FlowLayout(FlowLayout.CENTER)); py1bordercentre.add (py1centre); py1bordercentre.add (py1amp); py1bordercentre.add (py1frhz); py1bordercentre.add (py1frratio); py1bordercentre.add (py1phase); // Panel components: synthy1 synthy1.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Control Point Y One")); synthy1.setLayout (new BorderLayout ()); synthy1.add ("Center", py1bordercentre); synthy1.add ("South", py1modenv); // Panel components: px2modenv px2modenv.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Modulation Envelope")); px2modenv.setLayout (new FlowLayout(FlowLayout.CENTER)); px2modenv.add (envx2); px2modenv.add (x2time0); x2time0.addChangeListener (changeListener); x2time0.setMajorTickSpacing (100); x2time0.setMinorTickSpacing (50); x2time0.setPaintLabels (true); relabel (x2time0, "0", 100); x2time0.setPreferredSize (new Dimension (140, 35)); px2modenv.add (x2time1); // Panel components: px2centre px2centre.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Centre%")); GridBagLayout px2centreGridBag = new GridBagLayout (); GridBagConstraints px2centreConstr = new GridBagConstraints (); px2centre.setLayout (px2centreGridBag); px2centreConstr.anchor = GridBagConstraints.CENTER; px2centreConstr.weightx = 1.0; px2centreConstr.weighty = 1.0; px2centreConstr.fill = GridBagConstraints.BOTH; px2centreConstr.gridx = 0; px2centreConstr.gridy = 0; px2centreConstr.gridwidth = 1; px2centreConstr.gridheight = 1; px2centreGridBag.setConstraints (x2centre0, px2centreConstr); px2centre.add (x2centre0); x2centre0.addChangeListener (changeListener); x2centre0.setMajorTickSpacing (10); x2centre0.setMinorTickSpacing (5); x2centre0.setPaintLabels (true); x2centre0.setPreferredSize (new Dimension (40, 140)); px2centreConstr.gridx = 0; px2centreConstr.gridy = 1; px2centreConstr.gridwidth = 1; px2centreConstr.gridheight = 1; px2centreGridBag.setConstraints (x2centre1, px2centreConstr); px2centre.add (x2centre1); // Panel components: px2amp px2amp.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Mod Amp")); GridBagLayout px2ampGridBag = new GridBagLayout (); GridBagConstraints px2ampConstr = new GridBagConstraints (); px2amp.setLayout (px2ampGridBag); px2ampConstr.anchor = GridBagConstraints.CENTER; px2ampConstr.weightx = 1.0; px2ampConstr.weighty = 1.0; px2ampConstr.fill = GridBagConstraints.BOTH; px2ampConstr.gridx = 0; px2ampConstr.gridy = 0; px2ampConstr.gridwidth = 1; px2ampConstr.gridheight = 1; px2ampGridBag.setConstraints (x2amp0, px2ampConstr); px2amp.add (x2amp0); x2amp0.addChangeListener (changeListener); x2amp0.setMajorTickSpacing (10); x2amp0.setMinorTickSpacing (5); x2amp0.setPaintLabels (true); x2amp0.setPreferredSize (new Dimension (40, 140)); px2ampConstr.gridx = 0; px2ampConstr.gridy = 1; px2ampConstr.gridwidth = 1; px2ampConstr.gridheight = 1; px2ampGridBag.setConstraints (x2amp1, px2ampConstr); px2amp.add (x2amp1); // Panel components: px2frhz px2frhz.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Freq (Hz)")); GridBagLayout px2frhzGridBag = new GridBagLayout (); GridBagConstraints px2frhzConstr = new GridBagConstraints (); px2frhz.setLayout (px2frhzGridBag); px2frhzConstr.anchor = GridBagConstraints.CENTER; px2frhzConstr.weightx = 1.0; px2frhzConstr.weighty = 1.0; px2frhzConstr.fill = GridBagConstraints.BOTH; px2frhzConstr.gridx = 0; px2frhzConstr.gridy = 0; px2frhzConstr.gridwidth = 1; px2frhzConstr.gridheight = 1; px2frhzGridBag.setConstraints (x2frhz0, px2frhzConstr); px2frhz.add (x2frhz0); x2frhz0.addChangeListener (changeListener); x2frhz0.setMajorTickSpacing (20); x2frhz0.setPaintLabels (true); relabel (x2frhz0, "0.0", 10); x2frhz0.setPreferredSize (new Dimension (40, 140)); px2frhzConstr.gridx = 0; px2frhzConstr.gridy = 1; px2frhzConstr.gridwidth = 1; px2frhzConstr.gridheight = 1; px2frhzGridBag.setConstraints (x2frhz1, px2frhzConstr); px2frhz.add (x2frhz1); // Panel components: px2frratio px2frratio.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Fr Ratio")); GridBagLayout px2frratioGridBag = new GridBagLayout (); GridBagConstraints px2frratioConstr = new GridBagConstraints (); px2frratio.setLayout (px2frratioGridBag); px2frratioConstr.anchor = GridBagConstraints.CENTER; px2frratioConstr.weightx = 1.0; px2frratioConstr.weighty = 1.0; px2frratioConstr.fill = GridBagConstraints.BOTH; px2frratioConstr.gridx = 0; px2frratioConstr.gridy = 0; px2frratioConstr.gridwidth = 1; px2frratioConstr.gridheight = 1; px2frratioGridBag.setConstraints (x2frin0, px2frratioConstr); px2frratio.add (x2frin0); x2frin0.addChangeListener (changeListener); x2frin0.setMajorTickSpacing (1); x2frin0.setPaintLabels (true); x2frin0.setPreferredSize (new Dimension (40, 140)); px2frratioConstr.gridx = 1; px2frratioConstr.gridy = 0; px2frratioConstr.gridwidth = 1; px2frratioConstr.gridheight = 1; px2frratioGridBag.setConstraints (x2frfr0, px2frratioConstr); px2frratio.add (x2frfr0); x2frfr0.addChangeListener (changeListener); x2frfr0.setMajorTickSpacing (10); x2frfr0.setPaintLabels (true); relabel (x2frfr0, ".0", 100); x2frfr0.setPreferredSize (new Dimension (40, 140)); px2frratioConstr.gridx = 0; px2frratioConstr.gridy = 1; px2frratioConstr.gridwidth = 2; px2frratioConstr.gridheight = 1; px2frratioGridBag.setConstraints (x2fratio1, px2frratioConstr); px2frratio.add (x2fratio1); // Panel components: px2phase px2phase.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Phase")); GridBagLayout px2phaseGridBag = new GridBagLayout (); GridBagConstraints px2phaseConstr = new GridBagConstraints (); px2phase.setLayout (px2phaseGridBag); px2phaseConstr.anchor = GridBagConstraints.CENTER; px2phaseConstr.weightx = 1.0; px2phaseConstr.weighty = 1.0; px2phaseConstr.fill = GridBagConstraints.BOTH; px2phaseConstr.gridx = 0; px2phaseConstr.gridy = 0; px2phaseConstr.gridwidth = 1; px2phaseConstr.gridheight = 1; px2phaseGridBag.setConstraints (x2phase0, px2phaseConstr); px2phase.add (x2phase0); x2phase0.addChangeListener (changeListener); x2phase0.setMajorTickSpacing (90); x2phase0.setMinorTickSpacing (45); x2phase0.setPaintLabels (true); x2phase0.setPreferredSize (new Dimension (40, 140)); px2phaseConstr.gridx = 0; px2phaseConstr.gridy = 1; px2phaseConstr.gridwidth = 1; px2phaseConstr.gridheight = 1; px2phaseGridBag.setConstraints (x2phase1, px2phaseConstr); px2phase.add (x2phase1); // Panel components: px2bordercentre px2bordercentre.setLayout (new FlowLayout(FlowLayout.CENTER)); px2bordercentre.add (px2centre); px2bordercentre.add (px2amp); px2bordercentre.add (px2frhz); px2bordercentre.add (px2frratio); px2bordercentre.add (px2phase); // Panel components: synthx2 synthx2.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Control Point X Two")); synthx2.setLayout (new BorderLayout ()); synthx2.add ("Center", px2bordercentre); synthx2.add ("South", px2modenv); // Panel components: py2modenv py2modenv.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Modulation Envelope")); py2modenv.setLayout (new FlowLayout(FlowLayout.CENTER)); py2modenv.add (envy2); py2modenv.add (y2time0); y2time0.addChangeListener (changeListener); y2time0.setMajorTickSpacing (100); y2time0.setMinorTickSpacing (50); y2time0.setPaintLabels (true); relabel (y2time0, "0", 100); y2time0.setPreferredSize (new Dimension (140, 35)); py2modenv.add (y2time1); // Panel components: py2centre py2centre.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Centre%")); GridBagLayout py2centreGridBag = new GridBagLayout (); GridBagConstraints py2centreConstr = new GridBagConstraints (); py2centre.setLayout (py2centreGridBag); py2centreConstr.anchor = GridBagConstraints.CENTER; py2centreConstr.weightx = 1.0; py2centreConstr.weighty = 1.0; py2centreConstr.fill = GridBagConstraints.BOTH; py2centreConstr.gridx = 0; py2centreConstr.gridy = 0; py2centreConstr.gridwidth = 1; py2centreConstr.gridheight = 1; py2centreGridBag.setConstraints (y2centre0, py2centreConstr); py2centre.add (y2centre0); y2centre0.addChangeListener (changeListener); y2centre0.setMajorTickSpacing (10); y2centre0.setMinorTickSpacing (5); y2centre0.setPaintLabels (true); y2centre0.setPreferredSize (new Dimension (40, 140)); py2centreConstr.gridx = 0; py2centreConstr.gridy = 1; py2centreConstr.gridwidth = 1; py2centreConstr.gridheight = 1; py2centreGridBag.setConstraints (y2centre1, py2centreConstr); py2centre.add (y2centre1); // Panel components: py2amp py2amp.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Mod Amp")); GridBagLayout py2ampGridBag = new GridBagLayout (); GridBagConstraints py2ampConstr = new GridBagConstraints (); py2amp.setLayout (py2ampGridBag); py2ampConstr.anchor = GridBagConstraints.CENTER; py2ampConstr.weightx = 1.0; py2ampConstr.weighty = 1.0; py2ampConstr.fill = GridBagConstraints.BOTH; py2ampConstr.gridx = 0; py2ampConstr.gridy = 0; py2ampConstr.gridwidth = 1; py2ampConstr.gridheight = 1; py2ampGridBag.setConstraints (y2amp0, py2ampConstr); py2amp.add (y2amp0); y2amp0.addChangeListener (changeListener); y2amp0.setMajorTickSpacing (10); y2amp0.setMinorTickSpacing (5); y2amp0.setPaintLabels (true); y2amp0.setPreferredSize (new Dimension (40, 140)); py2ampConstr.gridx = 0; py2ampConstr.gridy = 1; py2ampConstr.gridwidth = 1; py2ampConstr.gridheight = 1; py2ampGridBag.setConstraints (y2amp1, py2ampConstr); py2amp.add (y2amp1); // Panel components: py2frhz py2frhz.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Freq (Hz)")); GridBagLayout py2frhzGridBag = new GridBagLayout (); GridBagConstraints py2frhzConstr = new GridBagConstraints (); py2frhz.setLayout (py2frhzGridBag); py2frhzConstr.anchor = GridBagConstraints.CENTER; py2frhzConstr.weightx = 1.0; py2frhzConstr.weighty = 1.0; py2frhzConstr.fill = GridBagConstraints.BOTH; py2frhzConstr.gridx = 0; py2frhzConstr.gridy = 0; py2frhzConstr.gridwidth = 1; py2frhzConstr.gridheight = 1; py2frhzGridBag.setConstraints (y2frhz0, py2frhzConstr); py2frhz.add (y2frhz0); y2frhz0.addChangeListener (changeListener); y2frhz0.setMajorTickSpacing (20); y2frhz0.setPaintLabels (true); relabel (y2frhz0, "0.0", 10); y2frhz0.setPreferredSize (new Dimension (40, 140)); py2frhzConstr.gridx = 0; py2frhzConstr.gridy = 1; py2frhzConstr.gridwidth = 1; py2frhzConstr.gridheight = 1; py2frhzGridBag.setConstraints (y2frhz1, py2frhzConstr); py2frhz.add (y2frhz1); // Panel components: py2frratio py2frratio.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Fr Ratio")); GridBagLayout py2frratioGridBag = new GridBagLayout (); GridBagConstraints py2frratioConstr = new GridBagConstraints (); py2frratio.setLayout (py2frratioGridBag); py2frratioConstr.anchor = GridBagConstraints.CENTER; py2frratioConstr.weightx = 1.0; py2frratioConstr.weighty = 1.0; py2frratioConstr.fill = GridBagConstraints.BOTH; py2frratioConstr.gridx = 0; py2frratioConstr.gridy = 0; py2frratioConstr.gridwidth = 1; py2frratioConstr.gridheight = 1; py2frratioGridBag.setConstraints (y2frin0, py2frratioConstr); py2frratio.add (y2frin0); y2frin0.addChangeListener (changeListener); y2frin0.setMajorTickSpacing (1); y2frin0.setPaintLabels (true); y2frin0.setPreferredSize (new Dimension (40, 140)); py2frratioConstr.gridx = 1; py2frratioConstr.gridy = 0; py2frratioConstr.gridwidth = 1; py2frratioConstr.gridheight = 1; py2frratioGridBag.setConstraints (y2frfr0, py2frratioConstr); py2frratio.add (y2frfr0); y2frfr0.addChangeListener (changeListener); y2frfr0.setMajorTickSpacing (10); y2frfr0.setPaintLabels (true); relabel (y2frfr0, ".0", 100); y2frfr0.setPreferredSize (new Dimension (40, 140)); py2frratioConstr.gridx = 0; py2frratioConstr.gridy = 1; py2frratioConstr.gridwidth = 2; py2frratioConstr.gridheight = 1; py2frratioGridBag.setConstraints (y2fratio1, py2frratioConstr); py2frratio.add (y2fratio1); // Panel components: py2phase py2phase.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Phase")); GridBagLayout py2phaseGridBag = new GridBagLayout (); GridBagConstraints py2phaseConstr = new GridBagConstraints (); py2phase.setLayout (py2phaseGridBag); py2phaseConstr.anchor = GridBagConstraints.CENTER; py2phaseConstr.weightx = 1.0; py2phaseConstr.weighty = 1.0; py2phaseConstr.fill = GridBagConstraints.BOTH; py2phaseConstr.gridx = 0; py2phaseConstr.gridy = 0; py2phaseConstr.gridwidth = 1; py2phaseConstr.gridheight = 1; py2phaseGridBag.setConstraints (y2phase0, py2phaseConstr); py2phase.add (y2phase0); y2phase0.addChangeListener (changeListener); y2phase0.setMajorTickSpacing (90); y2phase0.setMinorTickSpacing (45); y2phase0.setPaintLabels (true); y2phase0.setPreferredSize (new Dimension (40, 140)); py2phaseConstr.gridx = 0; py2phaseConstr.gridy = 1; py2phaseConstr.gridwidth = 1; py2phaseConstr.gridheight = 1; py2phaseGridBag.setConstraints (y2phase1, py2phaseConstr); py2phase.add (y2phase1); // Panel components: py2bordercentre py2bordercentre.setLayout (new FlowLayout(FlowLayout.CENTER)); py2bordercentre.add (py2centre); py2bordercentre.add (py2amp); py2bordercentre.add (py2frhz); py2bordercentre.add (py2frratio); py2bordercentre.add (py2phase); // Panel components: synthy2 synthy2.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Control Point Y Two")); synthy2.setLayout (new BorderLayout ()); synthy2.add ("Center", py2bordercentre); synthy2.add ("South", py2modenv); // Panel components: synth1Panel GridBagLayout synth1PanelGridBag = new GridBagLayout (); GridBagConstraints synth1PanelConstr = new GridBagConstraints (); synth1Panel.setLayout (synth1PanelGridBag); synth1PanelConstr.anchor = GridBagConstraints.CENTER; synth1PanelConstr.weightx = 1.0; synth1PanelConstr.weighty = 1.0; synth1PanelConstr.fill = GridBagConstraints.BOTH; synth1PanelConstr.gridx = 0; synth1PanelConstr.gridy = 0; synth1PanelConstr.gridwidth = 1; synth1PanelConstr.gridheight = 1; synth1PanelGridBag.setConstraints (synthx1, synth1PanelConstr); synth1Panel.add (synthx1); synth1PanelConstr.gridx = 1; synth1PanelConstr.gridy = 0; synth1PanelConstr.gridwidth = 1; synth1PanelConstr.gridheight = 1; synth1PanelGridBag.setConstraints (synthy1, synth1PanelConstr); synth1Panel.add (synthy1); // Panel components: synth2Panel GridBagLayout synth2PanelGridBag = new GridBagLayout (); GridBagConstraints synth2PanelConstr = new GridBagConstraints (); synth2Panel.setLayout (synth2PanelGridBag); synth2PanelConstr.anchor = GridBagConstraints.CENTER; synth2PanelConstr.weightx = 1.0; synth2PanelConstr.weighty = 1.0; synth2PanelConstr.fill = GridBagConstraints.BOTH; synth2PanelConstr.gridx = 0; synth2PanelConstr.gridy = 0; synth2PanelConstr.gridwidth = 1; synth2PanelConstr.gridheight = 1; synth2PanelGridBag.setConstraints (synthx2, synth2PanelConstr); synth2Panel.add (synthx2); synth2PanelConstr.gridx = 1; synth2PanelConstr.gridy = 0; synth2PanelConstr.gridwidth = 1; synth2PanelConstr.gridheight = 1; synth2PanelGridBag.setConstraints (synthy2, synth2PanelConstr); synth2Panel.add (synthy2); // Panel components: penvAttack penvAttack.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Attack")); GridBagLayout penvAttackGridBag = new GridBagLayout (); GridBagConstraints penvAttackConstr = new GridBagConstraints (); penvAttack.setLayout (penvAttackGridBag); penvAttackConstr.anchor = GridBagConstraints.CENTER; penvAttackConstr.weightx = 1.0; penvAttackConstr.weighty = 1.0; penvAttackConstr.fill = GridBagConstraints.BOTH; penvAttackConstr.gridx = 0; penvAttackConstr.gridy = 0; penvAttackConstr.gridwidth = 3; penvAttackConstr.gridheight = 1; penvAttackGridBag.setConstraints (attack0, penvAttackConstr); penvAttack.add (attack0); attack0.addChangeListener (changeListener); attack0.setMajorTickSpacing (100); attack0.setMinorTickSpacing (50); attack0.setPaintLabels (true); relabel (attack0, "0", 100); attack0.setPreferredSize (new Dimension (140, 35)); penvAttackConstr.gridx = 0; penvAttackConstr.gridy = 1; penvAttackConstr.gridwidth = 1; penvAttackConstr.gridheight = 1; penvAttackGridBag.setConstraints (label1, penvAttackConstr); penvAttack.add (label1); penvAttackConstr.gridx = 1; penvAttackConstr.gridy = 1; penvAttackConstr.gridwidth = 1; penvAttackConstr.gridheight = 1; penvAttackGridBag.setConstraints (attack1, penvAttackConstr); penvAttack.add (attack1); penvAttackConstr.gridx = 2; penvAttackConstr.gridy = 1; penvAttackConstr.gridwidth = 1; penvAttackConstr.gridheight = 1; penvAttackGridBag.setConstraints (label2, penvAttackConstr); penvAttack.add (label2); // Panel components: penvDecay penvDecay.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Decay")); GridBagLayout penvDecayGridBag = new GridBagLayout (); GridBagConstraints penvDecayConstr = new GridBagConstraints (); penvDecay.setLayout (penvDecayGridBag); penvDecayConstr.anchor = GridBagConstraints.CENTER; penvDecayConstr.weightx = 1.0; penvDecayConstr.weighty = 1.0; penvDecayConstr.fill = GridBagConstraints.BOTH; penvDecayConstr.gridx = 0; penvDecayConstr.gridy = 0; penvDecayConstr.gridwidth = 3; penvDecayConstr.gridheight = 1; penvDecayGridBag.setConstraints (decay0, penvDecayConstr); penvDecay.add (decay0); decay0.addChangeListener (changeListener); decay0.setMajorTickSpacing (100); decay0.setMinorTickSpacing (50); decay0.setPaintLabels (true); relabel (decay0, "0", 100); decay0.setPreferredSize (new Dimension (140, 35)); penvDecayConstr.gridx = 0; penvDecayConstr.gridy = 1; penvDecayConstr.gridwidth = 1; penvDecayConstr.gridheight = 1; penvDecayGridBag.setConstraints (label3, penvDecayConstr); penvDecay.add (label3); penvDecayConstr.gridx = 1; penvDecayConstr.gridy = 1; penvDecayConstr.gridwidth = 1; penvDecayConstr.gridheight = 1; penvDecayGridBag.setConstraints (decay1, penvDecayConstr); penvDecay.add (decay1); penvDecayConstr.gridx = 2; penvDecayConstr.gridy = 1; penvDecayConstr.gridwidth = 1; penvDecayConstr.gridheight = 1; penvDecayGridBag.setConstraints (label4, penvDecayConstr); penvDecay.add (label4); // Panel components: penvSustain penvSustain.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Sustain")); GridBagLayout penvSustainGridBag = new GridBagLayout (); GridBagConstraints penvSustainConstr = new GridBagConstraints (); penvSustain.setLayout (penvSustainGridBag); penvSustainConstr.anchor = GridBagConstraints.CENTER; penvSustainConstr.weightx = 1.0; penvSustainConstr.weighty = 1.0; penvSustainConstr.fill = GridBagConstraints.BOTH; penvSustainConstr.gridx = 0; penvSustainConstr.gridy = 0; penvSustainConstr.gridwidth = 3; penvSustainConstr.gridheight = 1; penvSustainGridBag.setConstraints (sustain0, penvSustainConstr); penvSustain.add (sustain0); sustain0.addChangeListener (changeListener); sustain0.setMajorTickSpacing (20); sustain0.setMinorTickSpacing (10); sustain0.setPaintLabels (true); sustain0.setPreferredSize (new Dimension (140, 35)); penvSustainConstr.gridx = 0; penvSustainConstr.gridy = 1; penvSustainConstr.gridwidth = 1; penvSustainConstr.gridheight = 1; penvSustainGridBag.setConstraints (label5, penvSustainConstr); penvSustain.add (label5); penvSustainConstr.gridx = 1; penvSustainConstr.gridy = 1; penvSustainConstr.gridwidth = 1; penvSustainConstr.gridheight = 1; penvSustainGridBag.setConstraints (sustain1, penvSustainConstr); penvSustain.add (sustain1); penvSustainConstr.gridx = 2; penvSustainConstr.gridy = 1; penvSustainConstr.gridwidth = 1; penvSustainConstr.gridheight = 1; penvSustainGridBag.setConstraints (label6, penvSustainConstr); penvSustain.add (label6); // Panel components: penvRelease penvRelease.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Release")); GridBagLayout penvReleaseGridBag = new GridBagLayout (); GridBagConstraints penvReleaseConstr = new GridBagConstraints (); penvRelease.setLayout (penvReleaseGridBag); penvReleaseConstr.anchor = GridBagConstraints.CENTER; penvReleaseConstr.weightx = 1.0; penvReleaseConstr.weighty = 1.0; penvReleaseConstr.fill = GridBagConstraints.BOTH; penvReleaseConstr.gridx = 0; penvReleaseConstr.gridy = 0; penvReleaseConstr.gridwidth = 3; penvReleaseConstr.gridheight = 1; penvReleaseGridBag.setConstraints (release0, penvReleaseConstr); penvRelease.add (release0); release0.addChangeListener (changeListener); release0.setMajorTickSpacing (100); release0.setMinorTickSpacing (50); release0.setPaintLabels (true); relabel (release0, "0", 100); release0.setPreferredSize (new Dimension (140, 35)); penvReleaseConstr.gridx = 0; penvReleaseConstr.gridy = 1; penvReleaseConstr.gridwidth = 1; penvReleaseConstr.gridheight = 1; penvReleaseGridBag.setConstraints (label7, penvReleaseConstr); penvRelease.add (label7); penvReleaseConstr.gridx = 1; penvReleaseConstr.gridy = 1; penvReleaseConstr.gridwidth = 1; penvReleaseConstr.gridheight = 1; penvReleaseGridBag.setConstraints (release1, penvReleaseConstr); penvRelease.add (release1); penvReleaseConstr.gridx = 2; penvReleaseConstr.gridy = 1; penvReleaseConstr.gridwidth = 1; penvReleaseConstr.gridheight = 1; penvReleaseGridBag.setConstraints (label8, penvReleaseConstr); penvRelease.add (label8); // Panel components: envelopePanel envelopePanel.setBorder (new TitledBorder ( new BevelBorder (BevelBorder.RAISED), "Overall Envelope")); envelopePanel.setLayout (new FlowLayout(FlowLayout.CENTER)); envelopePanel.add (penvAttack); envelopePanel.add (penvDecay); envelopePanel.add (penvSustain); envelopePanel.add (penvRelease); // Tabbed Pane components: tabbedPanel tabbedPanel.addTab ("Presets", presetPanel); tabbedPanel.addTab ("Control Point 1", synth1Panel); tabbedPanel.addTab ("Control Point 2", synth2Panel); tabbedPanel.addTab ("Envelope", envelopePanel); // Panel components: controls controls.setLayout (new FlowLayout(FlowLayout.CENTER)); controls.add (plot); plot.addActionListener (actionListener); controls.add (label9); //controls.add (quit); //quit.addActionListener (actionListener); this.getContentPane ().setLayout (new BorderLayout ()); this.getContentPane ().add ("North", label10); this.getContentPane ().add ("Center", tabbedPanel); this.getContentPane ().add ("South", controls); // Set frame size and show it setSize (950, 450); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); } // Frame constructor BezierWaves () private static void relabel (JSlider slider, String format, int divisor) { DecimalFormat df = new DecimalFormat (format); Dictionary d = slider.getLabelTable (); Enumeration keys = d.keys (); while (keys.hasMoreElements ()) { Object key = keys.nextElement (); JLabel label = (JLabel) d.get (key); String labelText = label.getText (); int labelValue = Integer.parseInt (labelText); double newValue = (double)labelValue/(double) divisor; String newLabel = df.format (newValue); d.put (key, new JLabel (newLabel)); } slider.setLabelTable (d); } // relabel () //File Pass 3...(Window and Action Listeners) // Window listener interface methods public void windowActivated (WindowEvent e) { //$ System.out.println ("Window activated"); } // windowActivated () public void windowClosed (WindowEvent e) { //$ System.out.println ("Window closed"); } // windowClosed () public void windowClosing (WindowEvent e) { //$ System.out.println ("Window closing"); // System.exit (0); } // windowClosing () public void windowDeactivated (WindowEvent e) { //$ System.out.println ("Window deactivated"); } // windowDeactivated () public void windowDeiconified (WindowEvent e) { //$ System.out.println ("Window deiconified"); } // windowDeiconified () public void windowIconified (WindowEvent e) { //$ System.out.println ("Window iconified"); } // windowIconifed () public void windowOpened (WindowEvent e) { //$ System.out.println ("Window opened"); } // windowOpened () // Action Listener interface method public void actionPerformed (ActionEvent event) { Object target = event.getSource (); if (target == x1time1) { //$ System.out.println ("AE1 TextField x1time1 selected"); } else if (target == x1centre1) { //$ System.out.println ("AE2 TextField x1centre1 selected"); } else if (target == x1amp1) { //$ System.out.println ("AE3 TextField x1amp1 selected"); } else if (target == x1frhz1) { //$ System.out.println ("AE4 TextField x1frhz1 selected"); } else if (target == x1fratio1) { //$ System.out.println ("AE5 TextField x1fratio1 selected"); } else if (target == x1phase1) { //$ System.out.println ("AE6 TextField x1phase1 selected"); } else if (target == y1time1) { //$ System.out.println ("AE7 TextField y1time1 selected"); } else if (target == y1centre1) { //$ System.out.println ("AE8 TextField y1centre1 selected"); } else if (target == y1amp1) { //$ System.out.println ("AE9 TextField y1amp1 selected"); } else if (target == y1frhz1) { //$ System.out.println ("AE10 TextField y1frhz1 selected"); } else if (target == y1fratio1) { //$ System.out.println ("AE11 TextField y1fratio1 selected"); } else if (target == y1phase1) { //$ System.out.println ("AE12 TextField y1phase1 selected"); } else if (target == x2time1) { //$ System.out.println ("AE13 TextField x2time1 selected"); } else if (target == x2centre1) { //$ System.out.println ("AE14 TextField x2centre1 selected"); } else if (target == x2amp1) { //$ System.out.println ("AE15 TextField x2amp1 selected"); } else if (target == x2frhz1) { //$ System.out.println ("AE16 TextField x2frhz1 selected"); } else if (target == x2fratio1) { //$ System.out.println ("AE17 TextField x2fratio1 selected"); } else if (target == x2phase1) { //$ System.out.println ("AE18 TextField x2phase1 selected"); } else if (target == y2time1) { //$ System.out.println ("AE19 TextField y2time1 selected"); } else if (target == y2centre1) { //$ System.out.println ("AE20 TextField y2centre1 selected"); } else if (target == y2amp1) { //$ System.out.println ("AE21 TextField y2amp1 selected"); } else if (target == y2frhz1) { //$ System.out.println ("AE22 TextField y2frhz1 selected"); } else if (target == y2fratio1) { //$ System.out.println ("AE23 TextField y2fratio1 selected"); } else if (target == y2phase1) { //$ System.out.println ("AE24 TextField y2phase1 selected"); } else if (target == attack1) { //$ System.out.println ("AE25 TextField attack1 selected"); } else if (target == decay1) { //$ System.out.println ("AE26 TextField decay1 selected"); } else if (target == sustain1) { //$ System.out.println ("AE27 TextField sustain1 selected"); } else if (target == release1) { //$ System.out.println ("AE28 TextField release1 selected"); } else if (target == plot) { //$ System.out.println ("AE29 JButton plot selected"); plotButton (); } /*else if (target == quit) { //$ System.out.println ("AE30 JButton quit selected"); quitButton (); }*/ else { } // if } // actionPerformed () //File Pass 4...(Document Listener) // Replace the end of the automatically generated gui by this data! //File Pass 5...(Item Listener) // Item Listener interface method public void itemStateChanged (ItemEvent event) { Object target = event.getSource (); //$ System.out.println (target); if (target == presets) { if (event.getStateChange () == ItemEvent.SELECTED){ //$ System.out.print ("IS1 Item presets changed to: "); //$ System.out.print (presets.getSelectedIndex () + " "); //$ System.out.println (presets.getSelectedItem ()); int index = presets.getSelectedIndex (); changePreset (presetSettings [index]); } } else if (target == envx1) { if (event.getStateChange () == ItemEvent.SELECTED){ //$ System.out.print ("IS2 Item envx1 changed to: "); //$ System.out.print (envx1.getSelectedIndex () + " "); //$ System.out.println (envx1.getSelectedItem ()); repatch (); } } else if (target == envy1) { if (event.getStateChange () == ItemEvent.SELECTED){ //$ System.out.print ("IS3 Item envy1 changed to: "); //$ System.out.print (envy1.getSelectedIndex () + " "); //$ System.out.println (envy1.getSelectedItem ()); repatch (); } } else if (target == envx2) { if (event.getStateChange () == ItemEvent.SELECTED){ //$ System.out.print ("IS4 Item envx2 changed to: "); //$ System.out.print (envx2.getSelectedIndex () + " "); //$ System.out.println (envx2.getSelectedItem ()); repatch (); } } else if (target == envy2) { if (event.getStateChange () == ItemEvent.SELECTED){ //$ System.out.print ("IS5 Item envy2 changed to: "); //$ System.out.print (envy2.getSelectedIndex () + " "); //$ System.out.println (envy2.getSelectedItem ()); repatch (); } } else { } // if } // itemStateChanged () //File Pass 6...(List Selection Listener) //File Pass 7...(Adjustment Listener) //File Pass 8...(Change Listener) // Change Listener interface method public void stateChanged (ChangeEvent event) { Object target = event.getSource (); if (target == x1time0) { //$ System.out.print ("CHN1 Slider x1time0 changed to "); //$ System.out.println (x1time0.getValue () + " " + x1time0.getValueIsAdjusting ()); adjusted (x1time0, x1time1, "0.00", 100); } else if (target == x1centre0) { //$ System.out.print ("CHN2 Slider x1centre0 changed to "); //$ System.out.println (x1centre0.getValue () + " " + x1centre0.getValueIsAdjusting ()); adjusted (x1centre0, x1centre1, "0", 1); } else if (target == x1amp0) { //$ System.out.print ("CHN3 Slider x1amp0 changed to "); //$ System.out.println (x1amp0.getValue () + " " + x1amp0.getValueIsAdjusting ()); adjusted (x1amp0, x1amp1, "0", 1); } else if (target == x1frhz0) { //$ System.out.print ("CHN4 Slider x1frhz0 changed to "); //$ System.out.println (x1frhz0.getValue () + " " + x1frhz0.getValueIsAdjusting ()); adjusted (x1frhz0, x1frhz1, "0.0", 10); } else if (target == x1frin0) { //$ System.out.print ("CHN5 Slider x1frin0 changed to "); //$ System.out.println (x1frin0.getValue () + " " + x1frin0.getValueIsAdjusting ()); adjustedPair (x1frin0, x1frfr0, x1fratio1); } else if (target == x1frfr0) { //$ System.out.print ("CHN6 Slider x1frfr0 changed to "); //$ System.out.println (x1frfr0.getValue () + " " + x1frfr0.getValueIsAdjusting ()); adjustedPair (x1frin0, x1frfr0, x1fratio1); } else if (target == x1phase0) { //$ System.out.print ("CHN7 Slider x1phase0 changed to "); //$ System.out.println (x1phase0.getValue () + " " + x1phase0.getValueIsAdjusting ()); adjusted (x1phase0, x1phase1, "0", 1); } else if (target == y1time0) { //$ System.out.print ("CHN8 Slider y1time0 changed to "); //$ System.out.println (y1time0.getValue () + " " + y1time0.getValueIsAdjusting ()); adjusted (y1time0, y1time1, "0.00", 100); } else if (target == y1centre0) { //$ System.out.print ("CHN9 Slider y1centre0 changed to "); //$ System.out.println (y1centre0.getValue () + " " + y1centre0.getValueIsAdjusting ()); adjusted (y1centre0, y1centre1, "0", 1); } else if (target == y1amp0) { //$ System.out.print ("CHN10 Slider y1amp0 changed to "); //$ System.out.println (y1amp0.getValue () + " " + y1amp0.getValueIsAdjusting ()); adjusted (y1amp0, y1amp1, "0", 1); } else if (target == y1frhz0) { //$ System.out.print ("CHN11 Slider y1frhz0 changed to "); //$ System.out.println (y1frhz0.getValue () + " " + y1frhz0.getValueIsAdjusting ()); adjusted (y1frhz0, y1frhz1, "0.0", 10); } else if (target == y1frin0) { //$ System.out.print ("CHN12 Slider y1frin0 changed to "); //$ System.out.println (y1frin0.getValue () + " " + y1frin0.getValueIsAdjusting ()); adjustedPair (y1frin0, y1frfr0, y1fratio1); } else if (target == y1frfr0) { //$ System.out.print ("CHN13 Slider y1frfr0 changed to "); //$ System.out.println (y1frfr0.getValue () + " " + y1frfr0.getValueIsAdjusting ()); adjustedPair (y1frin0, y1frfr0, y1fratio1); } else if (target == y1phase0) { //$ System.out.print ("CHN14 Slider y1phase0 changed to "); //$ System.out.println (y1phase0.getValue () + " " + y1phase0.getValueIsAdjusting ()); adjusted (y1phase0, y1phase1, "0", 1); } else if (target == x2time0) { //$ System.out.print ("CHN15 Slider x2time0 changed to "); //$ System.out.println (x2time0.getValue () + " " + x2time0.getValueIsAdjusting ()); adjusted (x2time0, x2time1, "0.00", 100); } else if (target == x2centre0) { //$ System.out.print ("CHN16 Slider x2centre0 changed to "); //$ System.out.println (x2centre0.getValue () + " " + x2centre0.getValueIsAdjusting ()); adjusted (x2centre0, x2centre1, "0", 1); } else if (target == x2amp0) { //$ System.out.print ("CHN17 Slider x2amp0 changed to "); //$ System.out.println (x2amp0.getValue () + " " + x2amp0.getValueIsAdjusting ()); adjusted (x2amp0, x2amp1, "0", 1); } else if (target == x2frhz0) { //$ System.out.print ("CHN18 Slider x2frhz0 changed to "); //$ System.out.println (x2frhz0.getValue () + " " + x2frhz0.getValueIsAdjusting ()); adjusted (x2frhz0, x2frhz1, "0.0", 10); } else if (target == x2frin0) { //$ System.out.print ("CHN19 Slider x2frin0 changed to "); //$ System.out.println (x2frin0.getValue () + " " + x2frin0.getValueIsAdjusting ()); adjustedPair (x2frin0, x2frfr0, x2fratio1); } else if (target == x2frfr0) { //$ System.out.print ("CHN20 Slider x2frfr0 changed to "); //$ System.out.println (x2frfr0.getValue () + " " + x2frfr0.getValueIsAdjusting ()); adjustedPair (x2frin0, x2frfr0, x2fratio1); } else if (target == x2phase0) { //$ System.out.print ("CHN21 Slider x2phase0 changed to "); //$ System.out.println (x2phase0.getValue () + " " + x2phase0.getValueIsAdjusting ()); adjusted (x2phase0, x2phase1, "0", 1); } else if (target == y2time0) { //$ System.out.print ("CHN22 Slider y2time0 changed to "); //$ System.out.println (y2time0.getValue () + " " + y2time0.getValueIsAdjusting ()); adjusted (y2time0, y2time1, "0.00", 100); } else if (target == y2centre0) { //$ System.out.print ("CHN23 Slider y2centre0 changed to "); //$ System.out.println (y2centre0.getValue () + " " + y2centre0.getValueIsAdjusting ()); adjusted (y2centre0, y2centre1, "0", 1); } else if (target == y2amp0) { //$ System.out.print ("CHN24 Slider y2amp0 changed to "); //$ System.out.println (y2amp0.getValue () + " " + y2amp0.getValueIsAdjusting ()); adjusted (y2amp0, y2amp1, "0", 1); } else if (target == y2frhz0) { //$ System.out.print ("CHN25 Slider y2frhz0 changed to "); //$ System.out.println (y2frhz0.getValue () + " " + y2frhz0.getValueIsAdjusting ()); adjusted (y2frhz0, y2frhz1, "0.0", 10); } else if (target == y2frin0) { //$ System.out.print ("CHN26 Slider y2frin0 changed to "); //$ System.out.println (y2frin0.getValue () + " " + y2frin0.getValueIsAdjusting ()); adjustedPair (y2frin0, y2frfr0, y2fratio1); } else if (target == y2frfr0) { //$ System.out.print ("CHN27 Slider y2frfr0 changed to "); //$ System.out.println (y2frfr0.getValue () + " " + y2frfr0.getValueIsAdjusting ()); adjustedPair (y2frin0, y2frfr0, y2fratio1); } else if (target == y2phase0) { //$ System.out.print ("CHN28 Slider y2phase0 changed to "); //$ System.out.println (y2phase0.getValue () + " " + y2phase0.getValueIsAdjusting ()); adjusted (y2phase0, y2phase1, "0", 1); } else if (target == attack0) { //$ System.out.print ("CHN29 Slider attack0 changed to "); //$ System.out.println (attack0.getValue () + " " + attack0.getValueIsAdjusting ()); adjusted (attack0, attack1, "0.00", 100); } else if (target == decay0) { //$ System.out.print ("CHN30 Slider decay0 changed to "); //$ System.out.println (decay0.getValue () + " " + decay0.getValueIsAdjusting ()); adjusted (decay0, decay1, "0.00", 100); } else if (target == sustain0) { //$ System.out.print ("CHN31 Slider sustain0 changed to "); //$ System.out.println (sustain0.getValue () + " " + sustain0.getValueIsAdjusting ()); adjusted (sustain0, sustain1, "00", 1); } else if (target == release0) { //$ System.out.print ("CHN32 Slider release0 changed to "); //$ System.out.println (release0.getValue () + " " + release0.getValueIsAdjusting ()); adjusted (release0, release1, "0.00", 100); } else { } // if } // stateChanged () /** This method is called each time a slider is adjusted. It updates the associated text field and optionally calls the repatch method. */ private void adjusted (JSlider slider, JTextField textField, String format, int divider) { // Format the slider position and update the text field DecimalFormat df = new DecimalFormat (format); int sliderPosition = slider.getValue (); double value = (double)sliderPosition / (double) divider; String display = " " + df.format (value); textField.setText (display); // Possibly change the synthesizer patch if (!slider.getValueIsAdjusting () && !adjustingGui) { repatch (); } // if } // adjusted () /** This method is called each time a pair (integer + fraction) slider is adjusted. It updates the associated text field and optionally calls the repatch method. */ private void adjustedPair (JSlider sliderInt, JSlider sliderFrac, JTextField textField) { // Format the slider positions and update the text field DecimalFormat df = new DecimalFormat (" 0.00"); int intPosition = sliderInt.getValue (); int fracPosition = sliderFrac.getValue (); double value = (double) intPosition + (double) fracPosition / 100.0; String display = df.format (value); textField.setText (display); // Repatch the synthesizer when all adjustment is finished if ( !sliderInt.getValueIsAdjusting () && !sliderFrac.getValueIsAdjusting () && !adjustingGui) { repatch (); } // if } // adjusted () // ***** Extra goodies to support the various button options ***** /** Define parameters to be extracted from the gui */ BezierParams p; /** Define the command list of midi commands */ CommandList commandList; /** Define the midi input device */ MidiInputBase midiInputDevice; /** Global adjustment flag when adjusting the gui */ boolean adjustingGui = true; /** Preset voices */ final PresetItem [] vanillaSine = { }; final PresetItem [] flute = { new PresetItem (y1amp0, 40), new PresetItem (y1frhz0, 15), new PresetItem (x2amp0, 50), new PresetItem (x2frfr0, 73), new PresetItem (x2time0, 20), new PresetItem (envx2, 3), new PresetItem (attack0, 20), }; final PresetItem [] tinCan = { new PresetItem (y1amp0, 40), new PresetItem (y1frhz0, 15), new PresetItem (x2amp0, 50), new PresetItem (x2frin0, 3), new PresetItem (x2frfr0, 73), new PresetItem (x2time0, 20), new PresetItem (envx2, 3), new PresetItem (attack0, 0), new PresetItem (decay0, 20), new PresetItem (sustain0, 10), }; final PresetItem [] harpsichord = { new PresetItem (x1amp0, 100), new PresetItem (x1frin0, 6), new PresetItem (attack0, 0), new PresetItem (decay0, 100), }; final PresetItem [] trombone = { new PresetItem (x1amp0, 100), new PresetItem (x1frin0, 6), new PresetItem (x1time0, 50), new PresetItem (envx1, 1), new PresetItem (attack0, 0), new PresetItem (decay0, 100), }; final PresetItem [] cloisterBells = { new PresetItem (x1centre0, 80), new PresetItem (x1amp0, 30), new PresetItem (x1frin0, 1), new PresetItem (x1frfr0, 46), new PresetItem (x1time0, 50), new PresetItem (envx1, 0), new PresetItem (y1centre0, 50), new PresetItem (y1amp0, 100), new PresetItem (y1frfr0, 25), new PresetItem (x2centre0, 50), new PresetItem (x2amp0, 15), new PresetItem (x2frin0, 0), new PresetItem (x2frfr0, 60), new PresetItem (x2time0, 0), new PresetItem (envx2, 0), new PresetItem (attack0, 0), new PresetItem (decay0, 300), new PresetItem (sustain0, 80), new PresetItem (release0, 500) }; final PresetItem [] menacingBells = { new PresetItem (x1centre0, 80), new PresetItem (x1amp0, 30), new PresetItem (x1frin0, 6), new PresetItem (x1frfr0, 46), new PresetItem (x1time0, 50), new PresetItem (envx1, 1), new PresetItem (x2centre0, 50), new PresetItem (x2amp0, 15), new PresetItem (x2frin0, 0), new PresetItem (x2frfr0, 60), new PresetItem (x2time0, 0), new PresetItem (envx2, 0), new PresetItem (attack0, 0), new PresetItem (decay0, 300), new PresetItem (sustain0, 60), new PresetItem (release0, 500) }; static final String [] presetsChoices = { "Vanilla Sine", "Flute", "Tin Can", "Harpsichord", "Trombone", "Cloister Bells", "Menacing Bells" }; final PresetItem [][] presetSettings = { vanillaSine, flute, tinCan, harpsichord, trombone, cloisterBells, menacingBells }; /** * Frinika specific startup * Method to copy data to the frame once it has started running. This is used because main () only exists in a static context. @author Bob Lang @author Peter Salomonsen */ public void frinikaStartUp (FrinikaBezierSynth player) { this.player = player; // Set the sliders to their starting positions resetSliders (); // Extract the sample and output rates p = new BezierParamsV3_5 (); p.setSampleRate(player.getAudioOutput().getSampleRate()); p.setOutputRate(p.getSampleRate()); //p.bufferLength = b.dgBufferLength; // Create the command list commandList = new CommandList (); // Register the patch repatch (); } // startUp () /** Extract a single numeric parameter from the gui, and perform a range check */ private int getInt (JTextField f, int min, int max) { // Extract the value from the text field int value = Convert.stringToInt (f.getText (), 0); // Perform minimum range check if (value < min) { // Replace by minimum value and update the field value = min; f.setText (Convert.intToString (value, 5)); } // if // Perform maximum range check else if (value > max) { value = max; f.setText (Convert.intToString (value, 5)); } // if // Return the result return value; } // getInt /** Extract a single numeric parameter from the gui, and perform a range check and scale it by a scaling factor */ private int getScaledInt (JTextField f, double min, double max, double scaleFactor) { // Extract the value from the text field double value = Convert.stringToDouble (f.getText (), 0.0); // Perform minimum range check if (value < min) { // Replace by minimum value and update the field value = min; f.setText (Convert.doubleToString (value, 7, 2)); } // if // Perform maximum range check else if (value > max) { value = max; f.setText (Convert.doubleToString (value, 7, 2)); } // if // Perform the rescaling int result = (int) (value * scaleFactor); // Return the result return result; } // getInt /** Extract a single double parameter from the gui and perform range check */ private double getDouble (JTextField f, double min, double max) { // Extract the value from the text field double value = Convert.stringToDouble (f.getText (), 0.0); // Perform minimum range check if (value < min) { // Replace by minimum value and update the field value = min; f.setText (Convert.doubleToString (value, 7, 2)); } // if // Perform maximum range check else if (value > max) { // Replace by maximum value and update the field value = max; f.setText (Convert.doubleToString (value, 7, 2)); } // if // Return the result return value; } // getDouble /** Find whether particular combo box option is selected */ private boolean isComboValue (JComboBox box, int targetIndex) { return box.getSelectedIndex () == targetIndex; } // isComboValue () /** Extract parameter values from the gui */ private void extractParams () { // Prevent further adjustment startAdjustment (); // Convert amplitude envelope times from seconds to milliseconds p.setUpperXEnvTime(getScaledInt (x1time1, 0.0, 5.0, 1000.0)); p.setUpperYEnvTime(getScaledInt (y1time1, 0.0, 5.0, 1000.0)); p.setLowerXEnvTime(getScaledInt (x2time1, 0.0, 5.0, 1000.0)); p.setLowerYEnvTime(getScaledInt (y2time1, 0.0, 5.0, 1000.0)); // X Centre positions are stored as a percentage of the wave width // Y Centre positions are stored as a percentage of the max wave height p.setUpperCentreX(getInt (x1centre1, 0, 100)); p.setUpperCentreY(getInt (y1centre1, 0, 100)); p.setLowerCentreX(getInt (x2centre1, 0, 100)); p.setLowerCentreY(-getInt (y2centre1, 0, 100)); // Always -ve // Modulation amplitudes are stores using the same units as X/Y positions p.setUpperAmplX(getInt (x1amp1, 0, 100)); p.setUpperAmplY(getInt (y1amp1, 0, 100)); p.setLowerAmplX(getInt (x2amp1, 0, 100)); p.setLowerAmplY(getInt (y2amp1, 0, 100)); // Absolute frequency component in Hz p.setUpperAbsFreqX(getDouble (x1frhz1, 0.0, 20.0)); p.setUpperAbsFreqY(getDouble (y1frhz1, 0.0, 20.0)); p.setLowerAbsFreqX(getDouble (x2frhz1, 0.0, 20.0)); p.setLowerAbsFreqY(getDouble (y2frhz1, 0.0, 20.0)); // Relative frequency component as fraction of fundamental p.setUpperRelFreqX(getDouble (x1fratio1, 0.0, 50.0)); p.setUpperRelFreqY(getDouble (y1fratio1, 0.0, 50.0)); p.setLowerRelFreqX(getDouble (x2fratio1, 0.0, 50.0)); p.setLowerRelFreqY(getDouble (y2fratio1, 0.0, 50.0)); // Starting phase for frequency components - all in degrees p.setUpperPhaseX(getInt (x1phase1, 0, 360)); p.setUpperPhaseY(getInt (y1phase1, 0, 360)); p.setLowerPhaseX(getInt (x2phase1, 0, 360)); p.setLowerPhaseY(getInt (y2phase1, 0, 360)); // Envelope shaper parameters - most parameters in millisecs p.setEnvAttackTime(getScaledInt (attack1, 0.0, 5.0, 1000.0)); p.setEnvDecayTime(getScaledInt (decay1, 0.0, 5.0, 1000.0)); p.setEnvSusLevel(getInt (sustain1, 0, 100)); p.setEnvReleaseTime(getScaledInt (release1, 0.0, 5.0, 1000.0)); // Boolean values from the combo boxes p.setUpperEnvX(envx1.getSelectedIndex ()); p.setUpperEnvY(envy1.getSelectedIndex ()); p.setLowerEnvX(envx2.getSelectedIndex ()); p.setLowerEnvY(envy2.getSelectedIndex ()); // All done adjustingGui = false; } // extractParams () /** Set up a preset voice */ private void changePreset (PresetItem [] list) { resetSliders (); startAdjustment (); for (int i=0; i<list.length; i++) { list [i].set (); } // for endAdjustment (); repatch (); } // changePreset () /** Reset all the fields in the gui to initial values */ private void resetSliders () { //$ System.out.println ("Reset Sliders"); // Mark the gui as being adjusted startAdjustment (); // Define arrays to simplify later processing JSlider [] sliders = {x1time0, x1centre0, x1amp0, x1frhz0, x1frin0, x1frfr0, x1phase0, y1time0, y1centre0, y1amp0, y1frhz0, y1frin0, y1frfr0, y1phase0, x2time0, x2centre0, x2amp0, x2frhz0, x2frin0, x2frfr0, x2phase0, y2time0, y2centre0, y2amp0, y2frhz0, y2frin0, y2frfr0, y2phase0, attack0, decay0, sustain0, release0}; // Set all the sliders to zero for (int i = 0; i < sliders.length; i++) { sliders [i].setValue (1); sliders [i].setValue (0); } // for // Special cases x1centre0.setValue (50); x2centre0.setValue (50); y1centre0.setValue (100); y2centre0.setValue (100); attack0.setValue (50); decay0.setValue (100); sustain0.setValue (80); release0.setValue (200); // Reset the envelopes envx1.setSelectedIndex (0); envy1.setSelectedIndex (0); envx2.setSelectedIndex (0); envy2.setSelectedIndex (0); // Finished adjusting the gui endAdjustment (); } // resetSliders () private void startAdjustment () { adjustingGui = true; } // startAdjustment () private void endAdjustment () { // Allow time for other threads to update the gui try {Thread.sleep (500);} catch (Exception e) {} adjustingGui = false; } // endAdjustment () /** Create a new patch/program for the synthesizer */ private void repatch () { //$ System.out.println ("Repatch called"); if (!adjustingGui) { //$ System.out.println ("Repatch activating..."); extractParams (); player.changePatch (p); } // if } // repatch () /** Plot graphical information */ private void plotButton () { repatch (); BezierSynth sLow = new BezierSynth (0, p); BezierSynth s = new BezierSynth (1, p); // Calculate the current undersampling rate int underSampling = (int) p.getSampleRate()/(int) p.getOutputRate(); int [] samples = new int [2048]; int [] samplesLow = new int [2048]; int sample = 0; for (int i=0; i<2048; i++) { samples [i] = s.getSample (sample); samplesLow [i] = sLow.getSample (sample); sample+=4; } // for WaveSupport.plotGraph (1, "Bezier Synthesis", "Generated output", "time", "value", samples, 500); WaveSupport.addGraph (1, Graph.BLUE, samplesLow, 500); double [] fourier = new double [2048]; Fourier.frequencyFft (2048, samples, fourier); WaveSupport.plotFourier (2, fourier, 2048, p.getOutputRate(), 512); } // plotButton () /** Quit button exits the program */ private void quitButton () { System.exit (0); } // quitButton () } // Frame BezierWaves