SoXR crashes on the calling soxr_create if the input sampling rate is the same or very close to the output sampling rate.
soxr_io_spec_t const soxIOs = soxr_io_spec(SOXR_INT16_I, SOXR_FLOAT32_I); soxr_quality_spec_t const soxQs = soxr_quality_spec(SOXR_MQ, 0); soxr_runtime_spec_t const soxRTs = soxr_runtime_spec(1); soxr = soxr_create( static_cast<double> (sample->getSampleRate()), // 48000 static_cast<double> (output_sample_rate), // 48000 static_cast<unsigned>(sample->getChannelCount()), // 2 &soxr_error, &soxIOs, &soxQs, &soxRTs );
It was compiled with GCC 4.9.0. (distro: Arch Linux x64)
GDB backtrace; note the NaN on frame 2:
#0 0x00007ffff76e8f1b in _soxr_bessel_I_0 (x=-nan(0x8000000000000)) at .../soxr-0.1.1/src/dbesi0.c:143 #1 0x00007ffff76ea6aa in _soxr_make_lpf (num_taps=-1, Fc=0, beta=-nan(0x8000000000000), rho=0.5, scale=1) at .../soxr-0.1.1/src/filter.c:97 #2 0x00007ffff76eacb8 in _soxr_design_lpf (Fp=0, Fs=0, Fn=inf, att=102.35019852575361, num_taps=0x7fffffffd298, k=0, beta=-nan(0x8000000000000)) at .../soxr-0.1.1/src/filter.c:142 #3 0x00007ffff7720b88 in rate_init (p=0x6929c0, shared=0x692960, factor=1, bits=16, phase=50, passband_end=0.91505264245819784, stopband_begin=1, rolloff=rolloff_medium, maintain_3dB_pt=0, multiplier=3.0517578125e-05, use_hi_prec_clock=0, interpolator=-1, max_coefs_size=400, noSmallIntOpt=0, log2_min_dft_size=10, log2_large_dft_size=17) at .../soxr-0.1.1/src/rate.h:534 #4 0x00007ffff7721a5c in rate_create (channel=0x6929c0, shared=0x692960, io_ratio=1, q_spec=0x692838, r_spec=0x692888, scale=3.0517578125e-05) at .../soxr-0.1.1/src/rate.h:689 #5 0x00007ffff76e38ca in initialise (p=0x692820) at .../soxr-0.1.1/src/soxr.c:336 #6 0x00007ffff76e3a2b in soxr_set_io_ratio (p=0x692820, io_ratio=1, slew_len=0) at .../soxr-0.1.1/src/soxr.c:373 #7 0x00007ffff76e3522 in soxr_create (input_rate=48000, output_rate=48000, num_channels=2, error0=0x6947b8, io_spec=0x7fffffffd5e0, q_spec=0x7fffffffd620, runtime_spec=0x7fffffffd600) at .../soxr-0.1.1/src/soxr.c:265 ...
Thanks very much for this report — I think you've found a (the first?) bug in soxr.
As a temporary workaround, you could try something like:
bool workaround(fabs(sample->getSampleRate()/output_sample_rate - 1) < 1e-6);
and then:
soxr_quality_spec(workaround? SOXR_QQ : SOXR_MQ, 0);
Here is the probable fix for the library itself:
diff --git a/src/rate.h b/src/rate.h index 81cabff..06dcc3f 100644 --- a/src/rate.h +++ b/src/rate.h @@ -447,7 +447,7 @@ static char const * rate_init( p->num_stages = shift + have_pre_stage + have_arb_stage + have_post_stage; if (!p->num_stages && multiplier != 1) { - arbL = 0; + bits = arbL = 0; ++p->num_stages; } p->stages = calloc((size_t)p->num_stages + 1, sizeof(*p->stages));
Log in to post a comment.
SoXR crashes on the calling soxr_create if the input sampling rate is the same or very close to the output sampling rate.
It was compiled with GCC 4.9.0. (distro: Arch Linux x64)
GDB backtrace; note the NaN on frame 2:
Thanks very much for this report — I think you've found a (the first?) bug in soxr.
As a temporary workaround, you could try something like:
and then:
Here is the probable fix for the library itself: