import pitaru.sonia_v2_9.*; import com.softsynth.jsyn.*; FileInputStream stream; SineOscillator myBeep; EnvelopePlayer myEnvPlayer; SynthEnvelope myEnv; LineOut myOut; void setup() { size(1000,100); background(120); try { Synth.startEngine(0); println("engine started"); } catch(SynthException e) { SynthAlert.showError(this,e); } myBeep = new SineOscillator() ; myEnvPlayer = new EnvelopePlayer(); myOut = new LineOut(); /* Connect units together. */ myBeep.output.connect( myEnvPlayer.amplitude ); myEnvPlayer.output.connect( myOut.input ); /* Create Envelope to be played. */ double[] data = { 0.10, 1.0, /* duration,value pair for frame[0] */ 0.30, 0.5, 0.80, 0.0 }; myEnv = new SynthEnvelope( data ); myBeep.amplitude.set( 0.5 ); myBeep.frequency.set(440.0); /* Queue envelope to trigger sound. */ myEnvPlayer.envelopePort.clear(); myEnvPlayer.envelopePort.queue( myEnv ); myEnvPlayer.start(); myBeep.start(); myOut.start(); println("fine setup"); } void draw() { } void mouseReleased() { background(120); try { /* Select frequency. */ myBeep.frequency.set(mouseX); /* Queue envelope to trigger sound. */ myEnvPlayer.envelopePort.clear(); myEnvPlayer.envelopePort.queue( myEnv ); } catch (SynthException e) { SynthAlert.showError(this,e); } line(mouseX, 0, mouseX, height); } /* * Clean up synthesis by overriding stop() method. */ public void stop() { try { /* Your cleanup code goes here. */ //removeAll(); // remove components from Applet panel. myBeep.stop(); Synth.stopEngine(); println("engine stopped"); } catch(SynthException e) { //SynthAlert.showError(this,e); } }