aubio 0.4.9

Loading...
Searching...
No Matches
spectral/test-dct.c
#include <math.h>
#include "aubio.h"
#include "utils_tests.h"
int main (void)
{
int return_code = 0;
uint_t win_s = 32; // window size
uint_t i, j, n_iters = 10; // number of iterations
// create dct object
aubio_dct_t * dct = new_aubio_dct(win_s);
aubio_dct_t * tmp;
if (new_aubio_dct(0)) return 1;
fvec_t * in = new_fvec (win_s); // input buffer
fvec_t * dctout = new_fvec (win_s); // output buffer
fvec_t * out = new_fvec (win_s); // input buffer
if ((tmp = new_aubio_dct(1)) == 0) return 1;
//aubio_dct_do(tmp, dctout, out);
//aubio_dct_rdo(tmp, dctout, out);
del_aubio_dct(tmp);
if (!dct || !in || !dctout) {
return_code = 1;
return return_code;
}
in->data[0] = 1.;
for (i = 0; i < n_iters; i++) {
aubio_dct_do (dct, in, dctout);
aubio_dct_rdo (dct, dctout, out);
for (j = 0; j < in->length; j++) {
return_code += (fabsf(in->data[j] - out->data[j]) > 10.e-4);
}
}
fvec_print(in);
fvec_print(dctout);
fvec_print(out);
del_fvec(dctout);
del_fvec(in);
del_fvec(out);
del_aubio_dct(dct);
return return_code;
}
aubio.h
Global aubio include file.
aubio_dct_t
struct _aubio_dct_t aubio_dct_t
DCT object.
Definition dct.h:46
del_aubio_dct
void del_aubio_dct(aubio_dct_t *s)
delete DCT object
aubio_dct_rdo
void aubio_dct_rdo(aubio_dct_t *s, const fvec_t *input, fvec_t *idct_output)
compute backward DCT
aubio_dct_do
void aubio_dct_do(aubio_dct_t *s, const fvec_t *input, fvec_t *dct_output)
compute forward DCT
new_aubio_dct
aubio_dct_t * new_aubio_dct(uint_t size)
create new DCT computation object
new_fvec
fvec_t * new_fvec(uint_t length)
fvec_t buffer creation function
del_fvec
void del_fvec(fvec_t *s)
fvec_t buffer deletion function
fvec_print
void fvec_print(const fvec_t *s)
print out fvec data
fvec_t
Buffer for real data.
Definition fvec.h:67
fvec_t::data
smpl_t * data
data vector of length fvec_t.length
Definition fvec.h:69
fvec_t::length
uint_t length
length of buffer
Definition fvec.h:68
uint_t
unsigned int uint_t
unsigned integer
Definition types.h:60