shithub: aubio

Download patch

ref: e24378a5aa0554c9958c61aca71d9a83a1198f64
parent: 941801f7c4c93778081c240175438cd4531f663f
author: Paul Brossier <piem@piem.org>
date: Tue Nov 13 04:15:35 EST 2007

examples/utils.{c,h}, examples/aubioonset.c: added process_flush function to get last onset at the end of file, added frames_delay parameter

--- a/examples/aubioonset.c
+++ b/examples/aubioonset.c
@@ -71,8 +71,8 @@
        * actual onset */
       if (isonset && output_filename == NULL) {
         if(frames >= 4) {
-          outmsg("%f\n",(frames-4)*overlap_size/(float)samplerate);
-        } else if (frames < 4) {
+          outmsg("%f\n",(frames-frames_delay)*overlap_size/(float)samplerate);
+        } else if (frames < frames_delay) {
           outmsg("%f\n",0.);
         }
       }
@@ -79,6 +79,7 @@
 }
 
 int main(int argc, char **argv) {
+  frames_delay = 4;
   examples_common_init(argc,argv);
   examples_common_process(aubio_process,process_print);
   examples_common_del();
--- a/examples/utils.c
+++ b/examples/utils.c
@@ -21,6 +21,7 @@
 int lash_main (void);
 void save_data (void);
 void restore_data(lash_config_t * lash_config);
+void flush_process(aubio_process_func_t process_func, aubio_print_func_t print);
 pthread_t lash_thread;
 #endif /* LASH_SUPPORT */
 
@@ -32,6 +33,7 @@
 int verbose = 0;
 int usejack = 0;
 int usedoubled = 1;
+int frames_delay = 0;
 
 
 /* energy,specdiff,hfc,complexdomain,phase */
@@ -394,6 +396,8 @@
     }
 
     debug("Processed %d frames of %d samples.\n", frames, buffer_size);
+
+    flush_process(process_func, print);
     del_aubio_sndfile(file);
 
     if (output_filename != NULL)
@@ -402,6 +406,18 @@
   }
 }
 
+void flush_process(aubio_process_func_t process_func, aubio_print_func_t print){
+  uint i,j;
+  for (i = 0; i < channels; i++) {
+    for (j = 0; j < obuf->length; j++) {
+      fvec_write_sample(obuf,0.,i,j);
+    }
+  }
+  for (i = 0; i < frames_delay; i++) {
+    process_func(ibuf->data, obuf->data, overlap_size);
+    print(); 
+  }
+}
 
 
 void send_noteon(int pitch, int velo)
--- a/examples/utils.h
+++ b/examples/utils.h
@@ -41,6 +41,7 @@
 extern int verbose;
 extern int usejack;
 extern int usedoubled;
+extern int frames_delay;
 extern unsigned int median;
 extern const char * output_filename;
 extern const char * input_filename;