Filters
- class tiliqua.dsp.SVF(*args, src_loc_at=0, **kwargs)
Oversampled Chamberlin State Variable Filter.
Filter cutoff and resonance are tunable at the system sample rate.
Highpass, lowpass, bandpass routed out on stream payloads hp, lp, bp.
Reference: Fig.3 in https://arxiv.org/pdf/2111.05592
- class tiliqua.dsp.FIR(*args, src_loc_at=0, **kwargs)
Fixed-point FIR filter that uses a single multiplier.
This filter contains some optional optimizations to act as an efficient interpolator/decimator. For details, see
stride_i
,stride_o
below.- Members:
i (
In(stream.Signature(ASQ))
) – Input stream for sending samples to the filter.o (
In(stream.Signature(ASQ))
) – Output stream for getting samples from the filter. There is 1 output sample per input sample, presentedfilter_order+1
cycles after the input sample. Forstride_o > 1
, there is only 1 output sample perstride_o
input samples.
- __init__(fs, filter_cutoff_hz, filter_order, filter_type='lowpass', prescale=1, stride_i=1, stride_o=1)
- fsint
Sample rate of the filter, used for calculating FIR coefficients.
- filter_cutoff_hzint
Cutoff frequency of the filter, used for calculating FIR coefficients.
- filter_orderint
Size of the filter (number of coefficients).
- filter_typestr
Type of the filter passed to
signal.firwin
-"lowpass"
,"highpass"
or so on.- prescalefloat
All taps are scaled by
prescale
. This is used in cases where you are upsampling and need to preserve energy. Be careful with this, it can overflow the tap coefficients (you’ll get a warning).- stride_iint
When an FIR filter is used as an interpolator, a common pattern is to provide 1 ‘actual’ sample and pad S-1 zeroes for every S output samples needed. For any
stride > 1
, thestride
must evenly dividefilter_order
(i.e. no remainder). Forstride > 1
, this core applies some optimizations, assuming every S’th sample is nonzero, and the rest are zero. This results in a factor S reduction in MAC ops (latency) and a factor S reduction in RAM needed for sample storage. The tap storage remains of sizefilter_order
as all taps are still mathematically required. The nonzero sample must be the first sample to arrive.- stride_oint
When an FIR filter is used as a decimator, it is common to keep only 1 sample and discard M-1 samples (if decimating by factor M). For
stride_o == M
, only 1 output sample is produced per M input samples. This does not reduce LUT/RAM usage, but avoids performing MACs to produce samples that will be discarded.
- class tiliqua.dsp.Boxcar(*args, src_loc_at=0, **kwargs)
Simple Boxcar Average.
Average of previous N samples, implemented with an accumulator. Requires no multiplies, often useful for simple smoothing.
Can be used in low- or high-pass mode.