Reputation: 927
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?
Upvotes: 3
Views: 1475
Reputation: 13928
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."
Upvotes: 2