gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 03:30:49 25 4
gpt4 key购买 nike

我想从麦克风获取输入并将其传递到分析器节点以提取频率数据。我探索了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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com