Hey guys,

I've read the API documentation and I realize that I wasn't completing the
input buffer with some zeros. So, I tried to add those zeros, but I'm still
having an unexpected output.

I'm attaching the code that I wrote, I would be very happy if anyone could
say what I am doing wrong.

greets,

André



2014-02-07 21:50 GMT-02:00 Fons Adriaensen <f...@linuxaudio.org>:

> On Sat, Feb 08, 2014 at 12:00:56AM +0100, Robin Gareus wrote:
>
> > I'm sorry. It turns out, I only got this half right (wrong number of
> > samples to line things up). Just read the API documenation, explains it
> > all:
> >
> http://kokkinizita.linuxaudio.org/linuxaudio/zita-resampler/resampler.html
>
> I've just updated this with the latest version (which comes
> with the sources as well).
>
> Indeed, the API documentation explains it all.
>
> 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)
>
> _______________________________________________
> Linux-audio-dev mailing list
> Linux-audio-dev@lists.linuxaudio.org
> http://lists.linuxaudio.org/listinfo/linux-audio-dev
>
#include <iostream>
#include <fstream>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include "resampler.h"

#define TRY1
//#define TRY2
//#define TRY3

using namespace std;

typedef float sample_t;

int main(void)
{
    cout << "OverSample Test" << endl;

    const uint32_t samplerate = 44100, n_over = 2;
    const uint32_t n_samples = 256;

    sample_t *buffer, *buffer_over, freq_Hz = 1000;
    buffer = (sample_t *) malloc(sizeof(sample_t) * n_samples);
    buffer_over = (sample_t *) malloc(sizeof(sample_t) * n_samples * n_over);
    
    //SinWave
    for (uint32_t i = 0; i< n_samples ; i++)
    {
		buffer[i] = sin(2*M_PI*freq_Hz*i/samplerate);
	}
    
    for (uint32_t i = 0; i<n_samples; i++)
    {
		cout << "buffer[" << i << "] = " << buffer[i] << ";" <<  endl;
	}

    Resampler over;
    over.setup(samplerate, n_over*samplerate, 1, 96);
 
#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;
    over.out_data = buffer_over;
    over.process();
    
    over.inp_count = z2;
	over.inp_data = 0;
	over.out_data = buffer_over;
	over.process ();
    
#endif

#ifdef TRY2    
    int z1 = over.inpsize() - 1;
	
	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;
    over.out_data = buffer_over;
    over.process();
    
#endif

#ifdef TRY3
	int z2 = over.inpsize() - 1;
    
	cout << over.inpsize() << endl;
    
    over.inp_count = n_samples;
    over.out_count = n_samples*n_over;
    over.inp_data = buffer;
    over.out_data = buffer_over;
    over.process();
    
    over.inp_count = z2;
	over.inp_data = 0;
	over.out_data = buffer_over;
	over.process ();
    
#endif
    
    for (uint32_t i = 0; i< n_over*n_samples; i++)
    {
		cout << "buffer_over[" << i+1 << "] = " << buffer_over[i] << ";" << endl;
	}
	

    return 0;
}
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev

Reply via email to