Web Audio API analyser node getByteFrequencyData returning blank array

ぐ巨炮叔叔 提交于 2019-12-01 05:23:50

问题


I'm trying to access FFT data from the analyser node using analyser.getByteFrequencyData(array) but it seems to return a blank array:

var array = new Uint8Array(analyser.frequencyBinCount);
analyser.getByteFrequencyData(array);

However using analyser.getFloatFrequencyData(array) returns an array of data:

var array = new Float32Array(analyser.frequencyBinCount);
analyser.getFloatFrequencyData(array);

I'm using a signal chain as follows:

Source -> Analyser -> ScriptProcessor -> Context Destination

So why can I not get frequency data in byte form?

Thanks in advance.


回答1:


Without seeing more of your code, my best guess is that you have the minDecibels and maxDecibels set to a range that is over the data you're pumping through the analyser, so it's getting zeroed out.




回答2:


What are the odds that one of you got the data before playback started, so there was nothing to read yet? If that might be the case, try to call getByteFrequencyData after playback is started.




回答3:


Check if smoothingTimeConstant is set to 1. When it is so, getFloatFrequencyData always returns an array of zeroes.



来源:https://stackoverflow.com/questions/14677221/web-audio-api-analyser-node-getbytefrequencydata-returning-blank-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!