JS Audio - audioBuffer getChannelData到频率 [英] JS Audio - audioBuffer getChannelData to frequency
问题描述
bsd
我正在尝试实现音高检测,而且在路上学习一些基本的音频物理,我其实真的很新这只是试着理解这一切是如何工作的......
我的问题是,什么是audioBuffer以及来自getChannelData的数据与频率有什么关系。如何从audioBuffer中提取频率数据......
此外,如果有人可以解释一些关于采样率等的话,这也会很棒。
谢谢!
AudioBuffer
只代表音频资源,即音频样本和有关音频的其他信息。
<例如,您可以访问
AudioBuffer
对象的 sampleRate
属性,以了解 AudioBuffer $ c $中包含的音频的采样频率
c>。 使用 getChannelData
将返回一组音频样本。在采样率给定的每个间隔,您都有一个与样本的音频幅度对应的数字(对于IEEE 32浮点音频采样,介于-1.0和+1.0之间)。因此,此样本数组包含时域音频信息。
要进行音高检测,您需要在频率下工作域以及从时域到频域,您需要使用傅里叶变换。如果您想了解基础DSP(数字信号处理)原理,您可以使用纯FFT库(例如,节点-FFT )。如果您只想使用交钥匙解决方案,例如 pitch.js 会更容易。
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!
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.
这篇关于JS Audio - audioBuffer getChannelData到频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!