Determining channel frequency response from measured data via IFFT I've been working on a small system that transmits a linear chirp over the 35Hz-20kHz frequency range in a room and simultaneously records the transmitted signal with echoes (from the floor, walls, etc.), using two microcontrollers.
Using the received data $y[n]$ and reconstructing the transmitted chirp $x[n]$ in the receiver, I obtain the channel frequency response by $H[k]=Y[k]/X[k]$, $X$ and $Y$ being the FFTs of $x$ and $y$ respectively. I then attempt to compute the channel impulse response by computing $h[n]={\tt IFFT}(H[k])$. I then try to use time-gating to get rid of the echoes.

The fact that I am not using external memory limits my computational ability to using float arrays of length N=2048 at most, so the signals I'm dealing with are in the single milliseconds regions (this of course limits my resolution, but that's a problem I have to come to terms with).

The problem that's bothering me is, when I look at the calculated impulse response I get something like this:



It seems that the main response is seemingly moved cyclicly a bit to the left, so that its beginning is at the end of the array and there is a large "spike" there (either that or the response has a big delay, which doesn't fit the physical system as the speaker and the microphone are just a few centimeters apart for the tests I'm performing).
What might be the reason for this?
I've read some posts around here which looked similar and there was talk about pre-ringing; could this be the case here?

I want to compute the FFT of the time-gated (and ideally, "fixed") impulse response to get some data out of it, and a part of it is obtaining the delay of the main response- can this be done in this case?

Insight would be greatly appreciated!

Avner

Edit: Attempting to bump this along with a follow-up question I had to Peter's response.
If I should attempt to ask this in a separate question instead- please let me know.

"Thank you very much! So far I've been transmitting a chirp that lasts 25ms, and the reception goes on for 32ms (so there's an underlying assumption that the channel is 7ms long due to short distances between speaker and mic). I've padded the chirp samples with zeroes to match the reception length (in samples) and using this scheme gave me the graph attached in the question. 

I've read that using a sine-sweep and performing a deconvolution results in separating nonlinear harmonics to "behind" the channel response in time, so that might be what's moved cyclicly and runs over the channel. Do you think there is a solution to this problem, given the limitations? I'm pretty much filling up the 32kB memory on the microcontroller I'm using with two 2048-float arrays that constitute a general array I'm working on and take up 16kB (doing things in-place) and two more int-arrays that take up 12kB more, so there's not a lot of memory left to use."
Without seeing your code directly, my guess is that you're doing something like:

N = length(x);
X = fft(x,N);
Y = fft(y,N);
H = Y./X;
h = ifft(H);


The problem with doing that is this operation performs circular convolution over a length of N.  The trouble is, the "true" length of the convolution of y with 1/X's impulse response will be of length 2N - 1 (assuming x and y are both of length N).

So you are getting time domain aliasing.

The solution is probably to set

N = length(x) + length(y) - 1


or greater.