xxxxxxxxxx
30
var osc;
var playing = false;
function setup() {
createCanvas(windowWidth,windowHeight);
backgroundColor = color(255,0,255);
textAlign(CENTER);
}
function draw() {
background(255);
if(playing) text("playing",width/2,height/2);
}
function touchStarted() {
osc = new p5.Oscillator();
osc.setType('sine');
osc.freq(240);
osc.amp(0.1);
osc.start();
playing = true;
return false;
}
function touchEnded() {
if(touches.length == 0) {
playing = false;
osc.stop();
}
}