Your Equation

Library / Signal processing and digital filters / DSP-47

Signal processing and digital filters

Full upsample–FIR–downsample output length

Length of the full output when N input samples are upsampled by L, filtered by an H-tap FIR and downsampled by M, keeping indices 0, M, 2M, … of the full zero-extended convolution.

Ref
DSP-47
Rev
v1
Field
Signal processing and digital filters
Result
Nout [samples]

Upsampling a sequence of N samples by L inserts L − 1 zeros between samples, giving (N − 1)L + 1 samples. Convolving with an H-tap filter lengthens this to (N − 1)L + H. Keeping indices 0, M, 2M, … leaves ⌊((N − 1)L + H − 1)/M⌋ + 1 samples. If the output is trimmed to remove the filter delay, the count is different.

Length of the full output when N input samples are upsampled by L, filtered by an H-tap FIR and downsampled by M, keeping indices 0, M, 2M, … of the full zero-extended convolution. Delay-compensated trimming gives a different count.

Calculator

Solve for
samples
1100,000
11,000
taps
110,000
11,000
  • Length after zero insertion, (N − 1)L + 113 samples
  • Full filtered length, (N − 1)L + H16 samples
  • Length if the filter had no tail, ⌊(N − 1)L/M⌋ + 17 samples

What drives the result

Each variable is moved across its typical range while the others stay at the values above. The longest bar is the key driver.

Output length (samples) current value 8 samples
NInput samplesKey driver
2150,000
HFIR length
75,010
LInterpolation factor
42,000
MDecimation factor
116
  • 5 input samples become 8 output samples, 1.6 per input sample, against the ideal ratio of 1.5.
  • The difference is the filter tail: 3 extra full-rate samples, which are trimmed or flushed depending on the implementation.
Chart data as tables

Ranked variables

VariableTypical rangeLowest resultHighest resultSwing (samples)Local stepChange in result
N Input samples1 to 100,000 2150,000150,000+1 +25 %
H FIR length1 to 10,000 taps75,0064,999+1 taps+12.5 %
L Interpolation factor1 to 1,000 42,0021,998+1 +25 %
M Decimation factor1 to 1,000 11615+1 −25 %

Sweep of Input samples

Input samplesOutput length (samples)
12
4.2177
17.7828
74.99113
316.2475
1,3342,002
5,6238,435
23,71035,570
100,000150,000

Sweep one variable

Output length (samples)Hover, touch, or use the arrow keys on the chart
050k100k150k 110100100010k100k Input samples, log scale now 8

Variables and how each one contributes

Nout

Output length

Result · samples

What the equation gives you. Everything else feeds it.

N

Input samples

· typical 1 to 100,000

The number of input samples. Raises the output length in proportion to L/M. Raising it by 10 % (to 5.5) moves the result by +25 %, from 8 to 10 samples.

L

Interpolation factor

· typical 1 to 1,000

The interpolation factor. Raises the output length roughly in proportion to L. Raising it by 10 % (to 3.3) moves the result by +0 %, from 8 to 8 samples.

H

FIR length

taps · typical 1 to 10,000

The FIR filter length, in taps. Adds H − 1 samples of filter tail to the full convolution. Raising it by 10 % (to 4.4) moves the result by +0 %, from 8 to 8 samples.

M

Decimation factor

· typical 1 to 1,000

The decimation factor. Lowers the output length roughly in inverse proportion to M. Raising it by 10 % (to 2.2) moves the result by +0 %, from 8 to 8 samples.

Worked example with the values above

  1. Upsampled and filtered length: (N − 1)L + H = 4 × 3 + 4 = 16 samples.
  2. Last index: 15; keep every 2th sample.
  3. N_out = ⌊15/2⌋ + 1 = 8 samples.

Assumptions and limits

  • Integer, positive resampling factors, with a low-pass filter that gives enough alias rejection.
  • For analytic-signal formulas, a narrowband signal with a clean quadrature component and less than π of phase change per sample.

Common mistakes

  • Not reducing L/M by the common factor, which wastes computation.
  • Forgetting the filter delay when counting output samples.
  • Using the phase difference when the true change per sample exceeds π.

Statistics and uncertainty

Rates and lengths here are exact integer relations. Estimates of envelope and frequency from analytic samples are sensitive to noise, since the phase of a small sample is poorly defined, so use only samples well above the noise floor.

Where it is used

  • Converting between audio and instrumentation sample rates and sizing buffers.
  • Demodulating amplitude and frequency from complex baseband data.

Maths you need

  • Interpolation and decimation: raising and lowering the sampling rate by integer factors
  • Analytic signal: a real signal plus i times its Hilbert transform
  • Principal phase: phase wrapped to the range −π to π

Related formulas

Practise this formula