examples/aubio{trac,onset}.c: add silence option
authorPaul Brossier <piem@piem.org>
Sun, 8 Dec 2013 01:14:09 +0000 (20:14 -0500)
committerPaul Brossier <piem@piem.org>
Sun, 8 Dec 2013 01:14:09 +0000 (20:14 -0500)
examples/aubionotes.c
examples/aubioonset.c
examples/aubioquiet.c
examples/aubiotrack.c
examples/parse_args.h
examples/utils.c

index dc57ce8..fd8278e 100644 (file)
@@ -57,7 +57,7 @@ process_block(fvec_t *ibuf, fvec_t *obuf) {
   }
 
   /* curlevel is negatif or 1 if silence */
-  smpl_t curlevel = aubio_level_detection(ibuf, silence);
+  smpl_t curlevel = aubio_level_detection(ibuf, silence_threshold);
   if (fvec_read_sample(onset, 0)) {
     /* test for silence */
     if (curlevel == 1.) {
index d8c7987..09ce0e4 100644 (file)
 aubio_onset_t *o;
 aubio_wavetable_t *wavetable;
 fvec_t *onset;
+smpl_t is_onset;
+uint_t is_silence = 0.;
 
 void
 process_block(fvec_t *ibuf, fvec_t *obuf) {
   fvec_zeros(obuf);
   aubio_onset_do (o, ibuf, onset);
-  if ( fvec_read_sample(onset, 0) ) {
+  if (silence_threshold != -90.)
+    is_silence = aubio_silence_detection(ibuf, silence_threshold);
+  is_onset = fvec_read_sample(onset, 0);
+  if ( is_onset && !is_silence ) {
     aubio_wavetable_play ( wavetable );
   } else {
     aubio_wavetable_stop ( wavetable );
@@ -46,8 +51,7 @@ process_block(fvec_t *ibuf, fvec_t *obuf) {
 void
 process_print (void)
 {
-  smpl_t onset_found = fvec_read_sample (onset, 0);
-  if (onset_found) {
+  if ( is_onset && !is_silence ) {
     outmsg ("%f\n", aubio_onset_get_last_s (o) );
   }
 }
@@ -59,6 +63,7 @@ int main(int argc, char **argv) {
   verbmsg ("onset method: %s, ", onset_method);
   verbmsg ("buffer_size: %d, ", buffer_size);
   verbmsg ("hop_size: %d, ", hop_size);
+  verbmsg ("threshold: %f, ", silence_threshold);
   verbmsg ("threshold: %f\n", onset_threshold);
 
   o = new_aubio_onset (onset_method, buffer_size, hop_size, samplerate);
index e1fbbfa..ba0d71d 100644 (file)
@@ -25,7 +25,7 @@ sint_t wassilence = 1, issilence;
 
 void process_block(fvec_t * ibuf, fvec_t * obuf) {
   fvec_zeros (obuf);
-  if (aubio_silence_detection(ibuf, silence)==1) {
+  if (aubio_silence_detection(ibuf, silence_threshold)==1) {
     if (wassilence==1) issilence = 1;
     else issilence = 2;
     wassilence=1;
index 48d4cdc..83bd214 100644 (file)
 aubio_tempo_t * tempo;
 aubio_wavetable_t *wavetable;
 fvec_t * tempo_out;
-smpl_t istactus = 0;
-smpl_t isonset = 0;
+smpl_t is_beat = 0;
+smpl_t is_onset = 0;
+uint_t is_silence = 0.;
 
 void process_block(fvec_t * ibuf, fvec_t *obuf) {
   aubio_tempo_do (tempo, ibuf, tempo_out);
-  istactus = fvec_read_sample (tempo_out, 0);
-  isonset = fvec_read_sample (tempo_out, 1);
+  is_beat = fvec_read_sample (tempo_out, 0);
+  is_onset = fvec_read_sample (tempo_out, 1);
+  if (silence_threshold != -90.)
+    is_silence = aubio_silence_detection(ibuf, silence_threshold);
   fvec_zeros (obuf);
-  if (istactus > 0.) {
+  if ( is_beat && !is_silence ) {
     aubio_wavetable_play ( wavetable );
   } else {
     aubio_wavetable_stop ( wavetable );
@@ -47,10 +50,10 @@ void process_block(fvec_t * ibuf, fvec_t *obuf) {
 }
 
 void process_print (void) {
-  if (istactus) {
+  if ( is_beat && !is_silence ) {
     outmsg("%f\n", aubio_tempo_get_last_s(tempo) );
   }
-  //if (isonset && verbose)
+  //if ( is_onset )
   //  outmsg(" \t \t%f\n",(blocks)*hop_size/(float)samplerate);
 }
 
index 1ab652e..1f22799 100644 (file)
@@ -37,7 +37,7 @@ extern smpl_t pitch_tolerance;
 // tempo stuff
 extern char_t * tempo_method;
 // more general stuff
-extern smpl_t silence;
+extern smpl_t silence_threshold;
 extern uint_t mix_input;
 
 typedef int (*aubio_process_func_t)(fvec_t * input, fvec_t * output);
@@ -183,7 +183,7 @@ parse_args (int argc, char **argv)
         pitch_tolerance = (smpl_t) atof (optarg);
         break;
       case 's':                /* silence threshold */
-        silence = (smpl_t) atof (optarg);
+        silence_threshold = (smpl_t) atof (optarg);
         break;
       case 'm':                /* mix_input flag */
         mix_input = 1;
index 0987531..2c4c90e 100644 (file)
@@ -50,7 +50,7 @@ smpl_t pitch_tolerance = 0.0; // will be set if != 0.
 // tempo stuff
 char_t * tempo_method = "default";
 // more general stuff
-smpl_t silence = -90.;
+smpl_t silence_threshold = -90.;
 uint_t mix_input = 0;
 
 //