diff --git a/src/sketch.js b/src/sketch.js index 696348e..ded06ee 100644 --- a/src/sketch.js +++ b/src/sketch.js @@ -15,8 +15,11 @@ function setup() { createCanvas(windowWidth, windowHeight); fft = new p5.FFT(); mic = new p5.AudioIn(); - mic.start() - mic.connect(fft); + + // Create a button and attach an event listener + let startButton = createButton('Start Audio'); + startButton.position(10, 10); + startButton.mousePressed(startAudio); textAlign(CENTER); @@ -107,6 +110,11 @@ function setup() { } +function startAudio() { + mic.start(); + mic.connect(fft); +} + function draw() { background(0);