So I’m recently starting out with p5.sound.js to make an audio visualizer. However, I find myself stuck at the very first step and I would really appreciate any help.
Errors:
The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page.
Access to XMLHttpRequest at ‘file:///Users/theonlyroy/Desktop/Repositories/audio-visualizer/tb.mp3’ from origin ‘null’ has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
Here’s the code snippet:
var song;
var fft;
function preload() {
song = loadSound('tb.mp3');
}
function touchStarted() {
getAudioContext().resume()
}
function setup() {
createCanvas(256, 256);
colorMode(HSB);
angleMode(DEGREES);
song.play();
fft = new p5.FFT(0.9, 128);
}
I still don’t understand why the errors persist.