I've been trying to get values for the fft using Tone.js. I want to get values of the note that was played using this function
async function playCasio(noteToPlay, duration) {
Tone.start()
// Create an FFT component
const fft = new Tone.FFT(1024)
const casio = new Tone.Sampler({
urls: {
A1: "A1.mp3",
A2: "A2.mp3",
},
baseUrl: "https://tonejs.github.io/audio/casio/",
})
const tones = await Tone.loaded();
// Connect the Casio sampler to the FFT
casio.chain(fft, Tone.Destination)
casio.triggerAttackRelease(noteToPlay, duration);
const fftValues = fft.getValue();
console.log(fftValues);
}
However, when I look at the console log, it says this screenshot of console log
meaning fft is listening for silence (-Infinity db). It does play the right sound, and I can hear it. I could not find the solution. How can I achieve this? I just want some values to display other than -Infinity
I've tried to connect casio to destination, tried to use promise so that it waits till the note is played.