Hi, I'm extremely new to DSP, I just read about the FFT for the first time a couple of days ago. :) I wanted to construct a program will add filter effects to a WAV file. No, I'm not interested in a freeware/shareware program, I want to learn how to do this. I found that I would need a FFT and so, I decided to try FFTW. I'm very new to this program, as you can imagine, and I'm trying to wrap my head around how I would input the WAV, so that I can get the FFT of the signals and then modify the output and then do an IFFT to turn it back into WAV format. Can anyone explicitly answer how I would do something like this using FFTW? i.e. What do I pass as the array? (Each sample for each frequency (20Hz - 20kHz)?) Thanks, Ben

# Using FFTW to do analysis of a WAV file

Started by ●January 23, 2008

Reply by ●January 23, 20082008-01-23

On Jan 23, 7:41 pm, "motleyruse" <motleyr...@yahoo.com> wrote:> Hi, > > I'm extremely new to DSP, I just read about the FFT for the first time a > couple of days ago. :) I wanted to construct a program will add filter > effects to a WAV file. No, I'm not interested in a freeware/shareware > program, I want to learn how to do this. I found that I would need a FFT > and so, I decided to try FFTW. > > I'm very new to this program, as you can imagine, and I'm trying to wrap > my head around how I would input the WAV, so that I can get the FFT of the > signals and then modify the output and then do an IFFT to turn it back into > WAV format. > > Can anyone explicitly answer how I would do something like this using > FFTW? > i.e. What do I pass as the array? (Each sample for each frequency (20Hz - > 20kHz)?) > > Thanks, > BenFor getting familiar with DSP and the FFT, I wouldn't recommend using FFTW, or any other C/C++/Fortran/etc. based framework. An environment like MATLAB (or GNU Octave for a free alternative) provides you the ability to play around and explore concepts without having to worry about issues like memory allocation, array ordering, etc. You also often find functions to do things for you like read in WAV files, images, etc. and get at the data without having to worry about the details of the file format. It's easy to prototype an algorithm using a framework like MATLAB and then implement it later in a native language for improved speed. In the latter case, FFTW is a great example of a high-performance, free, easy-to-use (once you get used to it) FFT library. I've not seen anything faster, except for Intel's Math Kernel Library on an x86 processor. But hey, the price is right. To answer your question directly, if you're looking to add "filter effects" to a WAV file, then I will assume you mean running the audio signal through a linear filter. To do this, you can read in the file (Google for the WAV format header) and get the raw samples into an array. You then need to convolve the time-domain signal with the impulse response of your filter. You can either do this by computing the discrete-time convolution sum directly, or via FFT-based fast convolution techniques. To avoid having to do really long FFTs (which you would have to do if you took a single FFT of an entire audio signal), fast convolution is typically done on a block-oriented basis, with a reasonable FFT size of 1024, 8192, etc. based upon the processing/memory you have available. To do one-dimensional FFTs with FFTW, you use fftw_plan() to set up a plan for a given FFT size and direction. As the input array, pass the portion of the time-domain signal that you want to transform. The output array will contain its FFT after you fftw_execute() the plan. Jason