Menu

Clicking while resampling from 16kHz to 48kHz

2015-12-10
2015-12-11
  • Michael FIG

    Michael FIG - 2015-12-10

    Hi,

    Thanks for soxr, it (nearly) does what I want.

    I get random clicking/popping artifacts in the output buffer with the following initialization and soxr_process call. Is this a bug?

    soxr_io_spec_t io_spec = soxr_io_spec(SOXR_INT16_S, SOXR_INT16_S);
    soxr_quality_spec_t quality_spec = soxr_quality_spec(SOXR_HQ, 0);
    soxr_error_t err;
    soxr_ = soxr_create(16000, 48000, 2,
    

    &err, &io_spec, &quality_spec, NULL);

    int16_t obuf[2][olen];
    soxr_cbuf_t obufs[] = {obuf[0], obuf[1]};
    soxr_cbuf_t ibufs[] = {pcm_l, pcm_r}; // pcm_l and pcm_r are int16_t arrays.

    size_t nframes = 0;
    soxr_process(soxr, ibufs, nsamples, NULL,
    obufs, olen, &nframes);

    Thanks for any help you can offer,
    Michael.

     
    • Michael FIG

      Michael FIG - 2015-12-11

      My fault: it turns out my input stream is mono, so the pcm_r array contained garbage. Copying the pcm_l stream to the right stereo channel made it all turn out fine!

      Thanks,
      Michael.

       
  • robs

    robs - 2015-12-11

    Hi Michael, I'm afraid I can't spot any problem in the code above. Perhaps the problem is in some of the other code around the code you have posted?

    I'm not aware of any bug in soxr in this area. For example, using soxr example number 4 (which exercises split-channel I/O) with a test signal and your parameters above, the resultant spectrogram looks clean and as expected:

    sox -c2 -r16k -n 16.s16 synth 8 sin 0:8k sin 8k:0 gain -1
    ./4-split-channels 16000 48000 2 3 3 < 16.s16 > 48.s16
    sox -c2 -r48k 48.s16 -n spectrogram -wk -o 48.png
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.