public void init() { synth = JSyn.createSynthesizer(); // Add a tone generator. (band limited sawtooth) synth.add(osc = new SawtoothOscillatorBL()); // Add a lag to smooth out amplitude changes and avoid pops. synth.add(lag = new LinearRamp()); // Add an output mixer. synth.add(lineOut = new LineOut()); // Connect the oscillator to both left and right output. osc.output.connect(0, lineOut.input, 0); osc.output.connect(0, lineOut.input, 1); // Set the minimum, current and maximum values for the port. lag.output.connect(osc.amplitude); lag.input.setup(0.0, 0.5, 1.0); lag.time.set(0.2); // Arrange the faders in a stack. setLayout(new GridLayout(0, 1)); ExponentialRangeModel amplitudeModel = PortModelFactory.createExponentialModel(lag.input); RotaryTextController knob = new RotaryTextController(amplitudeModel, 5); JPanel knobPanel = new JPanel(); knobPanel.add(knob); add(knobPanel); osc.frequency.setup(50.0, 300.0, 10000.0); add(PortControllerFactory.createExponentialPortSlider(osc.frequency)); validate(); }
@Override public void init() { synth = JSyn.createSynthesizer(); // Add a tone generator. synth.add(osc1 = new SineOscillator()); synth.add(osc2 = new SineOscillator()); // Add a lag to smooth out amplitude changes and avoid pops. synth.add(lag = new LinearRamp()); // Add an output mixer. synth.add(lineOut = new LineOut()); // Connect the oscillator to the output. osc1.output.connect(0, lineOut.input, 0); osc2.output.connect(0, lineOut.input, 1); // Arrange the faders in a stack. setLayout(new GridLayout(0, 1)); JPanel infoPanel = new JPanel(); infoPanel.setLayout(new GridLayout(0, 1)); infoPanel.add(new JLabel("About: " + synth, SwingConstants.CENTER)); infoPanel.add(new JLabel("From: http://www.softsynth.com/", SwingConstants.CENTER)); infoPanel.add(new JLabel("(C) 1997-2011 Mobileer Inc", SwingConstants.CENTER)); add(infoPanel); // Set the minimum, current and maximum values for the port. lag.output.connect(osc1.amplitude); lag.output.connect(osc2.amplitude); lag.input.setup(0.001, 0.5, 1.0); lag.time.set(0.1); lag.input.setName("Amplitude"); add(PortControllerFactory.createExponentialPortSlider(lag.input)); osc1.frequency.setup(50.0, 300.0, 3000.0); osc1.frequency.setName("Frequency (Left)"); add(PortControllerFactory.createExponentialPortSlider(osc1.frequency)); osc2.frequency.setup(50.0, 302.0, 3000.0); osc2.frequency.setName("Frequency (Right)"); add(PortControllerFactory.createExponentialPortSlider(osc2.frequency)); validate(); }