How to extract frequency out of WAV sample data?

杀马特。学长 韩版系。学妹 提交于 2019-12-03 06:25:42

问题


I'm developing an application in c to read simple PCM WAV files. My question is, how should I interpret the samples from the data chunk, so that I can extract the sample's frequency?

Given a WAV example, how can the original data represent frequencies. E.g. this data chunk, 24 17 1e f3, for stereo, 16 bits, the left channel sample is, 0x1724 = 5924d, means 5924Hz ? How can that be, for samples that are signed or frequencies that humans can´t hear?


回答1:


Your assumption is incorrect. The sample data is simply a digital representation of the actual sound wave. The numbers represent wave amplitude, the array offset represents time.

I would suggest reading about How Audio is Represented, specifically PCM.

To convert this data (amplitude-vs-time) to frequency data, you need to understand the basic concepts of The Fourier Transform

I really suggest taking the time to read these before trying to do any audio processing.




回答2:


You can extract the sample rate in the WAV header, but if you need the actual frequency data of the audio that was recorded, i.e. how much energy at 200Hz, how much at 2kHz, how much at 8kHz, etc. you need to do an FFT, or run it through a spectrogram.



来源:https://stackoverflow.com/questions/8154084/how-to-extract-frequency-out-of-wav-sample-data

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