something wrong with this sketch ? please need direction .. (p5 oscillator)

I tried to play with audio and tried to form object with a oscillator as one of its property ,did mange get some sounds ,but does stop making noises after a while (same count every time ).I am pretty sure i got something wrong but cant figure out here is script ..would be nice if u cud point me in the rite direction.thanks

var canvas; var counter=0; var boby=0 ; var obj1 = 0; var obj2 = 1; var obj3 = 2; var changesize=0; var attackLevel = 1.0; var releaseLevel = 0; var attackTime = 0.001 var decayTime = 0.1; var susPercent = 0.2; var releaseTime = 0.5; var env, Osc; var state; var start; function setup(){ masterVolume(0.06); canvas= createCanvas(displayWidth/2,displayHeight/2); noStroke(); noLoop(); canvas.mousePressed(theplanes);

}

function theplanes(){

ourtimer(300,70,2,800,500);

}

function sound(freq){ env = new p5.Env(); env.setADSR(attackTime, decayTime); env.setRange(attackLevel, releaseLevel); Osc = new p5.Oscillator('sawtooth'); Osc.amp(env); Osc.start(); Osc.freq(freq); env.play(); }

function ourtimer(xloc,yloc,count,freq,wait){

setInterval(plane1,wait,xloc,yloc,count,freq);

function plane1(xloc,yloc,count,freq){

sound(freq); var size= (map(sin(changesize),-1,1,0,60));

colorvalues=255/count; steps=size/count;

for (i = 0; i < count; i++) { fill(icolorvalues); stroke(0); strokeWeight(1); rectMode(CENTER); rect(xloc, yloc, size - isteps, size - i*steps);

} changesize++;

}

} function draw(){ background(100);

}

Sign In or Register to comment.