File HalfbandDecimator_core.h¶
FileList > HalfbandDecimator > HalfbandDecimator_core.h
Go to the source code of this file
Halfband 2:1 decimator for CF32 IQ (adapter over hbdecim_core). More...
#include "hbdecim/hbdecim_core.h"
Public Types¶
| Type | Name |
|---|---|
| typedef hbdecim_state_t | HalfbandDecimator_state_t |
Public Functions¶
| Type | Name |
|---|---|
| HalfbandDecimator_state_t * | HalfbandDecimator_create (size_t num_taps, const float * h) Create a HalfbandDecimator with caller-supplied FIR taps. Implements a 2:1 polyphase halfband decimator over CF32 IQ. The caller provides the FIR branch coefficient array h; use doppler.resample.kaiser_num_taps(2, atten, pb, sb) to size it and scipy or the built-in bank helper to design the prototype. Output length is approximately x_len / 2 per execute() call. |
| void | HalfbandDecimator_destroy (HalfbandDecimator_state_t * state) |
| size_t | HalfbandDecimator_execute (HalfbandDecimator_state_t * state, const float complex * x, size_t x_len, float complex * out) Decimate x by 2 using the polyphase halfband FIR filter. Processes every second input sample through the FIR branch and passes the other branch through the all-pass (zero-delay) path. State persists between calls — contiguous blocks give identical output to one large block. Output length is floor(x_len / 2). |
| size_t | HalfbandDecimator_execute_max_out (HalfbandDecimator_state_t * state) |
| size_t | HalfbandDecimator_get_num_taps (const HalfbandDecimator_state_t * state) Number of FIR branch taps as passed to create. The all-pass (even-phase) branch has no taps; only the odd-phase FIR branch has length num_taps. The total prototype length is 2 * num_taps - 1. |
| double | HalfbandDecimator_get_rate (const HalfbandDecimator_state_t * state) Fixed decimation rate — always 0.5. The halfband decimator is structurally 2:1; this property exists for API parity with Resampler and RateConverter. |
| void | HalfbandDecimator_get_state (const HalfbandDecimator_state_t * state, void * blob) Serialize the decimator's delay-line state into blob . |
| void | HalfbandDecimator_reset (HalfbandDecimator_state_t * state) Zero all delay lines. Coefficients and num_taps preserved. Call between signal bursts to suppress transient ringing from prior filter state. The next execute() after reset produces the same output as a freshly created decimator fed the same input. |
| int | HalfbandDecimator_set_state (HalfbandDecimator_state_t * state, const void * blob) Restore state from blob ; DP_OK, or DP_ERR_INVALID if rejected. |
| size_t | HalfbandDecimator_state_bytes (const HalfbandDecimator_state_t * state) Serialized-state byte size (forwarded to the hbdecim leaf). |
Macros¶
| Type | Name |
|---|---|
| define | HBDECIM_MAX_OUT 32768 |
Detailed Description¶
Thin adapter over hbdecim_state_t. The caller supplies a FIR coefficient array at construction; use resample.build_bank(2, ...) from Python to generate a suitable halfband prototype.
Lifecycle:
float h[] = { ... }; // num_taps FIR branch coefficients
HalfbandDecimator_state_t *r =
HalfbandDecimator_create(num_taps, h);
float complex out[512];
size_t n = HalfbandDecimator_execute(r, in, 1024, out);
HalfbandDecimator_destroy(r);
Public Types Documentation¶
typedef HalfbandDecimator_state_t¶
Public Functions Documentation¶
function HalfbandDecimator_create¶
Create a HalfbandDecimator with caller-supplied FIR taps. Implements a 2:1 polyphase halfband decimator over CF32 IQ. The caller provides the FIR branch coefficient array h; use doppler.resample.kaiser_num_taps(2, atten, pb, sb) to size it and scipy or the built-in bank helper to design the prototype. Output length is approximately x_len / 2 per execute() call.
Parameters:
num_tapsNumber of FIR branch coefficients in h.hFloat32 FIR branch coefficients, length num_taps. Must be a symmetric halfband prototype (antisymmetric even-indexed taps zeroed).
Returns:
Non-NULL on success, NULL on invalid args or OOM.
>>> from doppler.resample import HalfbandDecimator
>>> import numpy as np
>>> h = np.array([0.0625, 0.25, 0.375, 0.25, 0.0625],
... dtype=np.float32)
>>> hb = HalfbandDecimator(h=h)
>>> hb.num_taps, hb.rate
(5, 0.5)
function HalfbandDecimator_destroy¶
Free all resources. NULL is a no-op.
function HalfbandDecimator_execute¶
Decimate x by 2 using the polyphase halfband FIR filter. Processes every second input sample through the FIR branch and passes the other branch through the all-pass (zero-delay) path. State persists between calls — contiguous blocks give identical output to one large block. Output length is floor(x_len / 2).
size_t HalfbandDecimator_execute (
HalfbandDecimator_state_t * state,
const float complex * x,
size_t x_len,
float complex * out
)
Parameters:
statePointer to a valid HalfbandDecimator_state_t.xCF32 input array. Length must be even for exact half-rate output; odd lengths write floor(x_len/2).x_lenNumber of input samples.outOutput buffer; must hold at least floor(x_len/2) samples.
Returns:
CF32 decimated output; length == floor(x_len / 2).
>>> from doppler.resample import HalfbandDecimator
>>> import numpy as np
>>> h = np.array([0.0625, 0.25, 0.375, 0.25, 0.0625],
... dtype=np.float32)
>>> hb = HalfbandDecimator(h=h)
>>> y = hb.execute(np.zeros(100, dtype=np.complex64))
>>> y.shape, y.dtype
((50,), dtype('complex64'))
function HalfbandDecimator_execute_max_out¶
Always returns HBDECIM_MAX_OUT.
function HalfbandDecimator_get_num_taps¶
Number of FIR branch taps as passed to create. The all-pass (even-phase) branch has no taps; only the odd-phase FIR branch has length num_taps. The total prototype length is 2 * num_taps - 1.
>>> from doppler.resample import HalfbandDecimator
>>> import numpy as np
>>> h = np.array([0.0625, 0.25, 0.375, 0.25, 0.0625],
... dtype=np.float32)
>>> HalfbandDecimator(h=h).num_taps
5
function HalfbandDecimator_get_rate¶
Fixed decimation rate — always 0.5. The halfband decimator is structurally 2:1; this property exists for API parity with Resampler and RateConverter.
>>> from doppler.resample import HalfbandDecimator
>>> import numpy as np
>>> h = np.array([0.0625, 0.25, 0.375, 0.25, 0.0625],
... dtype=np.float32)
>>> HalfbandDecimator(h=h).rate
0.5
function HalfbandDecimator_get_state¶
Serialize the decimator's delay-line state into blob .
function HalfbandDecimator_reset¶
Zero all delay lines. Coefficients and num_taps preserved. Call between signal bursts to suppress transient ringing from prior filter state. The next execute() after reset produces the same output as a freshly created decimator fed the same input.
>>> from doppler.resample import HalfbandDecimator
>>> import numpy as np
>>> h = np.array([0.0625, 0.25, 0.375, 0.25, 0.0625],
... dtype=np.float32)
>>> hb = HalfbandDecimator(h=h)
>>> _ = hb.execute(np.ones(64, dtype=np.complex64))
>>> hb.reset()
>>> hb.num_taps
5
function HalfbandDecimator_set_state¶
Restore state from blob ; DP_OK, or DP_ERR_INVALID if rejected.
function HalfbandDecimator_state_bytes¶
Serialized-state byte size (forwarded to the hbdecim leaf).
Macro Definition Documentation¶
define HBDECIM_MAX_OUT¶
The documentation for this class was generated from the following file native/inc/HalfbandDecimator/HalfbandDecimator_core.h