From 0e0a049d1e2bd6633d92aa8436dff4ad78d3af39 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sun, 25 Oct 2009 21:33:24 +0100 Subject: [PATCH] examples/: simplify, use fvec_ funcs --- examples/aubiomfcc.c | 2 +- examples/aubioonset.c | 8 ++------ examples/aubiopitch.c | 6 ++---- examples/aubiotrack.c | 18 +++++------------- 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/examples/aubiomfcc.c b/examples/aubiomfcc.c index d7d1ebf3..4dc99951 100644 --- a/examples/aubiomfcc.c +++ b/examples/aubiomfcc.c @@ -70,7 +70,7 @@ static void process_print (void) { if (output_filename == NULL) { outmsg("%f\t",frames*overlap_size/(float)samplerate); for (coef_cnt = 0; coef_cnt < n_coefs; coef_cnt++) { - outmsg("%f ",mfcc_out->data[0][coef_cnt]); + outmsg("%f ", fvec_read_sample (mfcc_out, 0, coef_cnt) ); } outmsg("\n"); } diff --git a/examples/aubioonset.c b/examples/aubioonset.c index 9cd9654c..df081b65 100644 --- a/examples/aubioonset.c +++ b/examples/aubioonset.c @@ -40,13 +40,9 @@ static int aubio_process(smpl_t **input, smpl_t **output, int nframes) { /* block loop */ aubio_onset_do (o, ibuf, onset); if (fvec_read_sample(onset, 0, 0)) { - for (pos = 0; pos < overlap_size; pos++){ - obuf->data[0][pos] = woodblock->data[0][pos]; - } + fvec_copy (woodblock, obuf); } else { - for (pos = 0; pos < overlap_size; pos++) { - obuf->data[0][pos] = 0.; - } + fvec_zeros (obuf); } /* end of block loop */ pos = -1; /* so it will be zero next j loop */ diff --git a/examples/aubiopitch.c b/examples/aubiopitch.c index c362c019..d8b80465 100644 --- a/examples/aubiopitch.c +++ b/examples/aubiopitch.c @@ -41,12 +41,10 @@ static int aubio_process(smpl_t **input, smpl_t **output, int nframes) { aubio_pitch_do (o, ibuf, pitch); if (fvec_read_sample(pitch, 0, 0)) { for (pos = 0; pos < overlap_size; pos++){ - obuf->data[0][pos] = woodblock->data[0][pos]; + // TODO, play sine at this freq } } else { - for (pos = 0; pos < overlap_size; pos++) { - obuf->data[0][pos] = 0.; - } + fvec_zeros (obuf); } /* end of block loop */ pos = -1; /* so it will be zero next j loop */ diff --git a/examples/aubiotrack.c b/examples/aubiotrack.c index 8e9b84ed..b69ac4bc 100644 --- a/examples/aubiotrack.c +++ b/examples/aubiotrack.c @@ -41,20 +41,12 @@ static int aubio_process(smpl_t **input, smpl_t **output, int nframes) { if (pos == overlap_size-1) { /* block loop */ aubio_tempo_do (bt,ibuf,tempo_out); - if (tempo_out->data[0][0]>0) - istactus = tempo_out->data[0][0]; - else - istactus = 0; - if (tempo_out->data[0][1]>0) - isonset = tempo_out->data[0][0]; - else - isonset = 0; - if (istactus) { - for (pos = 0; pos < overlap_size; pos++) - obuf->data[0][pos] = woodblock->data[0][pos]; + istactus = fvec_read_sample (tempo_out, 0, 0); + isonset = fvec_read_sample (tempo_out, 0, 1); + if (istactus > 0.) { + fvec_copy (woodblock, obuf); } else { - for (pos = 0; pos < overlap_size; pos++) - obuf->data[0][pos] = 0.; + fvec_zeros (obuf); } /* end of block loop */ pos = -1; /* so it will be zero next j loop */ -- 2.26.2