xxxxxxxxxx
// remember to add the sound library : p5.sound
var osc; // this is a variable which we will use for an oscillator
function setup() {
createCanvas(windowWidth, windowHeight);
background(255);
osc = new p5.Oscillator(); // make an oscillator
osc.setType('sine'); // options are 'sine', 'sawtooth', 'triangle', 'square'
osc.start(); // start it
}
function draw() {
line(pmouseX, pmouseY, mouseX, mouseY);
ellipse(mouseX, mouseY, 20, 20);
osc.freq(mouseX); // frequency to the X axis (in Hz)
osc.amp(1.0 - mouseY/height); // amplitude to the Y axis
}