OTFConvolver¶
-
class
DSP.
OTFConvolver
(FIRfilter, data=None)¶ Bases:
object
On-the-fly convolution tool
If the convolver is initialized with data, those data are processed. If not, the
next()
method will process one sample, returning None until there are enough samples to process.circ_buf - (list of float) data - (list of float) history of all input samples F - (ndarray) FIR filter filtered - (list of float) history of all filtered samples K - (int) number of taps in F M - (int) length of data (if provided) oldest - (int) pointer to current data
Methods Summary
convolution_step
(sample)cross-correlation with a circular buffer
next
(sample)perform a step with the circular buffer convolver
Methods Documentation
-
convolution_step
(sample)¶ cross-correlation with a circular buffer
This inserts ‘raw_data’ into the position in circular buffer ‘S’ indicated by the index ‘oldest’ and then applies the filter ‘F’ to the data in ‘S’. It returns the sum, the modified signal array, and the new index.
Notes
The FORTRAN-like version would be:
sum=0 S[oldest] = raw_data for n in list(range(K)): sum += F[n]*S[(oldest + n) % K] oldest=(oldest+1) % K
Pointer setting: Because Python ranges are defined by current:last+1, the pointer must be updated before the multiplication with the filter is done.
-
next
(sample)¶ perform a step with the circular buffer convolver
The convolver requires K samples to work on, one for each filter tap.
-