Average across blocks of FFT buffers

6 posts / 0 new
Last post
PabloFH
Offline
Last seen: 1 month 1 week ago
Joined: 10/27/2017 - 6:30pm
Average across blocks of FFT buffers

Hi,

I am struggling to build a system to estimate the spectral coherence between 2 signals in AudioWeaver. Computing the FFT, complex conjugate, magnitude, and magnitude square is not a problem. What I cannot figure out is how to compute the FFTs of a number of consecutive blocks, say 4, and then compute the average frequency response across the 4 blocks.

Thanks.

Pablo F. Hoffmann

Axel Nilsson
Offline
Last seen: 1 day 21 hours ago
Joined: 12/19/2016 - 2:02pm

Hey Pablo,

 

If I'm understanding your problem correctly, you can use the BufferUp or Rebuffer module to increase the effective block size by a factor of 4, then run your FFT on those larger blocks. 

 

Let me know if this doesn't answer your question.

Thanks

-Axel

PabloFH
Offline
Last seen: 1 month 1 week ago
Joined: 10/27/2017 - 6:30pm

Hi Axel,

Sorry I wasn't clear enough because that is not what I meant. Say I have a 1024-sample block, what I need is to run FFTs on 4 consecutive blocks of 256-sample and average the *FFT results* across blocks, i.e. I should get a 129-point frequency vector where each point is the average across 4 data points. It is similar to how the Welsh periodogram is computed, and the average part is critical because I am interested in the squared spectral coherence too. If the coherence is computed directly on raw data, i.e. without average, the result across frequencies is always 1 which is not useful.

Does that make sense?

Thanks.

Pablo F. Hoffmann

Axel Nilsson
Offline
Last seen: 1 day 21 hours ago
Joined: 12/19/2016 - 2:02pm

Thanks for the clarification. I believe this layout accomplishes your goal, though it is simplified to just two 256 sample blocks rather than 4. The key for computing the average is the SampleStatistics module.

 

Does this help?

Thanks

-Axel

PabloFH
Offline
Last seen: 1 month 1 week ago
Joined: 10/27/2017 - 6:30pm

Hi Axel,

That works. Really appreciate your prompt reply.

Thanks.

Pablo

PabloFH
Offline
Last seen: 1 month 1 week ago
Joined: 10/27/2017 - 6:30pm

Hi Axel,

An alternative is to use a Rebuffer module and a WindowAlias module set with a rectangular window. This will generate a sum that can be divided by the number of summed-up blocks to obtain the average. BufferUp might be used instead of Rebuffer but this will change the ClockDivider.

The output of the WindowAlias1 module is a 132-sample block so the subsystem is summing across 8 blocks (1056/132). What bothers me is that given the functionality of the WindowAlias, using a rectangular window means multiplying the 1056-sample input block by 1s which is a waste of computational power.

Thanks.

Pablo