How come that function getLevel() doesn't work: Uncaught TypeError: Cannot read properties of undefined (reading 'getLevel')

I started a project in VS code and at the beginning everything was working but now I get the TypeError. How come? Thanks

hi and welcome

can you post your sketch

Hello, here is my code: The problem is in function draw. “let level = amp.getLevel();”. He doesn’t understand the function getLevel() from p5.js. When I’m using the same code in the editor of p5 there is no problem, in Visual Studio Code (live server) there is a problem => TypeError. Thanks

let sound;
let amp;

function preload() {

soundFormats(‘mp3’, ‘ogg’);

sound = loadSound(‘song3.mp3’);

}

function setup() {

let cnv = createCanvas(600,600);

cnv.mouseClicked(togglePlay);

amplitude = new p5.Amplitude();

}

function draw() {

background(‘red’);

let level = amp.getLevel();

let size = map(level, 0, 1, 0, width/1.9);

console.log(size);

if(size<50) {

fill('white');

}else if(size<75) {

fill('green');

background('red');

}else if(size<100) {

fill('yellow');

background('blue');

} else {

fill('blue');

background('yellow');

}

circle(width/2, height/2, size);

}

function togglePlay() {

if (sound.isPlaying() ){

sound.pause();

} else {

sound.loop();

amplitude = new p5.Amplitude();

amplitude.setInput(sound);

}

}

document.getElementById(“knop”).addEventListener(“click”, pauzeSound);

function pauzeSound() {

console.log(“knoop werkt naar behoren”);

let thissound = sound;

thissound.pause();

thissound.currentTime = 0;

}

https://creative-coding.decontextualize.com/synthesizing-analyzing-sound/