xxxxxxxxxx
var osc;
var types = ['sine', 'triangle', 'square', 'sawtooth'];
var t = 0;
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
osc = new p5.Oscillator();
osc.start();
}
function draw() {
ellipse(mouseX, mouseY, 20, 20);
var f = mouseX/width*1000.;
var a = mouseY/height;
osc.freq(f);
osc.amp(a);
}
function keyTyped() {
t = (t+1)%types.length;
osc.setType(types[t]);
}