javascript - 为什么 getFloatFrequencyData 返回的值为负数?

标签 javascript fft microphone getusermedia web-audio-api

我想从麦克风获取输入并将其传递到分析器节点以提取频率数据。我探索了Web Audio ApiGetUserMedia一段时间,但无法弄清楚为什么控制台中的所有值都是负数。难道不应该有积极的值(value)观吗?这些负值有什么意义?

navigator.mediaDevices.getUserMedia({audio: true, video:false}).then(function(stream){               
              aContext = new AudioContext();
              analyser = aContext.createAnalyser();
              microphone = aContext.createMediaStreamSource(stream);
              microphone.connect(analyser);
              analyser.connect(aContext.destination);
              LoopFunc();
          });                    

     var LoopFunc = function (){
          setInterval(function(){
              frequencyData = new Float32Array(analyser.frequencyBinCount);
              analyser.getFloatFrequencyData(frequencyData);
              console.log(frequencyData);                  
          },100);
      }

最佳答案

来自 the spec

getFloatFrequencyData

Copies the current frequency data into the passed floating-point array. If the array has fewer elements than the frequencyBinCount, the excess elements will be dropped. If the array has more elements than the frequencyBinCount, the excess elements will be ignored.

The frequency data are in dB units.

这就引出了一个问题:What does negative numbers on the decibel scale mean?

关于javascript - 为什么 getFloatFrequencyData 返回的值为负数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44546024/

相关文章:

带有麦克风输入的 Python Librosa

android - 使用麦克风录制数据固定时间

java - Java 中的麦克风级别

javascript - 我想要一个将我链接到对象列表中单击的对象的操作

javascript - 创建新的 PouchDB 抛出 "Adapter is missing"异常

python - 如何找到脉冲的频率?

c# - 使用有限域 FFT 的多项式乘法 - 选择第 n 个原单位根

javascript - 无法在 React 元素 (div) 上调用 e.preventDefault

javascript - 如何判断 HTTP 表单是否已提交?

fortran - Fortran 结果中的 FFTW 仅包含零