Hi all, I'm having a few problems with the basics of IFFT. I have created a frequency repsonse (which is an acoustical model of the response of a room). I want to convolve this with an audio file - thereby making the audio sound like it was played in the room. However, I'm having problems with the IFFT and time domain issues. My frequency response is originally 600 points long, representing 0 to 300Hz (I'm only modelling the low frequency audio of the room). I then mirror these 600 points (remembering the complex-conjugate) so I have 1200 points. So then I need this frequency response to be transformed into the time domain so that I can convolve it with my original wav file. However, when I can't get my head round understanding how the samples in the FFT relate to the time - there is no original time domain sampling frequency as I've created the frequency response myself. To test, I used a simple sine wave, and performed an FFT (which my frequency response should replicate in the real thing) Then if I IFFT it with the same number of points, I seem to only be able to get one second of time information, and if I use more points, ie. 4096, in the IFFT, I get crazy things going on with the output impulse response. I've tried zero padding in the middle of the FFT signal but this still only seems to give me one seconds worth of information. Here is my test matlab code. If anyone can point out what I'm missing I'd much appreciate it. t = 0 : 1/600 : 1; freq1 = 5; sine1 = sin(2*pi*freq1*t); y=fft(sine1,1200); absy=abs(y); inv=ifft(y,4096); %have tried this at 1200 points also inv=real(inv); subplot(2,1,1) plot(absy) subplot(2,1,2) plot(inv) Many thanks, Matt
Frequency response to time domain - lack of understanding!
Started by ●November 21, 2007
Reply by ●November 21, 20072007-11-21
Hi Matt,> However, I'm having problems with the IFFT and time domain issues. My > frequency response is originally 600 points long, representing 0 to 300Hz > (I'm only modelling the low frequency audio of the room). I then mirror > these 600 points (remembering the complex-conjugate) so I have 1200 > points.The time domain sampling frequency (fs), and the distance between adjacent frequency domain points(df) are related by df = fs/N, where N is the number of points. So since you have 600 points originally, representing 0-300Hz, df = 300/600 = 0.5 Hz. So fs = N.df = 1200*0.5 = 600Hz. Assuming no aliasing, the DFT of time domain sequence respresents frequencies from -fs/2 to fs/2. As soon as you decide the f domain samples represent from -300 to 300 Hz, then 300 = fs/2 so fs = 600Hz. => T = 3
Reply by ●November 22, 20072007-11-22
matt_w wrote:> Hi all, > > I'm having a few problems with the basics of IFFT. I have created a > frequency repsonse (which is an acoustical model of the response of a > room). I want to convolve this with an audio file - thereby making the > audio sound like it was played in the room. > > However, I'm having problems with the IFFT and time domain issues. My > frequency response is originally 600 points long, representing 0 to 300Hz > (I'm only modelling the low frequency audio of the room). I then mirror > these 600 points (remembering the complex-conjugate) so I have 1200 > points. > > So then I need this frequency response to be transformed into the time > domain so that I can convolve it with my original wav file. However, when > I can't get my head round understanding how the samples in the FFT relate > to the time - there is no original time domain sampling frequency as I've > created the frequency response myself. > > To test, I used a simple sine wave, and performed an FFT (which my > frequency response should replicate in the real thing) Then if I IFFT it > with the same number of points, I seem to only be able to get one second > of time information, and if I use more points, ie. 4096, in the IFFT, I > get crazy things going on with the output impulse response. I've tried > zero padding in the middle of the FFT signal but this still only seems to > give me one seconds worth of information. > > Here is my test matlab code. If anyone can point out what I'm missing I'd > much appreciate it. > > t = 0 : 1/600 : 1; > freq1 = 5; > sine1 = sin(2*pi*freq1*t); > > y=fft(sine1,1200); > absy=abs(y); > > inv=ifft(y,4096); %have tried this at 1200 points also > inv=real(inv); > > subplot(2,1,1) > plot(absy) > subplot(2,1,2) > plot(inv) > > Many thanks, > Matt > >When you take an FFT of a sample of a signal, the length of the FFT will always equal the length of the sample, and the middle point of the FFT will always equal Fs/2, where Fs is your sampling rate. So if your sample is other than 1200 points long you need to scale your frequency-domain transfer function to fit, by interpolating or decimating points until it matches the length of your audio sample. Alternately you need to take the IFFT of your transfer function and use it as an FIR filter (suitably delayed) in the time domain. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" gives you just what it says. See details at http://www.wescottdesign.com/actfes/actfes.html