xxxxxxxxxx
25
// Variable for Oscillator.
let osc;
// Middle C frequency.
let myFreq = 262;
function setup() {
createCanvas(400,400);
// Create the Oscillator object.
osc = new Oscillator(myFreq);
}
function draw() {
background(220);
}
function mousePressed() {
// Toggle the note that is playing
if(osc.started){
osc.stop();
} else {
osc.start();
}
}