You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for scikits.samplerate: it looks like a great package. I am, however, surprised at the number of samples I get from calling resample on a mono signal: it is always exactly one less than my expectations. I wanted to confirm this was the correct behavior and not a bug before I go on using the package "in production". Here’s a worked example that shows what I mean:
from __future__ import division
from math import trunc
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"
I took a look at scikits.samplerate-0.3.3/scikits/samplerate/_samplerate.pyx. If I understand correctly, on line 173
osz = (r * nframes - 1)
sets the output length. That explains why the resampled audio is the length it is (original length times ratio, minus 1, truncated towards zero because of the cast to a long integer), but why is 1 being subtracted here?
It’s quite possible there’s a legitimate signal processing reason for this. But if so, what is the actual samplerate of signal_out?
The text was updated successfully, but these errors were encountered:
Thanks for scikits.samplerate: it looks like a great package. I am, however, surprised at the number of samples I get from calling
resample
on a mono signal: it is always exactly one less than my expectations. I wanted to confirm this was the correct behavior and not a bug before I go on using the package "in production". Here’s a worked example that shows what I mean:I took a look at scikits.samplerate-0.3.3/scikits/samplerate/_samplerate.pyx. If I understand correctly, on line 173
osz = (r * nframes - 1)
sets the output length. That explains why the resampled audio is the length it is (original length times ratio, minus 1, truncated towards zero because of the cast to a long integer), but why is 1 being subtracted here?
It’s quite possible there’s a legitimate signal processing reason for this. But if so, what is the actual samplerate of
signal_out
?The text was updated successfully, but these errors were encountered: