I’m working on a project and i have my audio files being put into an audio object in order for it to be played and created but when I try to analyze the frequency using FFT it doesn’t pick anything up here’s the code for the sketch and object. I’m wondering if there’s any way I can pick up the frequency from this audio object.
//Sketch
"use strict"; //catch some common coding errors
let audios = [];
let menus;
let l
let fft;
let test
let song;
/**
* setup :
*/
function preload()
{
song = loadSound("abba.mp3")
l = new audio("abba.mp3");
}
function setup() {
createCanvas(500, 500);
fft = new p5.FFT(0,16);
audios.push(l)
//song.play();
}
/**
* draw :
*/
function draw() {
l.testing()
}
function keyPressed()
{
for(audio of audios){
audio.switch()
}
}
class audio{
constructor(file,x,y){
this.file = createAudio(file);
this.x = x;
this.y = y;
this.pauses=true
//this.sel = createSelect();
this.ffst = new p5.FFT(0,16);
this.testt;
}
player(){
//this.sel.position(10,10)
//this.sel.option('pear');
this.file.loop();
}
switch()
{
this.pauses = !this.pauses
if (this.pauses)
{
this.file.stop()
}
else{
this.file.play()
}
console.log(this.pauses)
}
testing()
{ this.file.play()
this.testt = this.ffst.analyze(16);
console.log(this.testt)
}
}