Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFT values of webaudio's AnalyserNode are outside range

I'm trying to use Web-Audio's Analyser Node and keep getting weird results from it.

The code:

var self = this;
var bufferSize = 512;
var spectrum = new Float32Array(bufferSize/2);

self.analyser = audioContext.createAnalyser();
self.analyser.fftSize = bufferSize;
self.analyser.smoothingTimeConstant = 0;
self.analyser.minDecibels = -120;
self.analyser.maxDecibels = 0;
self.analyser.getFloatFrequencyData(spectrum);
source.connect(self.analyser);

Even though I explicitly set the values of the max and min decibels, I still get values that are less than -120, for example, -180.

Also, when I console.log the analyser, I see that the values did in fact change, but the FFT still gives me lower values than expected.

I'm using a stereo mp3 file to test it, could this be an issue?

Any ideas?

like image 211
nevos Avatar asked Jan 25 '26 18:01

nevos


1 Answers

Min and max decibels only affect the getByteFrequencyData values, not the getFloatFrequencyData values. "The minimum/maximum power value in the scaling range for the FFT analysis data for conversion to unsigned byte values."

like image 147
cwilso Avatar answered Jan 28 '26 07:01

cwilso



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!