# FFT Convolution: missing sample somewhere

For a piece of software I've been working on lately I need to implement FFT convolution for performance reasons.

Doing so has been mildly succesfull but there is still a error somewhere causing lots of small spikes to show up on the waveform. Also when looking at the spectrum of the signal, lots of distortion can be seen which is filtered out mostly at 15 KHz.

What I do in the filter is the following with overlap - add:

1. Create the filter kernel of 101 points and FFT it
2. Create a buffer holding 200 samples of audio
3. When there are 200 samples ready, FFT the signal and multiply with the filter kernel FFT.
4. IFFT the filtered signal again
5. Add last 100 samples from the previous run to the first 100 samples of the current output
6. Save the last 100 samples for the next run.

The small spikes and distortion when looking at the spectrum seems to come from a missing sample somewhere, but I can't track down exactly where it happens.

The following code is what I use to do the filtering:

function TFFTAnalyzer.doAnalyzer(Sample: Single) : Single;
var
I: Integer;

Temp : Single;
begin
Result := X[BufferPos];
X[BufferPos] := Sample;

BufferPos := BufferPos + 1;
if BufferPos > 200 then
BufferPos := 1;

if BufferPos = 200 then
begin
for I := 0 to 512 do
begin
if I > 200 then
X[I] := 0;
end;

//Calculate the FFT of the sample buffer
FFT_transform(1024, X);

I := 0;

while I <= 1024 do
begin
Temp := X[I] * FilterX[I] - X[I + 1] * FilterX[I + 1];
X[I + 1] := X[I] * FilterX[I + 1] + X[I + 1] * FilterX[I]; // imaginary part
X[I] := Temp; // real part

I := I + 2;
end;

//Inverse FFT the signal
FFT_inverse(1024, X);

//Overlap the first 100 samples
for I := 0 to 100 do
begin
X[I] := (X[I] + Overlap[I]);// / 2;
end;

//Save last 100 samples for next overlap
for I := 200 to 300 do
begin
Overlap[I - 200] := X[I];
end;
end;
end; This is the picture showing the problem with the spikes and distortion.

• is it 32 bit or 64 bit computation ? – Fat32 Dec 17 '15 at 0:55
• i really don't want to decode your code. is your FFT size 1024? your 101-tap filter kernel, are you zero-padding that out to 1024 before you FFT that? if so, with either overlap-add or overlap-save, you should be able to get 924 samples out from each frame. – robert bristow-johnson Dec 17 '15 at 5:12
• The program uses 32 bit computation. The filter I try to create uses 1024 point FFT's, where I have a filter kernel of 101 taps that I calculate over a buffer of 200 samples. The delay can't be too high, so I can't create a huge buffer of samples. – Jesse Willem Dec 17 '15 at 21:43
• I provided an indirect solution to you. – Fat32 Dec 21 '15 at 0:53