Ok so currently there is indeed several problems :
- documentation is not enough explenatory and ill-formed, this is why there only documentation for getters.
- the
AverageFftparameter was never set, resulting in ignoring theBlockSizeandBlockNumberparameters.
I’ll soon fix this so it can work as expected (see explanation below).
Let me explain the options a bit, so you can tell me if some names should be changed or if parameters should be added/removed to the API :
-
OptimizeForRealInput: basically it switches between usingscipy.signals.fftandscipy.signals.rfft. This has an incidence on the output size (output size for real input is ~ half the size). -
WindowingFunction: the windowing kernel to use. A kernel of the size of the input signal is generated and applied before doing the FFT. -
Average FFT per block: when off the filter computes a single FFT on the whole signal. If the signal is big this can take some time. To allow for a bit less precise FFT but much shorter computation time, one can average the FFT turning this optionOn. The algorithm when averaging the FFT is controlled by two other parameters :NumberOfBlocksandBlockSize. The algorithm is doing the following :- Create a windowing kernel of size
BlockSize(or half of it ifOptimizeForRealInputis on) - Extract the first
BlockSizesamples of the input signal - Apply the windowing kernel and then the FFT to it. The resulting FFT is of size
BlockSize(or half of it ifOptimizeForRealInputis on) - Store this FFT in a buffer
- Repeat the process
NumberOfBlockstimes from step2.but shifting the starting point when extracting the samples. The idea is that the block is “sliding” from start to finish. See below for an explanation of how the shift occurs. Green is the input signal and red are the block extracted - Once all blocks are extracted, average them all and return this result.
- Create a windowing kernel of size
-
Normalize: this parameter has 2 effects. First it transform the imaginary output of the FFT as a real output representing of the norm of all imaginary values and also divide it by the Windowing kernel energy. Second it removes the mean signal of each block before doing the FFT. For example on a pure sinusoidal signal the mean is 0 so it will have no effect.
The overall algorithm has been crafted with people from the acoustic world, maybe it is different from welch algorithm but it should still be usable (once I correct the bugs
).
