p5(sketch => {
let mouse = null
sketch.setup = function() {
sketch.createCanvas(width,height);
Tone.Master.volume.value = volume;
};
sketch.draw = function() {
const dim = Math.min(width, height);
const opacity = 0.085;
sketch.background(`#001b42${(~~(opacity * 255)+"").toString(16)}`);
if (mouse) {
sketch.noFill();
sketch.stroke(255);
sketch.strokeWeight(dim * 0.01);
sketch.circle(mouse[0], mouse[1], dim * 0.2);
mouse = null;
}
sketch.noStroke();
sketch.fill(255);
sketch.text('click around to make some sound',20,20)
}
sketch.mousePressed = function () {
mouse = [sketch.mouseX, sketch.mouseY];
const notes = ['F#', 'G#', 'A', 'C#', 'D', 'F#' ]
const octaves = [ 3, 4, 5, 6];
const octave = sketch.random(octaves);
const note = sketch.random(notes);
sketch.text(`octave ${octave} note ${note}`,20,40)
synth.triggerAttackRelease(note + octave, "8n");
}
})