[LAD] Help with frequency domain filtering basics

fons at kokkinizita.net fons at kokkinizita.net
Thu Nov 26 22:58:05 UTC 2009

On Thu, Nov 26, 2009 at 11:30:27PM +0100, Olivier Guilyardi wrote:
> Hi Fons :)
> On 11/25/2009 09:32 PM, fons at kokkinizita.net wrote:
> > process (input, output)
> > {
> > // both input, output are of size fftsize/2
> > 
> > 1.   R1 <= IP * W1
> > 2.   R2 <= input * W2
> > 3.   IP <= input
> > 4.   FFT, callback, IFFT
> > 5.   output <= (R1 + OP) * scale
> > 6.   OP <= R2
> > }
> Now, that works ! I'm attaching the fixed code for the records.

Thanks, could be useful one day !

> I've tried hard to understand where the problem was, and one thing I'm sure
> about is that you fft'ize a given block of input twice, once with the ascending
> part of the window applied (in R1), then again the same block of data multiplied
> with the descending part of the window (in R2).

That's correct. But the first time you combine the first half
of the current block with the second half of the previous,
and the second time you combine the second half of the current
block with the first half of the *next*. I think you failed to
do that somehow.

> Now, how I managed to get this running in Octave is a mistery to me ;)

Miracles happen.
> Anyway you method did solve my problem, and I now still have a lot of work,
> because I need all of this to run with integers (fixed point fft) and the joys
> of overflow..

Integer FFTs can be lots of fun :-)

One trick you may try (if you write the FFT yourself) is to
distribute the 'scale' thing over the internal iterations of
the FFT. Either shift by one bit each iteration in the FFT,
or in the IFFT, or do it each *second* iteration in both.
Which is best depends on the application, and the type of
signal which you process.

Another thing: you are aware that this method is not just
a filter ? It also modulates the signal... How bad it gets
depends on the frequency response you try to obtain.



Io lo dico sempre: l'Italia è troppo stretta e lunga.

More information about the Linux-audio-dev mailing list