From: Paul Brossier Date: Tue, 13 Nov 2007 08:15:35 +0000 (+0100) Subject: examples/utils.{c,h}, examples/aubioonset.c: added process_flush function to get... X-Git-Tag: bzr2git~458 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e24378a5aa0554c9958c61aca71d9a83a1198f64;p=aubio.git examples/utils.{c,h}, examples/aubioonset.c: added process_flush function to get last onset at the end of file, added frames_delay parameter --- diff --git a/examples/aubioonset.c b/examples/aubioonset.c index 880526f3..ab8374fa 100644 --- a/examples/aubioonset.c +++ b/examples/aubioonset.c @@ -71,14 +71,15 @@ void process_print (void) { * 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.); } } } int main(int argc, char **argv) { + frames_delay = 4; examples_common_init(argc,argv); examples_common_process(aubio_process,process_print); examples_common_del(); diff --git a/examples/utils.c b/examples/utils.c index 0a676068..3af049a9 100644 --- a/examples/utils.c +++ b/examples/utils.c @@ -21,6 +21,7 @@ void * lash_thread_main (void * data); 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 frames = 0; int verbose = 0; int usejack = 0; int usedoubled = 1; +int frames_delay = 0; /* energy,specdiff,hfc,complexdomain,phase */ @@ -394,6 +396,8 @@ void examples_common_process(aubio_process_func_t process_func, aubio_print_func } 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 examples_common_process(aubio_process_func_t process_func, aubio_print_func } } +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) diff --git a/examples/utils.h b/examples/utils.h index d4d02235..047b0a57 100644 --- a/examples/utils.h +++ b/examples/utils.h @@ -41,6 +41,7 @@ extern int frames; 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;