Get a spectrum of frequencies from WAV/RIFF using linux command line

喜欢而已 提交于 2019-12-22 08:46:39

问题


How to generate file including spectrum of frequencies of wav/riff sound file? I would like to use linux command line.

I know the cool sox function to generate png spectrograms

sox sound.wav -n spectrogram

But I do not need visual representation of the spectrum of frequencies. I just want to get spectrum of frequencies in data file so I can work on them. I believe that there must be an option using sox. Sox need to generate that data before plotting it. How to get this?

Not sure, maybe the second solution is exporting wav file into the dat file. Each sample from dat file is a measure of the position of the membrane at a moment in time. So this is not spectrum of frequencies.

sox sound.wav file.dat

How to convert those membrane positions into spectrum i need?

Thanks.


回答1:


What you are looking for is called a Fourier Transform, or Fast Fourier Transform (FFT). The FFT is a mathematical algorithm that transforms time domain samples (i.e. the membrane positions, as you put it, at points in time), which are contained in a .wav file - into frequency components. If you Google FFT, you will find much more information, including source code that you can compile and reuse in Linux. See How do I plot the spectrum of a wav file using FFT? for a good start.




回答2:


You can try the stat option in sox.

play track.wav stat -freq



回答3:


How about

sox sound.wav -n stat -freq >& file.dat


来源:https://stackoverflow.com/questions/21756237/get-a-spectrum-of-frequencies-from-wav-riff-using-linux-command-line

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