xxxxxxxxxx
19
let synth;
function setup() {
createCanvas(400, 400);
background(200);
synth = new Tone.Synth().toDestination();
}
function mouseClicked() {
// Start the audio context with a user interaction
if (Tone.context.state !== 'running') {
Tone.context.resume();
}
// Play a note
synth.triggerAttackRelease('C4', '8n');
}