JS Audio - audioBuffer getChannelData to frequency

烈酒焚心 提交于 2019-12-23 05:23:21

问题


bsd

I am trying achieve pitch detection, and moreover learn some basic audio physics on the way, I am actually really new to this and just trying to understand how this whole thing works...

My question is, What is exactly the audioBuffer and how is the data coming from getChannelData related to frequencies. and how can I extract frequency data from the audioBuffer...

Also, if someone can explain just a bit about sample rates etc. also this would be great.

Thanks!


回答1:


An AudioBuffer simply represents an audio resource, namely audio samples and additional information about the audio.

For instance, you can access the sampleRate property of an AudioBuffer object to know about the sampling frequency of the audio contained in the AudioBuffer.

Using getChannelData will return you an array of audio samples. At every interval given by the sampling rate, you have a number (comprised between -1.0 and +1.0 for IEEE 32 float audio samples) corresponding to the audio amplitude of the sample. Thus, this array of samples contain time-domain audio information.

To do pitch detection, you need to work in the frequency domain and to go from the time domain to the frequency domain, you need to use the Fourier transform. If you want to understand underlying DSP (digital signal processing) principles, you can use a pure FFT library (for instance, node-fft). If you just want to achieve a pitch detection, using a turnkey solution such as pitch.js will be easier.



来源:https://stackoverflow.com/questions/45397325/js-audio-audiobuffer-getchanneldata-to-frequency

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