Hello, tell me how to get the frequency from the getFloatFrequencyData method in Web Audio APi? Connected to the output, I get an array of the following form:

[-72.4644546508789, -50.16435241699219, -39.02543640136719, -37.38917541503906, -42.104286193847656, -47.633304595947266, -45.354637145996094, -31.857379913330078, -27.12179946899414, -30.678062438964844, ......] 

It is clear that the method returns float, then floating point numbers. Not all array elements have a nonzero value. In a word, I output an array from getFloatFrequencyData to the console, get an array. Now we need to get the frequency in Hz from this array. Initially it was assumed that the key of the array element is frequency, and the value is loudness in dB, but how can the loudness be negative?

  this.bands = new Float32Array(this.analyser.frequencyBinCount); this.analyser.getFloatFrequencyData(this.bands) console.log(this.bands) 

And at the output of such an array ... Thank you in advance. ps I tried to check the melody of a known frequency (440MHz), did not achieve anything

    1 answer 1

    I don't know about Web Audio Api. But loudness in decibels may well be a negative value, since it is a logarithmic quantity.

    Negative decibels mean only that the current signal level is less than some reading. And, considering that in many cases, the maximum signal level in an audio device is taken as a reading level, any real signal in these cases will have a negative value.

    • those. the smaller the value of the module, the greater the volume? - venanen 5:27 pm
    • Yes, if the maximum possible signal was taken for the reference value (usually this is so). In this case, 0 is the maximum. And each additional -10 designates 10 times smaller signal. Those. -30 is already 10 ^ 3 (ie, 1000) times less than the maximum. - Xander