On Wed, Feb 12, 2014 at 06:29:24PM -0200, André Garnier Coutinho wrote:
I'm attaching the code that I wrote, I would be
very happy if anyone could
say what I am doing wrong.
#ifdef TRY1
int z1 = over.inpsize()/2 - 1;
int z2 = over.inpsize()/2;
over.inp_count = z1;
over.inp_data = 0;
over.out_count = n_samples * n_over;
over.out_data = buffer_over;
over.process ();
over.inp_count = n_samples;
over.inp_data = buffer;
// The following line is not necessary, but it doesn't
// harm since no output samples have been produced yet.
// If you keep this line, it would be logical to write
// 'out_count' as well. But neither is necessary.
over.out_data = buffer_over;
over.process();
over.inp_count = z2;
over.inp_data = 0;
// This is wrong: you _overwrite_ the samples already
// output. Just delete this line.
over.out_data = buffer_over;
over.process ();
#endif
With the line indicated above deleted you will get the
correct output. The strange looking transient at the end
*is* correct, you get this because the input signal stops
with a sharp step. The 'ringing' is just the result of
the bandwidth being lower than Fs_out / 2.
Note: process() modifies 'inp_data' and 'out_data'. On
return both will point to the first unused sample. If
either buffer is not fully used, you can just continue
with it for the next process(). Or you can provide a
new one, that's up to you. But if you reset the output
buffer as you did, you need of course to read it first.
Ciao,
--
FA
A world of exhaustive, reliable metadata would be an utopia.
It's also a pipe-dream, founded on self-delusion, nerd hubris
and hysterically inflated market opportunities. (Cory Doctorow)