Generic Filter
- class gpype.backend.filters.base.generic_filter.GenericFilter[source]
Bases:
IONodeGeneric Linear Time-Invariant (LTI) digital filter for real-time use.
Implements a flexible LTI filter using transfer function coefficients (numerator ‘b’ and denominator ‘a’ polynomials). For IIR filters, converts to second-order sections for numerical stability. For FIR filters, uses direct form implementation to avoid unnecessary decomposition overhead. Maintains state for streaming data.
- __init__(b, a, **kwargs)[source]
Initialize the generic filter with transfer function coefficients.
- Parameters:
b (
ndarray) – Numerator coefficients of the transfer function, as an ndarray, a tuple or a list. Stored as a list of float, so the pipeline can be written to a document.a (
ndarray) – Denominator coefficients of the transfer function, the same way.**kwargs – Additional arguments passed to parent IONode class.
- Raises:
ValueError – If coefficients are empty or invalid.
- setup(data, port_context_in)[source]
Setup the generic filter before processing begins.
Converts transfer function to second-order sections for numerical stability and initializes filter state based on channel configuration.
- Parameters:
- Return type:
- Returns:
Output port context dictionary with updated metadata.
- Raises:
ValueError – If required context keys are missing or coefficients are invalid.