package jmsltutorial; import com.softsynth.jsyn.*; /************** ** WARNING - this code automatically generated by Wire. ** The real source is probably a Wire patch. ** Do NOT edit this file unless you copy it to another directory and change the name. ** Otherwise it is likely to get clobbered the next time you ** export Java source code from Wire. ** ** Wire is available from: http://www.softsynth.com/wire/ */ public class TutSquare extends SynthNote { // Declare units and ports. SquareOscillatorBL sqrOscBl; SynthEnvelope envelope; EnvelopePlayer envPlay; public SynthInput rate; public TutSquare() { this( Synth.getSharedContext() ); } public TutSquare( SynthContext synthContext ) { super( synthContext ); // Create unit generators. add( sqrOscBl = new SquareOscillatorBL(synthContext) ); double[] envelopeData = { 0.1, 1.0, 0.5, 0.2, 0.5, 0.0, }; envelope = new SynthEnvelope( synthContext, envelopeData ); envelopeData = null; envelope.setSustainLoop( 2, 2 ); envelope.setReleaseLoop( -1, -1 ); add( envPlay = new EnvelopePlayer(synthContext) ); // Connect units and ports. addPort( frequency = sqrOscBl.frequency, "frequency" ); frequency.setup( 0.0, 329.62850374278463, 3000.0 ); addPort( amplitude = envPlay.amplitude, "amplitude" ); amplitude.setup( 0.0, 0.5, 1.0 ); addPort( output = sqrOscBl.output, "output" ); sqrOscBl.phase.set( 0, 0.05247562751173973 ); envPlay.output.connect( sqrOscBl.amplitude); addPort( rate = envPlay.rate, "rate" ); rate.setup( 0.0, 1.0, 2.0 ); } public void setStage( int time, int stage ) { switch( stage ) { case 0: envPlay.envelopePort.clear( time ); envPlay.envelopePort.queueOn( time, envelope ); start( time ); break; case 1: envPlay.envelopePort.queueOff( time, envelope, true ); break; default: break; } } }