File resample_core.h¶
FileList > doppler > resample > resample_core.h
Go to the source code of this file
Resample module — public C API.
#include "doppler/clib_common.h"#include <math.h>#include <stddef.h>
Public Functions¶
| Type | Name |
|---|---|
| void | dp_ciccompmf (double * out, uint32_t N, uint32_t R, uint32_t M) Design a CIC passband-droop compensator FIR filter. Implements the closed-form Bernoulli-series maximally-flat-error method from Molnar & Vucic (IEEE TCAS-II 58(12):926-930, 2011, DOI 10.1109/TCSII.2011.2172522). The compensator runs at the decimated (output) rate and should be applied after the CIC stage. DC gain is exactly 1.0. Odd M gives symmetric linear-phase taps; even M gives half-sample-shifted linear-phase taps. |
| double | dp_kaiser_beta (double atten) Compute the Kaiser window beta parameter from stopband attenuation. Uses the standard Kaiser-Hamming formulae: atten > 50 dB: beta = 0.1102 * (atten - 8.7) 21 <= atten <= 50 dB: beta = 0.5842*(atten-21)^0.4 + 0.07886*(atten-21) atten < 21 dB: beta = 0.0 (rectangular window) |
| int | dp_kaiser_num_taps (int num_phases, double atten, double pb, double sb) Estimate the taps-per-phase count for a polyphase Kaiser FIR bank. Applies the Kaiser length formula to the per-phase normalised prototype (pb/num_phases, sb/num_phases), rounds up to the next odd symmetrical length, then divides by num_phases to give taps per branch. The result is the minimum num_taps argument to pass to dp_Resampler_create_custom() . |
Public Static Functions¶
| Type | Name |
|---|---|
| double | dp_kaiser_beta_eval (double atten) The Kaiser beta formula itself: the one implementation behind dp_kaiser_beta() and resamp's built-in bank. |
| size_t | dp_kaiser_num_taps_eval (size_t num_phases, double atten, double pb, double sb) The Kaiser taps-per-phase formula itself: the one implementation behind dp_kaiser_num_taps() and resamp's built-in bank. |
Public Functions Documentation¶
function dp_ciccompmf¶
Design a CIC passband-droop compensator FIR filter. Implements the closed-form Bernoulli-series maximally-flat-error method from Molnar & Vucic (IEEE TCAS-II 58(12):926-930, 2011, DOI 10.1109/TCSII.2011.2172522). The compensator runs at the decimated (output) rate and should be applied after the CIC stage. DC gain is exactly 1.0. Odd M gives symmetric linear-phase taps; even M gives half-sample-shifted linear-phase taps.
Parameters:
outOutput buffer; must hold at least M doubles. ALWAYS M an out-of-range M is written as M zeros, not left alone, so a caller cannot pre-fill a fallback design here and expect it to survive. Size by M, never by the table bound.NCIC filter order (number of integrator/comb stages, >= 1).RCIC decimation factor (>= 2).MNumber of compensator taps: odd M in[1, 19], even M in[1, 18]. The Bernoulli table is nine entries, so the two parities do not reach the same length; anything outside its own range yields the all-zero filter above.
>>> from doppler.resample import ciccompmf
>>> import numpy as np
>>> h = ciccompmf(4, 16, 5)
>>> h.shape, h.dtype
((5,), dtype('float64'))
>>> [round(float(v), 4) for v in h]
[0.029, -0.282, 1.5061, -0.282, 0.029]
function dp_kaiser_beta¶
Compute the Kaiser window beta parameter from stopband attenuation. Uses the standard Kaiser-Hamming formulae: atten > 50 dB: beta = 0.1102 * (atten - 8.7) 21 <= atten <= 50 dB: beta = 0.5842*(atten-21)^0.4 + 0.07886*(atten-21) atten < 21 dB: beta = 0.0 (rectangular window)
Parameters:
attenDesired stopband attenuation in dB (positive value).
Returns:
Kaiser beta parameter (>= 0.0).
>>> from doppler.resample import kaiser_beta
>>> round(kaiser_beta(60.0), 4)
5.6533
>>> kaiser_beta(20.0)
0.0
function dp_kaiser_num_taps¶
Estimate the taps-per-phase count for a polyphase Kaiser FIR bank. Applies the Kaiser length formula to the per-phase normalised prototype (pb/num_phases, sb/num_phases), rounds up to the next odd symmetrical length, then divides by num_phases to give taps per branch. The result is the minimum num_taps argument to pass to dp_Resampler_create_custom() .
Parameters:
num_phasesNumber of polyphase branches (power of two). A value below 1 is not a bank; the function returns 0.attenDesired stopband attenuation in dB. Below 8 dB the Kaiser length formula falls under one tap, and the prototype is floored at one.pbPassband edge in cycles per sample at the branch (input) rate, so Nyquist is 0.5 (0 < pb < sb < 1).sbStopband edge, same units aspb.
Returns:
Taps per polyphase branch (>= 1).
Public Static Functions Documentation¶
function dp_kaiser_beta_eval¶
The Kaiser beta formula itself: the one implementation behind dp_kaiser_beta() and resamp's built-in bank.
Header-inline so that resamp_core, which sits below this module in the link graph, computes beta with this code and not a private copy of it, without a link edge to resample_core (doppler#2652). dp_kaiser_beta() is a call to it; prefer that public function everywhere else.
Parameters:
attenDesired stopband attenuation in dB.
Returns:
Kaiser beta: 0.1102 * (atten - 8.7) above 50 dB, 0.5842 * (atten - 21)^0.4 + 0.07886 * (atten - 21) from 21 to 50 dB, and 0.0 below 21 dB.
function dp_kaiser_num_taps_eval¶
The Kaiser taps-per-phase formula itself: the one implementation behind dp_kaiser_num_taps() and resamp's built-in bank.
static inline size_t dp_kaiser_num_taps_eval (
size_t num_phases,
double atten,
double pb,
double sb
)
Header-inline for the same reason as dp_kaiser_beta_eval() (doppler#2652). num_phases must be at least 1, which dp_kaiser_num_taps() checks before calling it. Every other argument is total: the prototype length floors at one tap where the formula falls below it (an atten under 8 dB, or a NaN) and caps at 2^52, so the conversion to size_t is always defined.
Parameters:
num_phasesNumber of polyphase branches, >= 1.attenDesired stopband attenuation in dB; below 8 dB the prototype is one tap.pbPassband edge, as for dp_kaiser_num_taps().sbStopband edge, same units aspb.
Returns:
Taps per polyphase branch: the Kaiser length of the per-phase prototype, made odd, over num_phases, plus one.
The documentation for this class was generated from the following file native/inc/doppler/resample/resample_core.h