pitchdetection.{c,h}: remove tabs
authorPaul Brossier <piem@piem.org>
Tue, 30 Oct 2007 02:01:30 +0000 (03:01 +0100)
committerPaul Brossier <piem@piem.org>
Tue, 30 Oct 2007 02:01:30 +0000 (03:01 +0100)
src/pitchdetection.c
src/pitchdetection.h

index 2a831043e83bbbb08c81af0149e7265d8b111db4..806c82996a3b6935dbd856909d47600b6b08a2b0 100644 (file)
@@ -14,7 +14,7 @@
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+   */
 
 #include "aubio_priv.h"
 #include "sample.h"
 #include "pitchyinfft.h"
 #include "pitchdetection.h"
 
-typedef smpl_t (*aubio_pitchdetection_func_t)(aubio_pitchdetection_t *p, 
-                fvec_t * ibuf);
-typedef smpl_t (*aubio_pitchdetection_conv_t)(smpl_t value,uint_t srate,uint_t bufsize);
+typedef smpl_t (*aubio_pitchdetection_func_t)
+  (aubio_pitchdetection_t *p, fvec_t * ibuf);
+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);
 
-smpl_t aubio_pitchdetection_mcomb(aubio_pitchdetection_t *p, fvec_t * ibuf);
-smpl_t aubio_pitchdetection_yin(aubio_pitchdetection_t *p, fvec_t *ibuf);
-smpl_t aubio_pitchdetection_schmitt(aubio_pitchdetection_t *p, fvec_t *ibuf);
-smpl_t aubio_pitchdetection_fcomb(aubio_pitchdetection_t *p, fvec_t *ibuf);
-smpl_t aubio_pitchdetection_yinfft(aubio_pitchdetection_t *p, fvec_t *ibuf);
+smpl_t aubio_pitchdetection_mcomb   (aubio_pitchdetection_t *p, fvec_t *ibuf);
+smpl_t aubio_pitchdetection_yin     (aubio_pitchdetection_t *p, fvec_t *ibuf);
+smpl_t aubio_pitchdetection_schmitt (aubio_pitchdetection_t *p, fvec_t *ibuf);
+smpl_t aubio_pitchdetection_fcomb   (aubio_pitchdetection_t *p, fvec_t *ibuf);
+smpl_t aubio_pitchdetection_yinfft  (aubio_pitchdetection_t *p, fvec_t *ibuf);
 
 /** generic pitch detection structure */
 struct _aubio_pitchdetection_t {
@@ -63,183 +65,181 @@ struct _aubio_pitchdetection_t {
  * 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);
+  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 UNUSED,uint_t bufsize UNUSED){
-        return aubio_freqtomidi(f);
+  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 UNUSED,uint_t bufsize UNUSED){
-        return f;
+  return f;
 }
 
 aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize, 
-               uint_t hopsize, 
-               uint_t channels,
-               uint_t samplerate,
-               aubio_pitchdetection_type type,
-               aubio_pitchdetection_mode mode)
+    uint_t hopsize, 
+    uint_t channels,
+    uint_t samplerate,
+    aubio_pitchdetection_type type,
+    aubio_pitchdetection_mode mode)
 {
-       aubio_pitchdetection_t *p = AUBIO_NEW(aubio_pitchdetection_t);
-       p->srate = samplerate;
-       p->type = type;
-       p->mode = mode;
-       p->bufsize = bufsize;
-       switch(p->type) {
-               case aubio_pitch_yin:
-                       p->buf      = new_fvec(bufsize,channels);
-                       p->yin      = new_fvec(bufsize/2,channels);
-                        p->callback = aubio_pitchdetection_yin;
-                       p->yinthres = 0.15;
-                       break;
-               case aubio_pitch_mcomb:
-                       p->pv       = new_aubio_pvoc(bufsize, hopsize, channels);
-                       p->fftgrain = new_cvec(bufsize, channels);
-                       p->mcomb    = new_aubio_pitchmcomb(bufsize,hopsize,channels,samplerate);
-                       p->filter   = new_aubio_cdsgn_filter(samplerate);
-                        p->callback = aubio_pitchdetection_mcomb;
-                       break;
-                case aubio_pitch_fcomb:
-                       p->buf      = new_fvec(bufsize,channels);
-                        p->fcomb    = new_aubio_pitchfcomb(bufsize,hopsize,samplerate);
-                        p->callback = aubio_pitchdetection_fcomb;
-                        break;
-                case aubio_pitch_schmitt:
-                       p->buf      = new_fvec(bufsize,channels);
-                        p->schmitt  = new_aubio_pitchschmitt(bufsize,samplerate);
-                        p->callback = aubio_pitchdetection_schmitt;
-                        break;
-               case aubio_pitch_yinfft:
-                       p->buf      = new_fvec(bufsize,channels);
-                        p->yinfft   = new_aubio_pitchyinfft(bufsize);
-                        p->callback = aubio_pitchdetection_yinfft;
-                       p->yinthres = 0.85;
-                        break;
-                default:
-                        break;
-       }
-       switch(p->mode) {
-               case aubio_pitchm_freq:
-                        p->freqconv = freqconvpass;
-                        break;
-               case aubio_pitchm_midi:
-                        p->freqconv = freqconvmidi;
-                        break;
-               case aubio_pitchm_cent:
-                        /* bug: not implemented */
-                        p->freqconv = freqconvmidi;
-                        break;
-               case aubio_pitchm_bin:
-                        p->freqconv = freqconvbin;
-                        break;
-                default:
-                        break;
-        }
-       return p;
+  aubio_pitchdetection_t *p = AUBIO_NEW(aubio_pitchdetection_t);
+  p->srate = samplerate;
+  p->type = type;
+  p->mode = mode;
+  p->bufsize = bufsize;
+  switch(p->type) {
+    case aubio_pitch_yin:
+      p->buf      = new_fvec(bufsize,channels);
+      p->yin      = new_fvec(bufsize/2,channels);
+      p->callback = aubio_pitchdetection_yin;
+      p->yinthres = 0.15;
+      break;
+    case aubio_pitch_mcomb:
+      p->pv       = new_aubio_pvoc(bufsize, hopsize, channels);
+      p->fftgrain = new_cvec(bufsize, channels);
+      p->mcomb    = new_aubio_pitchmcomb(bufsize,hopsize,channels,samplerate);
+      p->filter   = new_aubio_cdsgn_filter(samplerate);
+      p->callback = aubio_pitchdetection_mcomb;
+      break;
+    case aubio_pitch_fcomb:
+      p->buf      = new_fvec(bufsize,channels);
+      p->fcomb    = new_aubio_pitchfcomb(bufsize,hopsize,samplerate);
+      p->callback = aubio_pitchdetection_fcomb;
+      break;
+    case aubio_pitch_schmitt:
+      p->buf      = new_fvec(bufsize,channels);
+      p->schmitt  = new_aubio_pitchschmitt(bufsize,samplerate);
+      p->callback = aubio_pitchdetection_schmitt;
+      break;
+    case aubio_pitch_yinfft:
+      p->buf      = new_fvec(bufsize,channels);
+      p->yinfft   = new_aubio_pitchyinfft(bufsize);
+      p->callback = aubio_pitchdetection_yinfft;
+      p->yinthres = 0.85;
+      break;
+    default:
+      break;
+  }
+  switch(p->mode) {
+    case aubio_pitchm_freq:
+      p->freqconv = freqconvpass;
+      break;
+    case aubio_pitchm_midi:
+      p->freqconv = freqconvmidi;
+      break;
+    case aubio_pitchm_cent:
+      /* bug: not implemented */
+      p->freqconv = freqconvmidi;
+      break;
+    case aubio_pitchm_bin:
+      p->freqconv = freqconvbin;
+      break;
+    default:
+      break;
+  }
+  return p;
 }
 
 void del_aubio_pitchdetection(aubio_pitchdetection_t * p) {
-       switch(p->type) {
-               case aubio_pitch_yin:
-                       del_fvec(p->yin);
-                       del_fvec(p->buf);
-                       break;
-               case aubio_pitch_mcomb:
-                       del_aubio_pvoc(p->pv);
-                       del_cvec(p->fftgrain);
-                       del_aubio_pitchmcomb(p->mcomb);
-                       break;
-                case aubio_pitch_schmitt:
-                       del_fvec(p->buf);
-                        del_aubio_pitchschmitt(p->schmitt);
-                        break;
-                case aubio_pitch_fcomb:
-                       del_fvec(p->buf);
-                        del_aubio_pitchfcomb(p->fcomb);
-                        break;
-                case aubio_pitch_yinfft:
-                       del_fvec(p->buf);
-                        del_aubio_pitchyinfft(p->yinfft);
-                        break;
-               default:
-                       break;
-       }
-       AUBIO_FREE(p);
+  switch(p->type) {
+    case aubio_pitch_yin:
+      del_fvec(p->yin);
+      del_fvec(p->buf);
+      break;
+    case aubio_pitch_mcomb:
+      del_aubio_pvoc(p->pv);
+      del_cvec(p->fftgrain);
+      del_aubio_pitchmcomb(p->mcomb);
+      break;
+    case aubio_pitch_schmitt:
+      del_fvec(p->buf);
+      del_aubio_pitchschmitt(p->schmitt);
+      break;
+    case aubio_pitch_fcomb:
+      del_fvec(p->buf);
+      del_aubio_pitchfcomb(p->fcomb);
+      break;
+    case aubio_pitch_yinfft:
+      del_fvec(p->buf);
+      del_aubio_pitchyinfft(p->yinfft);
+      break;
+    default:
+      break;
+  }
+  AUBIO_FREE(p);
 }
 
 void aubio_pitchdetection_slideblock(aubio_pitchdetection_t *p, fvec_t *ibuf){
-        uint_t i,j = 0, overlap_size = 0;
-        overlap_size = p->buf->length-ibuf->length;
-        for (i=0;i<p->buf->channels;i++){
-                for (j=0;j<overlap_size;j++){
-                        p->buf->data[i][j] = 
-                                p->buf->data[i][j+ibuf->length];
-                }
-        }
-        for (i=0;i<ibuf->channels;i++){
-                for (j=0;j<ibuf->length;j++){
-                        p->buf->data[i][j+overlap_size] = 
-                                ibuf->data[i][j];
-                }
-        }
+  uint_t i,j = 0, overlap_size = 0;
+  overlap_size = p->buf->length-ibuf->length;
+  for (i=0;i<p->buf->channels;i++){
+    for (j=0;j<overlap_size;j++){
+      p->buf->data[i][j] = p->buf->data[i][j+ibuf->length];
+    }
+  }
+  for (i=0;i<ibuf->channels;i++){
+    for (j=0;j<ibuf->length;j++){
+      p->buf->data[i][j+overlap_size] = ibuf->data[i][j];
+    }
+  }
 }
 
 void aubio_pitchdetection_set_yinthresh(aubio_pitchdetection_t *p, smpl_t thres) {
-        p->yinthres = thres;
+  p->yinthres = thres;
 }
 
 smpl_t aubio_pitchdetection(aubio_pitchdetection_t *p, fvec_t * ibuf) {
-        return p->freqconv(p->callback(p,ibuf),p->srate,p->bufsize);
+  return p->freqconv(p->callback(p,ibuf),p->srate,p->bufsize);
 }
 
 smpl_t aubio_pitchdetection_mcomb(aubio_pitchdetection_t *p, fvec_t *ibuf) {
-       smpl_t pitch = 0.;
-       aubio_filter_do(p->filter,ibuf);
-        aubio_pvoc_do(p->pv,ibuf,p->fftgrain);
-        pitch = aubio_pitchmcomb_detect(p->mcomb,p->fftgrain);
-        /** \bug should move the >0 check within aubio_bintofreq */
-        if (pitch>0.) {
-                pitch = aubio_bintofreq(pitch,p->srate,p->bufsize);
-        } else {
-                pitch = 0.;
-        }
-        return pitch;
+  smpl_t pitch = 0.;
+  aubio_filter_do(p->filter,ibuf);
+  aubio_pvoc_do(p->pv,ibuf,p->fftgrain);
+  pitch = aubio_pitchmcomb_detect(p->mcomb,p->fftgrain);
+  /** \bug should move the >0 check within aubio_bintofreq */
+  if (pitch>0.) {
+    pitch = aubio_bintofreq(pitch,p->srate,p->bufsize);
+  } else {
+    pitch = 0.;
+  }
+  return pitch;
 }
 
 smpl_t aubio_pitchdetection_yin(aubio_pitchdetection_t *p, fvec_t *ibuf) {
-       smpl_t pitch = 0.;
-        aubio_pitchdetection_slideblock(p,ibuf);
-        pitch = aubio_pitchyin_getpitchfast(p->buf,p->yin, p->yinthres);
-        if (pitch>0) {
-                pitch = p->srate/(pitch+0.);
-        } else {
-                pitch = 0.;
-        }
-        return pitch;
+  smpl_t pitch = 0.;
+  aubio_pitchdetection_slideblock(p,ibuf);
+  pitch = aubio_pitchyin_getpitchfast(p->buf,p->yin, p->yinthres);
+  if (pitch>0) {
+    pitch = p->srate/(pitch+0.);
+  } else {
+    pitch = 0.;
+  }
+  return pitch;
 }
 
 
 smpl_t aubio_pitchdetection_yinfft(aubio_pitchdetection_t *p, fvec_t *ibuf){
-       smpl_t pitch = 0.;
-       aubio_pitchdetection_slideblock(p,ibuf);
-       pitch = aubio_pitchyinfft_detect(p->yinfft,p->buf,p->yinthres);
-        if (pitch>0) {
-                pitch = p->srate/(pitch+0.);
-        } else {
-                pitch = 0.;
-        }
-       return pitch; 
+  smpl_t pitch = 0.;
+  aubio_pitchdetection_slideblock(p,ibuf);
+  pitch = aubio_pitchyinfft_detect(p->yinfft,p->buf,p->yinthres);
+  if (pitch>0) {
+    pitch = p->srate/(pitch+0.);
+  } else {
+    pitch = 0.;
+  }
+  return pitch; 
 }
 
 smpl_t aubio_pitchdetection_fcomb(aubio_pitchdetection_t *p, fvec_t *ibuf){
-        aubio_pitchdetection_slideblock(p,ibuf);
-        return aubio_pitchfcomb_detect(p->fcomb,p->buf);
+  aubio_pitchdetection_slideblock(p,ibuf);
+  return aubio_pitchfcomb_detect(p->fcomb,p->buf);
 }
 
 smpl_t aubio_pitchdetection_schmitt(aubio_pitchdetection_t *p, fvec_t *ibuf){
-        aubio_pitchdetection_slideblock(p,ibuf);
-        return aubio_pitchschmitt_detect(p->schmitt,p->buf);
+  aubio_pitchdetection_slideblock(p,ibuf);
+  return aubio_pitchschmitt_detect(p->schmitt,p->buf);
 }
index 92e760fe627ff35d138cb8d0510456b78e61def3..164b1f53738cf125d8e618ec3d6fc21c3f926550 100644 (file)
@@ -14,7 +14,7 @@
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+   */
 
 #ifndef PITCHAUTOTCORR_H
 #define PITCHAUTOTCORR_H
@@ -25,7 +25,7 @@ extern "C" {
 
 /** \file
 
-  Generic method for pitch detection  
+  Generic method for pitch detection
 
   This file creates the objects required for the computation of the selected
   pitch detection algorithm and output the results, in midi note or Hz.
@@ -34,65 +34,65 @@ extern "C" {
 
 /** pitch detection algorithm */
 typedef enum {
-        aubio_pitch_yin,     /**< YIN algorithm */
-        aubio_pitch_mcomb,   /**< Multi-comb filter */
-        aubio_pitch_schmitt, /**< Schmitt trigger */
-        aubio_pitch_fcomb,   /**< Fast comb filter */
-        aubio_pitch_yinfft   /**< Spectral YIN */
+  aubio_pitch_yin,     /**< YIN algorithm */
+  aubio_pitch_mcomb,   /**< Multi-comb filter */
+  aubio_pitch_schmitt, /**< Schmitt trigger */
+  aubio_pitch_fcomb,   /**< Fast comb filter */
+  aubio_pitch_yinfft   /**< Spectral YIN */
 } aubio_pitchdetection_type;
 
 /** pitch detection output mode */
 typedef enum {
-        aubio_pitchm_freq,   /**< Frequency (Hz) */
-        aubio_pitchm_midi,   /**< MIDI note (0.,127) */
-        aubio_pitchm_cent,   /**< Cent */
-        aubio_pitchm_bin     /**< Frequency bin (0,bufsize) */
+  aubio_pitchm_freq,   /**< Frequency (Hz) */
+  aubio_pitchm_midi,   /**< MIDI note (0.,127) */
+  aubio_pitchm_cent,   /**< Cent */
+  aubio_pitchm_bin     /**< Frequency bin (0,bufsize) */
 } aubio_pitchdetection_mode;
 
 /** pitch detection object */
 typedef struct _aubio_pitchdetection_t aubio_pitchdetection_t;
 
 /** execute pitch detection on an input signal frame
+
   \param p pitch detection object as returned by new_aubio_pitchdetection
-  \param ibuf input signal of length hopsize 
+  \param ibuf input signal of length hopsize
+
 */
 smpl_t aubio_pitchdetection(aubio_pitchdetection_t * p, fvec_t * ibuf);
 
 /** change yin or yinfft tolerance threshold
-  
+
   default is 0.15 for yin and 0.85 for yinfft
+
 */
 void aubio_pitchdetection_set_yinthresh(aubio_pitchdetection_t *p, smpl_t thres);
 
 /** deletion of the pitch detection object
+
   \param p pitch detection object as returned by new_aubio_pitchdetection
+
 */
 void del_aubio_pitchdetection(aubio_pitchdetection_t * p);
 
 /** creation of the pitch detection object
-  \param bufsize size of the input buffer to analyse 
-  \param hopsize step size between two consecutive analysis instant 
+
+  \param bufsize size of the input buffer to analyse
+  \param hopsize step size between two consecutive analysis instant
   \param channels number of channels to analyse
-  \param samplerate sampling rate of the signal 
+  \param samplerate sampling rate of the signal
   \param type set pitch detection algorithm
   \param mode set pitch units for output
+
 */
-aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize, 
-        uint_t hopsize, 
-        uint_t channels,
-        uint_t samplerate,
-        aubio_pitchdetection_type type,
-        aubio_pitchdetection_mode mode);
+aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize,
+    uint_t hopsize,
+    uint_t channels,
+    uint_t samplerate,
+    aubio_pitchdetection_type type,
+    aubio_pitchdetection_mode mode);
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /*PITCHDETECTION_H*/ 
+#endif /*PITCHDETECTION_H*/