shithub: aubio

Download patch

ref: 0e0a049d1e2bd6633d92aa8436dff4ad78d3af39
parent: a17e8c94786ad30bf06e6435894279e4f71b2f38
author: Paul Brossier <piem@piem.org>
date: Sun Oct 25 17:33:24 EDT 2009

examples/: simplify, use fvec_ funcs

--- a/examples/aubiomfcc.c
+++ b/examples/aubiomfcc.c
@@ -70,7 +70,7 @@
       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");
       }
--- a/examples/aubioonset.c
+++ b/examples/aubioonset.c
@@ -40,13 +40,9 @@
       /* 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 */
--- a/examples/aubiopitch.c
+++ b/examples/aubiopitch.c
@@ -41,12 +41,10 @@
       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 */
--- a/examples/aubiotrack.c
+++ b/examples/aubiotrack.c
@@ -41,20 +41,12 @@
     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 */