问题
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