Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

long window mode for signals with sr <= 210Hz #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

markostam
Copy link

Pyrubberband will hang when faced with low-sr signals unless the --window-long flag is set. This PR adds that flag for signals below 210Hz and allows the process to complete.

@bmcfee
Copy link
Owner

bmcfee commented May 3, 2018

Interesting -- looks like the tests are bombing out though. Any idea what's up with that?

BTW, @jongwook, is this also an issue in your fork?

@jongwook
Copy link

jongwook commented May 4, 2018

I am traveling, but let me try in the next 24 hours or so. I never knew that there can be WAV files with <210Hz sample rate..

@markostam
Copy link
Author

markostam commented May 4, 2018

I took a quick look at test_pitch and it seems like signals under a certain sample rate start losing samples compared to the original. The rate under which samples start getting chopped seems to be 1524, at least for the length of signal I quickly looked at. For example:

sr=1523; num_samples=3000; freq=500; n_step=0.5
y = synth(sr, num_samples, freq)
y_s = pyrubberband.pitch_shift(y, sr, n_step)
len(y_s)

returns 2998. But if you change sr=1524 and redo the above steps, len(y_s) returns 3000 as expected...

@bmcfee
Copy link
Owner

bmcfee commented May 4, 2018

The rate under which samples start getting chopped seems to be 1524, at least for the length of signal I quickly looked at. For example:

This is starting to sound like something amiss in rubberband itself, and not pyrb?

@markostam
Copy link
Author

markostam commented May 4, 2018

I'd agree with that assessment.

Does anyone know what rubberband is using under the hood? Some PSOLA variant or a phase vocoder?

@bmcfee
Copy link
Owner

bmcfee commented May 4, 2018

It's open-source: https://bitbucket.org/breakfastquay/rubberband/ but the documentation/comments are a bit thin. I don't have the bandwidth to pick it apart right now.

@markostam
Copy link
Author

I should probably also add a link the issue this PR was meant to address #13

@jongwook
Copy link

jongwook commented May 8, 2018

It hangs with the Cython version as well,

In [1]: import pyrubberband.rubberband as pyrb

In [2]: import numpy as np

In [3]: a=np.random.randn(10000)

In [4]: a
Out[4]:
array([ 0.31215944,  0.40128545, -1.52564994, ...,  1.40697364,
        1.81780644,  1.3080728 ])

In [5]: pyrb.pitch_shift(a, 200, 1, ['--debug', '3'])
RubberBandStretcher::Impl::Impl: rate = 200, options = 8208
configure: effective ratio = 1.05946
configure: analysis window size = 8, synthesis window size = 8, fft size = 8, increment = 0 (approx output increment = 0)
configure: outbuf size = 4096
Window area: 0.5; synthesis window area: 0.5
FFT::FFT(8): using implementation: vdsp
Resampler::Resampler: using Speex implementation with q = 4
Not real time mode: prefilling
configure: effective ratio = 1.05946
configure: analysis window size = 8, synthesis window size = 8, fft size = 8, increment = 0 (approx output increment = 0)
configure: outbuf size = 4096
Not real time mode: prefilling
configure: effective ratio = 1.05946
configure: analysis window size = 8, synthesis window size = 8, fft size = 8, increment = 0 (approx output increment = 0)
configure: outbuf size = 4096

I am also seeing that pyrb.pitch_shift(a, 200, 1, ['--window-long']) fixes the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants