EDIT:
Apparently the lowest non-infinity value is -250.
I generated a silent audio file with DarkAudacity and the lowest frequency value I got was -249.21243286132812, which is BASICALLY -250
Oh yeah, the question title might be somewhat wrong, so I guess you should just do this, as an answer to the title's question:
for (let i = 0; i < FrequencyData.length; i++) {
FrequencyData[i] = FrequencyData[i] / 250 + 1;
}
Original Question:
What I want to have: An array of Frequency Data that is easier to work with.
What I need to do to achieve it: Abstract the Frequency Data into Values between 0 and 1. (0 being silent and 1 being "loudest")
The Problem: I don't know what the lowest value is that can be returned by AnalyserNode.getFloatFrequencyData() (However, I assume the highest value is just 0, unless I get told otherwise)
What I have tried:
-Infinity, which doesn't help because I would only get 0 or 1 if I tried to scale that)-236.[lotsOfDecimalsHere], and I dislike to think that the lowest value has decimals)Here is roughly what my second try was:
let lowest = Infinity;
function loop() {
myAnalyserNode.getFloatFrequencyData(myFrequencyData);
if (!myFrequencyData.includes(-Infinity)) {
lowest = Math.min(lowest, ...myFrequencyData);
}
console.log(lowest);
requestAnimationFrame(loop);
}
loop();