wrapper functions to add pitchm_bin output
authorPaul Brossier <piem@altern.org>
Mon, 22 Aug 2005 22:53:38 +0000 (22:53 +0000)
committerPaul Brossier <piem@altern.org>
Mon, 22 Aug 2005 22:53:38 +0000 (22:53 +0000)
src/pitchdetection.c

index 67cb6b4434a7d89ace82feeb1cdb13ab5e6392e5..6b661000ef6ed87c1036d291cd0ec4bcd5af8063 100644 (file)
 #include "pitchschmitt.h"
 #include "pitchdetection.h"
 
-smpl_t freqconvpass(smpl_t f);
-smpl_t freqconvpass(smpl_t f){
-        return f;
-}
-
 typedef smpl_t (*aubio_pitchdetection_func_t)(aubio_pitchdetection_t *p, 
                 fvec_t * ibuf);
-typedef smpl_t (*aubio_pitchdetection_conv_t)(smpl_t value);
+typedef smpl_t (*aubio_pitchdetection_conv_t)(smpl_t value,uint_t srate,uint_t bufsize);
 void aubio_pitchdetection_slideblock(aubio_pitchdetection_t *p, fvec_t *ibuf);
 
 struct _aubio_pitchdetection_t {
@@ -56,6 +51,23 @@ struct _aubio_pitchdetection_t {
         aubio_pitchdetection_conv_t freqconv;
 };
 
+/* convenience wrapper function for frequency unit conversions 
+ * should probably be rewritten with #defines */
+smpl_t freqconvbin(smpl_t f,uint_t srate,uint_t bufsize);
+smpl_t freqconvbin(smpl_t f,uint_t srate,uint_t bufsize){
+        return aubio_freqtobin(f,srate,bufsize);
+}
+
+smpl_t freqconvmidi(smpl_t f,uint_t srate,uint_t bufsize);
+smpl_t freqconvmidi(smpl_t f,uint_t srate,uint_t bufsize){
+        return aubio_freqtomidi(f);
+}
+
+smpl_t freqconvpass(smpl_t f,uint_t srate,uint_t bufsize);
+smpl_t freqconvpass(smpl_t f,uint_t srate,uint_t bufsize){
+        return f;
+}
+
 aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize, 
                uint_t hopsize, 
                uint_t channels,
@@ -98,15 +110,14 @@ aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize,
                         p->freqconv = freqconvpass;
                         break;
                case aubio_pitchm_midi:
-                        p->freqconv = aubio_freqtomidi;
+                        p->freqconv = freqconvmidi;
                         break;
                case aubio_pitchm_cent:
                         /** bug: not implemented */
-                        p->freqconv = freqconvpass;
+                        p->freqconv = freqconvmidi;
                         break;
                case aubio_pitchm_bin:
-                        /** bug: not implemented */
-                        p->freqconv = freqconvpass;
+                        p->freqconv = freqconvbin;
                         break;
                 default:
                         break;
@@ -157,7 +168,7 @@ void aubio_pitchdetection_slideblock(aubio_pitchdetection_t *p, fvec_t *ibuf){
 }
 
 smpl_t aubio_pitchdetection(aubio_pitchdetection_t *p, fvec_t * ibuf) {
-        return p->freqconv(p->callback(p,ibuf));
+        return p->freqconv(p->callback(p,ibuf),p->srate,p->bufsize);
 }
 
 smpl_t aubio_pitchdetection_mcomb(aubio_pitchdetection_t *p, fvec_t *ibuf) {