1. PyPA
  2. Python Packaging Authority Projects
  3. pypi
  4. Issues


Issue #95 invalid

scikits.samplerate.resample output length off by one?

created an issue

scikits.samplerate.resample takes three (main) arguments: an array(like) data structure that is the signal, a resampling ratio, and a string indicating the method to be used. I have noticed, however, that the signal it returns is always one point shorter than I expected. For instance, if I downsample from 44.1kHz to 16000, I expect the length of the output signal to be len(input_signal) * trunc(44100 / 16000). However, it is ALWAYS one point shorter (regardless of choice of signal and samplerate ratio, as far as I can tell). E.g.:

from __future__ import division
from math import trunk
from numpy.random import uniform
from scikits.samplerate import resample

L = 10000
SR_in = 44100
SR_out = 16000

signal_in = uniform(size=L)
signal_out = resample(L, SR_in / SR_out, 'sinc_best')
expected_length = trunc(L * SR_in / SR_out)
print expected_length - 1 = len(signal_out) # prints "True"

It is possible this is not a bug and there is a good signal-processing reason why my expectation of how long it should be is off by one. But, if so, what is the ACTUAL sample rate (or timestep) of signal_out? It is presumably not the 16kHz I requested.

Comments (1)

  1. Log in to comment