examples/aubiopitch.c: add pitch_unit
[aubio.git] / examples / aubiopitch.c
index dd615bd..912aca8 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "utils.h"
 #define PROG_HAS_PITCH 1
+#define PROG_HAS_OUTPUT 1
+#define PROG_HAS_JACK 1
 #include "parse_args.h"
 
 aubio_pitch_t *o;
@@ -32,12 +34,12 @@ process_block(fvec_t * ibuf, fvec_t * obuf) {
   aubio_pitch_do (o, ibuf, pitch);
   smpl_t freq = fvec_read_sample(pitch, 0);
   aubio_wavetable_set_amp ( wavetable, aubio_level_lin (ibuf) );
-  if (freq != 0.0) {
-    aubio_wavetable_set_freq ( wavetable, freq );
-  } else {
-    aubio_wavetable_set_freq ( wavetable, 0.0 );
-  }
-  aubio_wavetable_do (wavetable, obuf, obuf);
+  aubio_wavetable_set_freq ( wavetable, freq );
+
+  if (mix_input)
+    aubio_wavetable_do (wavetable, ibuf, obuf);
+  else
+    aubio_wavetable_do (wavetable, obuf, obuf);
 }
 
 void
@@ -52,12 +54,14 @@ int main(int argc, char **argv) {
 
   verbmsg ("using source: %s at %dHz\n", source_uri, samplerate);
   verbmsg ("pitch method: %s, ", pitch_method);
+  verbmsg ("pitch unit: %s, ", pitch_unit);
   verbmsg ("buffer_size: %d, ", buffer_size);
   verbmsg ("hop_size: %d, ", hop_size);
   verbmsg ("tolerance: %f\n", pitch_tolerance);
 
   o = new_aubio_pitch (pitch_method, buffer_size, hop_size, samplerate);
   if (pitch_tolerance != 0.) aubio_pitch_set_tolerance (o, pitch_tolerance);
+  if (pitch_unit != NULL) aubio_pitch_set_unit (o, pitch_unit);
   pitch = new_fvec (1);
 
   wavetable = new_aubio_wavetable (samplerate, hop_size);