I've been using soxr_clear() to reset the state of libsoxr as follows:
static soxr_t soxr = NULL;
void setup()
{
// If this is the first call to setup() then create a new soxr_t
if (soxr == NULL)
{
int irate = 44100;
int orate = 48000;
soxr_io_spec_t iospec = soxr_io_spec(SOXR_INT16_I, SOXR_INT16_I);
obuf = malloc(sizeof(short) * 2 * olen); // 2 channels
assert(obuf != NULL);
soxr = soxr_create(irate, orate, 2, &error, &iospec, NULL, NULL);
assert(!error);
}
// Clear the state of the soxr_t for a fresh signal
soxr_clear(soxr);
}
However, when I later call soxr_process() (similar to the streaming
example), I get a crash due to soxr->resamplers being NULL (which
happens as a result of the call to soxr_clear()).
Is this a bug, or am I misunderstanding how the soxr_clear() API is
supposed to be used?
Many thanks
Matt.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Matt, I think this is indeed a bug. The equivalent function in the libsamplerate-like interface does in fact work, but in any case the (intended) implementation doesn't do any thing cleverer than would just calling soxr_create again. Could this be a work-around for you? If not, please let me know, and I'll see if something better can be done. Cheers, Rob
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I've been using soxr_clear() to reset the state of libsoxr as follows:
static soxr_t soxr = NULL;
void setup()
{
// If this is the first call to setup() then create a new soxr_t
if (soxr == NULL)
{
int irate = 44100;
int orate = 48000;
}
However, when I later call soxr_process() (similar to the streaming
example), I get a crash due to soxr->resamplers being NULL (which
happens as a result of the call to soxr_clear()).
Is this a bug, or am I misunderstanding how the soxr_clear() API is
supposed to be used?
Many thanks
Matt.
Hi Matt, I think this is indeed a bug. The equivalent function in the libsamplerate-like interface does in fact work, but in any case the (intended) implementation doesn't do any thing cleverer than would just calling soxr_create again. Could this be a work-around for you? If not, please let me know, and I'll see if something better can be done. Cheers, Rob