resample_int
Builtin index · Signal processing
result = resample_int(x, L, M, [order=60], [fs=])
Input: x, L, M, order, fs · Output: result
What it is
x: a length-N vector or Signal; L, M: whole numbers ≥ 1, the interpolation and decimation factors; order (optional, even, default 60); fs (optional), as for upsample. Rational rate change by L/M in a single pass: zero-stuff by L, filter once, decimate by M.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = resample_int(x, L, M, [order=60], [fs=]) | x vector or Signalx: a length-N vector or Signal.L numberL, M: whole numbers ≥ 1, the interpolation and decimation factors.M numberL, M: whole numbers ≥ 1, the interpolation and decimation factors.order optional (default 60)order (optional, even, default 60).fs optionalfs (optional), as for upsample. | result — | Returns ceil(N*L/M) samples at Fs = fs*L/M. Prefer this to x.upsample(L).downsample(M): that runs two filters in series at the same intermediate rate, doubling both the transition-band loss and the group delay for no benefit. The single shared filter's cutoff is min(fs/2, fs*L/(2*M)) — the interpolation limit when L >= M, the anti-alias limit when M > L — with gain L. Causal, so the output is delayed by order/2 samples at the intermediate rate fs*L (order/(2*fs*L) seconds), half what the two-step form costs. Added in v0.3.0. |
Examples
No documentation example calls this form yet. The Signal processing chapter is where one belongs.
How it works
resample_int(x, L, M, [order=], [fs=]) — rational rate change by L/M in one pass: zero-stuff by L, filter ONCE, decimate by M. Output rate is fs*L/M. The single shared filter is the point. Calling upsample then downsample runs two filters in series, doubling the transition-band loss and the group delay for no benefit — both filters run at the same intermediate rate fs*L, and two cascaded lowpasses there are just a worse version of one lowpass at the tighter of the two cutoffs. So the cutoff here is min(fs/2, fs*L/(2*M)): the interpolation cutoff when upsampling dominates (L >= M), the anti-alias cutoff when decimating does (M > L). Gain L, same reason as upsample. Group delay: order/2 samples at the intermediate rate fs*L, i.e. order/(2*fs*L) seconds — HALF what x.upsample(L).downsample(M) costs, and the reason to prefer this when both factors apply.
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.