On 02/07/2014 11:26 PM, André Garnier Coutinho wrote: > Hi Guys! > > I was doing some tests to learn how to use zita resampler and I got an > unexpected output. All the last positions of my output vector were 0 and I > don't know why. > [..] > Does anyone know what I am doing wrong?
Fons may have a detailed explanation. In code where I use zita-resampler I do initially feed it with a cycle of zeroes. Doing the same fixes the behaviour in your code. see also <zita-resampler-src>/apps/zresample.cc it also has a // Insert zero samples at start. > I'm attaching my code. I'm attaching a quick diff :) Cheers! robin PS. over.setup(..., 16) is rather poor quality.
--- a/main.cpp 2014-02-07 23:38:34.479692524 +0100 +++ b/main.cpp 2014-02-07 23:47:45.346424129 +0100 @@ -34,8 +34,22 @@ cout << "buffer[" << i << "] = " << buffer[i] << endl; } + Resampler over; over.setup(samplerate, n_over*samplerate, 1, 16); + + /* initialize resampler */ +#define RSZ_INIT_SIZE (n_samples) + float *zeroes = (float*) calloc(RSZ_INIT_SIZE, sizeof(float)); + float *scratch = (float*) calloc(n_over * RSZ_INIT_SIZE, sizeof(float)); + over.inp_count = RSZ_INIT_SIZE; + over.inp_data = zeroes; + over.out_count = RSZ_INIT_SIZE * n_over; + over.out_data = scratch; + over.process (); + free(zeroes); + free(scratch); + over.inp_count = n_samples; over.out_count = n_samples*n_over; over.inp_data = buffer;
_______________________________________________ Linux-audio-dev mailing list Linux-audio-dev@lists.linuxaudio.org http://lists.linuxaudio.org/listinfo/linux-audio-dev