xtos_ notch_ init
Initializes a second-order IIR notch filter’s coefficients and history state.
On this page
Declaration
#include <xtos/signal.h>
int xtos_notch_init(struct xtos_notch_filter *filter,
double sample_rate_hz,
double notch_frequency_hz,
double quality_factor);Parameters
| Parameter | Type | Description |
|---|---|---|
| filter | struct xtos_notch_filter * | Non-NULL caller-owned filter state. |
| sample_rate_hz | double | Sampling rate in Hz; implementation requires it to be positive but does not explicitly check finite. |
| notch_frequency_hz | double | Notch center frequency in Hz, requiring 0 < f0 < fs/2; finite is not explicitly checked. |
| quality_factor | double | Q value, required to be positive; finite is not explicitly checked. |
Return value
Returns 0 on success and -1 on failure. Success clears filter history.
Errors
| errno | Condition |
|---|---|
| EINVAL | filter is NULL or the comparisons fs>0, 0<f0<fs/2, and Q>0 fail. |
Notes
- The public implementation has no isfinite check; callers must reject NaN/Inf first and must not treat no error as numeric validation.
- Reinitialization discards history and creates a transient; keep one independent state per channel for a continuous signal.
Example
Source
This reference describes headers and implementation at OpenXTOS commit dd313955ad57542bcd2af8827157d1bbd0cf5e83.