From: Paul Brossier Date: Tue, 3 Nov 2009 15:14:03 +0000 (+0100) Subject: src/pitch/: indent X-Git-Tag: bzr2git~53 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fddfa647d845149f90a4116483d287487f4b841c;p=aubio.git src/pitch/: indent --- diff --git a/src/pitch/pitch.c b/src/pitch/pitch.c index 41844627..fd1944d7 100644 --- a/src/pitch/pitch.c +++ b/src/pitch/pitch.c @@ -35,7 +35,8 @@ #include "pitch/pitch.h" /** pitch detection algorithm */ -typedef enum { +typedef enum +{ aubio_pitcht_yin, /**< YIN algorithm */ aubio_pitcht_mcomb, /**< Multi-comb filter */ aubio_pitcht_schmitt, /**< Schmitt trigger */ @@ -45,7 +46,8 @@ typedef enum { } aubio_pitch_type; /** pitch detection output mode */ -typedef enum { +typedef enum +{ aubio_pitchm_freq, /**< Frequency (Hz) */ aubio_pitchm_midi, /**< MIDI note (0.,127) */ aubio_pitchm_cent, /**< Cent */ @@ -54,51 +56,58 @@ typedef enum { } aubio_pitch_mode; typedef void (*aubio_pitch_func_t) - (aubio_pitch_t *p, fvec_t * ibuf, fvec_t *obuf); + (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf); typedef smpl_t (*aubio_pitch_conv_t) (smpl_t value, uint_t srate, uint_t bufsize); -void aubio_pitch_slideblock(aubio_pitch_t *p, fvec_t *ibuf); +void aubio_pitch_slideblock (aubio_pitch_t * p, fvec_t * ibuf); -void aubio_pitch_do_mcomb (aubio_pitch_t *p, fvec_t *ibuf, fvec_t *obuf); -void aubio_pitch_do_yin (aubio_pitch_t *p, fvec_t *ibuf, fvec_t *obuf); -void aubio_pitch_do_schmitt (aubio_pitch_t *p, fvec_t *ibuf, fvec_t *obuf); -void aubio_pitch_do_fcomb (aubio_pitch_t *p, fvec_t *ibuf, fvec_t *obuf); -void aubio_pitch_do_yinfft (aubio_pitch_t *p, fvec_t *ibuf, fvec_t *obuf); +void aubio_pitch_do_mcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf); +void aubio_pitch_do_yin (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf); +void aubio_pitch_do_schmitt (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf); +void aubio_pitch_do_fcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf); +void aubio_pitch_do_yinfft (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf); /** generic pitch detection structure */ -struct _aubio_pitch_t { +struct _aubio_pitch_t +{ aubio_pitch_type type; /**< pitch detection mode */ aubio_pitch_mode mode; /**< pitch detection output mode */ uint_t srate; /**< samplerate */ uint_t bufsize; /**< buffer size */ - aubio_pitchmcomb_t * mcomb; /**< mcomb object */ - aubio_pitchfcomb_t * fcomb; /**< fcomb object */ - aubio_pitchschmitt_t * schmitt; /**< schmitt object */ - aubio_pitchyinfft_t * yinfft; /**< yinfft object */ - aubio_pitchyin_t * yin; /**< yinfft object */ - aubio_filter_t * filter; /**< filter */ - aubio_pvoc_t * pv; /**< phase vocoder for mcomb */ - cvec_t * fftgrain; /**< spectral frame for mcomb */ - fvec_t * buf; /**< temporary buffer for yin */ + aubio_pitchmcomb_t *mcomb; /**< mcomb object */ + aubio_pitchfcomb_t *fcomb; /**< fcomb object */ + aubio_pitchschmitt_t *schmitt; /**< schmitt object */ + aubio_pitchyinfft_t *yinfft; /**< yinfft object */ + aubio_pitchyin_t *yin; /**< yinfft object */ + aubio_filter_t *filter; /**< filter */ + aubio_pvoc_t *pv; /**< phase vocoder for mcomb */ + cvec_t *fftgrain; /**< spectral frame for mcomb */ + fvec_t *buf; /**< temporary buffer for yin */ aubio_pitch_func_t callback; /**< pointer to current pitch detection method */ - aubio_pitch_conv_t freqconv; /**< pointer to current pitch conversion method */ + aubio_pitch_conv_t freqconv; /**< pointer to current pitch conversion method */ }; /* 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 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 UNUSED,uint_t bufsize UNUSED){ - return aubio_freqtomidi(f); +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); } -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){ +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; } @@ -106,56 +115,57 @@ aubio_pitch_t * new_aubio_pitch (char_t * pitch_mode, uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate) { - aubio_pitch_t *p = AUBIO_NEW(aubio_pitch_t); + aubio_pitch_t *p = AUBIO_NEW (aubio_pitch_t); aubio_pitch_type pitch_type; if (strcmp (pitch_mode, "mcomb") == 0) - pitch_type = aubio_pitcht_mcomb; + pitch_type = aubio_pitcht_mcomb; else if (strcmp (pitch_mode, "yinfft") == 0) - pitch_type = aubio_pitcht_yin; + pitch_type = aubio_pitcht_yin; else if (strcmp (pitch_mode, "yin") == 0) - pitch_type = aubio_pitcht_yin; + pitch_type = aubio_pitcht_yin; else if (strcmp (pitch_mode, "schmitt") == 0) - pitch_type = aubio_pitcht_schmitt; + pitch_type = aubio_pitcht_schmitt; else if (strcmp (pitch_mode, "fcomb") == 0) - pitch_type = aubio_pitcht_fcomb; + pitch_type = aubio_pitcht_fcomb; else if (strcmp (pitch_mode, "default") == 0) - pitch_type = aubio_pitcht_default; + pitch_type = aubio_pitcht_default; else { - AUBIO_ERR ("unknown pitch detection method %s, using default.\n", pitch_mode); - pitch_type = aubio_pitcht_default; - return NULL; + AUBIO_ERR ("unknown pitch detection method %s, using default.\n", + pitch_mode); + pitch_type = aubio_pitcht_default; + return NULL; } p->srate = samplerate; p->type = pitch_type; aubio_pitch_set_unit (p, "default"); p->bufsize = bufsize; - switch(p->type) { + switch (p->type) { case aubio_pitcht_yin: - p->buf = new_fvec(bufsize,channels); - p->yin = new_aubio_pitchyin(bufsize); + p->buf = new_fvec (bufsize, channels); + p->yin = new_aubio_pitchyin (bufsize); p->callback = aubio_pitch_do_yin; aubio_pitchyin_set_tolerance (p->yin, 0.15); break; case aubio_pitcht_mcomb: - p->pv = new_aubio_pvoc(bufsize, hopsize, channels); - p->fftgrain = new_cvec(bufsize, channels); - p->mcomb = new_aubio_pitchmcomb(bufsize,hopsize,channels); - p->filter = new_aubio_filter_c_weighting (samplerate, channels); + p->pv = new_aubio_pvoc (bufsize, hopsize, channels); + p->fftgrain = new_cvec (bufsize, channels); + p->mcomb = new_aubio_pitchmcomb (bufsize, hopsize, channels); + p->filter = new_aubio_filter_c_weighting (samplerate, channels); p->callback = aubio_pitch_do_mcomb; break; case aubio_pitcht_fcomb: - p->buf = new_fvec(bufsize,channels); - p->fcomb = new_aubio_pitchfcomb(bufsize,hopsize,channels); + p->buf = new_fvec (bufsize, channels); + p->fcomb = new_aubio_pitchfcomb (bufsize, hopsize, channels); p->callback = aubio_pitch_do_fcomb; break; case aubio_pitcht_schmitt: - p->buf = new_fvec(bufsize,channels); - p->schmitt = new_aubio_pitchschmitt(bufsize); + p->buf = new_fvec (bufsize, channels); + p->schmitt = new_aubio_pitchschmitt (bufsize); p->callback = aubio_pitch_do_schmitt; break; case aubio_pitcht_yinfft: - p->buf = new_fvec(bufsize,channels); - p->yinfft = new_aubio_pitchyinfft(bufsize); + p->buf = new_fvec (bufsize, channels); + p->yinfft = new_aubio_pitchyinfft (bufsize); p->callback = aubio_pitch_do_yinfft; aubio_pitchyinfft_set_tolerance (p->yinfft, 0.85); break; @@ -165,69 +175,75 @@ new_aubio_pitch (char_t * pitch_mode, return p; } -void del_aubio_pitch(aubio_pitch_t * p) { - switch(p->type) { +void +del_aubio_pitch (aubio_pitch_t * p) +{ + switch (p->type) { case aubio_pitcht_yin: - del_fvec(p->buf); - del_aubio_pitchyin(p->yin); + del_fvec (p->buf); + del_aubio_pitchyin (p->yin); break; case aubio_pitcht_mcomb: - del_aubio_pvoc(p->pv); - del_cvec(p->fftgrain); - del_aubio_filter(p->filter); - del_aubio_pitchmcomb(p->mcomb); + del_aubio_pvoc (p->pv); + del_cvec (p->fftgrain); + del_aubio_filter (p->filter); + del_aubio_pitchmcomb (p->mcomb); break; case aubio_pitcht_schmitt: - del_fvec(p->buf); - del_aubio_pitchschmitt(p->schmitt); + del_fvec (p->buf); + del_aubio_pitchschmitt (p->schmitt); break; case aubio_pitcht_fcomb: - del_fvec(p->buf); - del_aubio_pitchfcomb(p->fcomb); + del_fvec (p->buf); + del_aubio_pitchfcomb (p->fcomb); break; case aubio_pitcht_yinfft: - del_fvec(p->buf); - del_aubio_pitchyinfft(p->yinfft); + del_fvec (p->buf); + del_aubio_pitchyinfft (p->yinfft); break; default: break; } - AUBIO_FREE(p); + AUBIO_FREE (p); } -void aubio_pitch_slideblock(aubio_pitch_t *p, fvec_t *ibuf){ - uint_t i,j = 0, overlap_size = 0; - overlap_size = p->buf->length-ibuf->length; - for (i=0;ibuf->channels;i++){ - for (j=0;jbuf->data[i][j] = p->buf->data[i][j+ibuf->length]; +void +aubio_pitch_slideblock (aubio_pitch_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;ichannels;i++){ - for (j=0;jlength;j++){ - p->buf->data[i][j+overlap_size] = ibuf->data[i][j]; + 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 aubio_pitch_set_unit (aubio_pitch_t *p, char_t * pitch_unit) { +uint_t +aubio_pitch_set_unit (aubio_pitch_t * p, char_t * pitch_unit) +{ aubio_pitch_mode pitch_mode; if (strcmp (pitch_unit, "freq") == 0) - pitch_mode = aubio_pitchm_freq; + pitch_mode = aubio_pitchm_freq; else if (strcmp (pitch_unit, "midi") == 0) - pitch_mode = aubio_pitchm_midi; + pitch_mode = aubio_pitchm_midi; else if (strcmp (pitch_unit, "cent") == 0) - pitch_mode = aubio_pitchm_cent; + pitch_mode = aubio_pitchm_cent; else if (strcmp (pitch_unit, "bin") == 0) - pitch_mode = aubio_pitchm_bin; + pitch_mode = aubio_pitchm_bin; else if (strcmp (pitch_unit, "default") == 0) - pitch_mode = aubio_pitchm_default; + pitch_mode = aubio_pitchm_default; else { - AUBIO_ERR ("unknown pitch detection unit %s, using default\n", pitch_unit); - pitch_mode = aubio_pitchm_default; + AUBIO_ERR ("unknown pitch detection unit %s, using default\n", pitch_unit); + pitch_mode = aubio_pitchm_default; } p->mode = pitch_mode; - switch(p->mode) { + switch (p->mode) { case aubio_pitchm_freq: p->freqconv = freqconvpass; break; @@ -247,8 +263,10 @@ uint_t aubio_pitch_set_unit (aubio_pitch_t *p, char_t * pitch_unit) { return AUBIO_OK; } -uint_t aubio_pitch_set_tolerance(aubio_pitch_t *p, smpl_t tol) { - switch(p->type) { +uint_t +aubio_pitch_set_tolerance (aubio_pitch_t * p, smpl_t tol) +{ + switch (p->type) { case aubio_pitcht_yin: aubio_pitchyin_set_tolerance (p->yin, tol); break; @@ -261,33 +279,39 @@ uint_t aubio_pitch_set_tolerance(aubio_pitch_t *p, smpl_t tol) { return AUBIO_OK; } -void aubio_pitch_do (aubio_pitch_t *p, fvec_t * ibuf, fvec_t *obuf) { +void +aubio_pitch_do (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf) +{ uint_t i; - p->callback(p, ibuf, obuf); + p->callback (p, ibuf, obuf); for (i = 0; i < obuf->channels; i++) { - p->freqconv(obuf->data[i][0],p->srate,p->bufsize); + p->freqconv (obuf->data[i][0], p->srate, p->bufsize); } } -void aubio_pitch_do_mcomb(aubio_pitch_t *p, fvec_t *ibuf, fvec_t * obuf) { +void +aubio_pitch_do_mcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf) +{ uint_t i; - aubio_filter_do(p->filter,ibuf); - aubio_pvoc_do(p->pv,ibuf,p->fftgrain); - aubio_pitchmcomb_do(p->mcomb,p->fftgrain, obuf); + aubio_filter_do (p->filter, ibuf); + aubio_pvoc_do (p->pv, ibuf, p->fftgrain); + aubio_pitchmcomb_do (p->mcomb, p->fftgrain, obuf); for (i = 0; i < obuf->channels; i++) { obuf->data[i][0] = aubio_bintofreq (obuf->data[i][0], p->srate, p->bufsize); } } -void aubio_pitch_do_yin(aubio_pitch_t *p, fvec_t *ibuf, fvec_t * obuf) { +void +aubio_pitch_do_yin (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf) +{ smpl_t pitch = 0.; uint_t i; - aubio_pitch_slideblock(p,ibuf); - aubio_pitchyin_do(p->yin,p->buf, obuf); + aubio_pitch_slideblock (p, ibuf); + aubio_pitchyin_do (p->yin, p->buf, obuf); for (i = 0; i < obuf->channels; i++) { pitch = obuf->data[i][0]; - if (pitch>0) { - pitch = p->srate/(pitch+0.); + if (pitch > 0) { + pitch = p->srate / (pitch + 0.); } else { pitch = 0.; } @@ -296,15 +320,17 @@ void aubio_pitch_do_yin(aubio_pitch_t *p, fvec_t *ibuf, fvec_t * obuf) { } -void aubio_pitch_do_yinfft(aubio_pitch_t *p, fvec_t *ibuf, fvec_t * obuf){ +void +aubio_pitch_do_yinfft (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf) +{ smpl_t pitch = 0.; uint_t i; - aubio_pitch_slideblock(p,ibuf); - aubio_pitchyinfft_do(p->yinfft,p->buf,obuf); + aubio_pitch_slideblock (p, ibuf); + aubio_pitchyinfft_do (p->yinfft, p->buf, obuf); for (i = 0; i < obuf->channels; i++) { pitch = obuf->data[i][0]; - if (pitch>0) { - pitch = p->srate/(pitch+0.); + if (pitch > 0) { + pitch = p->srate / (pitch + 0.); } else { pitch = 0.; } @@ -312,24 +338,28 @@ void aubio_pitch_do_yinfft(aubio_pitch_t *p, fvec_t *ibuf, fvec_t * obuf){ } } -void aubio_pitch_do_fcomb(aubio_pitch_t *p, fvec_t *ibuf, fvec_t * out){ +void +aubio_pitch_do_fcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out) +{ uint_t i; - aubio_pitch_slideblock(p,ibuf); - aubio_pitchfcomb_do(p->fcomb,p->buf, out); + aubio_pitch_slideblock (p, ibuf); + aubio_pitchfcomb_do (p->fcomb, p->buf, out); for (i = 0; i < out->channels; i++) { out->data[i][0] = aubio_bintofreq (out->data[i][0], p->srate, p->bufsize); } } -void aubio_pitch_do_schmitt(aubio_pitch_t *p, fvec_t *ibuf, fvec_t *out){ +void +aubio_pitch_do_schmitt (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out) +{ smpl_t period, pitch = 0.; uint_t i; - aubio_pitch_slideblock(p,ibuf); - aubio_pitchschmitt_do(p->schmitt,p->buf, out); + aubio_pitch_slideblock (p, ibuf); + aubio_pitchschmitt_do (p->schmitt, p->buf, out); for (i = 0; i < out->channels; i++) { period = out->data[i][0]; - if (period>0) { - pitch = p->srate/period; + if (period > 0) { + pitch = p->srate / period; } else { pitch = 0.; } diff --git a/src/pitch/pitch.h b/src/pitch/pitch.h index aa837779..31510670 100644 --- a/src/pitch/pitch.h +++ b/src/pitch/pitch.h @@ -44,8 +44,7 @@ typedef struct _aubio_pitch_t aubio_pitch_t; \param out output pitch candidates of size [1 x channes] */ -void aubio_pitch_do (aubio_pitch_t * o, fvec_t * in, - fvec_t * out); +void aubio_pitch_do (aubio_pitch_t * o, fvec_t * in, fvec_t * out); /** change yin or yinfft tolerance threshold @@ -53,8 +52,7 @@ void aubio_pitch_do (aubio_pitch_t * o, fvec_t * in, \param tol tolerance default is 0.15 for yin and 0.85 for yinfft */ -uint_t aubio_pitch_set_tolerance (aubio_pitch_t * o, - smpl_t tol); +uint_t aubio_pitch_set_tolerance (aubio_pitch_t * o, smpl_t tol); /** deletion of the pitch detection object @@ -72,7 +70,7 @@ void del_aubio_pitch (aubio_pitch_t * o); \param samplerate sampling rate of the signal */ -aubio_pitch_t * new_aubio_pitch (char_t * mode, +aubio_pitch_t *new_aubio_pitch (char_t * mode, uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate); /** set the output unit of the pitch detection object @@ -81,8 +79,7 @@ aubio_pitch_t * new_aubio_pitch (char_t * mode, \param mode set pitch units for output */ -uint_t aubio_pitch_set_unit (aubio_pitch_t * o, - char_t * mode); +uint_t aubio_pitch_set_unit (aubio_pitch_t * o, char_t * mode); #ifdef __cplusplus } diff --git a/src/pitch/pitchfcomb.c b/src/pitch/pitchfcomb.c index c9cb1c2d..2cf2758c 100644 --- a/src/pitch/pitchfcomb.c +++ b/src/pitch/pitchfcomb.c @@ -29,110 +29,114 @@ #define MAX_PEAKS 8 -typedef struct { +typedef struct +{ smpl_t bin; smpl_t db; } aubio_fpeak_t; -struct _aubio_pitchfcomb_t { +struct _aubio_pitchfcomb_t +{ uint_t fftSize; uint_t stepSize; uint_t rate; - fvec_t * winput; - fvec_t * win; - cvec_t * fftOut; - fvec_t * fftLastPhase; - aubio_fft_t * fft; + fvec_t *winput; + fvec_t *win; + cvec_t *fftOut; + fvec_t *fftLastPhase; + aubio_fft_t *fft; }; -aubio_pitchfcomb_t * new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize, uint_t channels) +aubio_pitchfcomb_t * +new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize, uint_t channels) { - aubio_pitchfcomb_t * p = AUBIO_NEW(aubio_pitchfcomb_t); - p->fftSize = bufsize; - p->stepSize = hopsize; - p->winput = new_fvec(bufsize,1); - p->fftOut = new_cvec(bufsize,1); - p->fftLastPhase = new_fvec(bufsize, channels); - p->fft = new_aubio_fft(bufsize, 1); - p->win = new_aubio_window("hanning", bufsize); + aubio_pitchfcomb_t *p = AUBIO_NEW (aubio_pitchfcomb_t); + p->fftSize = bufsize; + p->stepSize = hopsize; + p->winput = new_fvec (bufsize, 1); + p->fftOut = new_cvec (bufsize, 1); + p->fftLastPhase = new_fvec (bufsize, channels); + p->fft = new_aubio_fft (bufsize, 1); + p->win = new_aubio_window ("hanning", bufsize); return p; } /* input must be stepsize long */ -void aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, fvec_t * input, fvec_t * output) +void +aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, fvec_t * input, fvec_t * output) { uint_t i, k, l, maxharm = 0; - smpl_t phaseDifference = TWO_PI*(smpl_t)p->stepSize/(smpl_t)p->fftSize; + smpl_t phaseDifference = TWO_PI * (smpl_t) p->stepSize / (smpl_t) p->fftSize; aubio_fpeak_t peaks[MAX_PEAKS]; for (i = 0; i < input->channels; i++) { - for (k=0; klength; k++){ - p->winput->data[0][k] = p->win->data[0][k] * input->data[i][k]; - } - aubio_fft_do(p->fft,p->winput,p->fftOut); + for (k = 0; k < input->length; k++) { + p->winput->data[0][k] = p->win->data[0][k] * input->data[i][k]; + } + aubio_fft_do (p->fft, p->winput, p->fftOut); - for (k=0; k<=p->fftSize/2; k++) { - smpl_t - magnitude = 20.*LOG10(2.*p->fftOut->norm[0][k]/(smpl_t)p->fftSize), - phase = p->fftOut->phas[0][k], - tmp, bin; + for (k = 0; k <= p->fftSize / 2; k++) { + smpl_t + magnitude = + 20. * LOG10 (2. * p->fftOut->norm[0][k] / (smpl_t) p->fftSize), + phase = p->fftOut->phas[0][k], tmp, bin; - /* compute phase difference */ - tmp = phase - p->fftLastPhase->data[i][k]; - p->fftLastPhase->data[i][k] = phase; + /* compute phase difference */ + tmp = phase - p->fftLastPhase->data[i][k]; + p->fftLastPhase->data[i][k] = phase; - /* subtract expected phase difference */ - tmp -= (smpl_t)k*phaseDifference; + /* subtract expected phase difference */ + tmp -= (smpl_t) k *phaseDifference; - /* map delta phase into +/- Pi interval */ - tmp = aubio_unwrap2pi(tmp); + /* map delta phase into +/- Pi interval */ + tmp = aubio_unwrap2pi (tmp); - /* get deviation from bin frequency from the +/- Pi interval */ - tmp = p->fftSize/(smpl_t)p->stepSize*tmp/(TWO_PI); + /* get deviation from bin frequency from the +/- Pi interval */ + tmp = p->fftSize / (smpl_t) p->stepSize * tmp / (TWO_PI); - /* compute the k-th partials' true bin */ - bin = (smpl_t)k + tmp; + /* compute the k-th partials' true bin */ + bin = (smpl_t) k + tmp; - if (bin > 0.0 && magnitude > peaks[0].db) { // && magnitude < 0) { - memmove(peaks+1, peaks, sizeof(aubio_fpeak_t)*(MAX_PEAKS-1)); - peaks[0].bin = bin; - peaks[0].db = magnitude; + if (bin > 0.0 && magnitude > peaks[0].db) { // && magnitude < 0) { + memmove (peaks + 1, peaks, sizeof (aubio_fpeak_t) * (MAX_PEAKS - 1)); + peaks[0].bin = bin; + peaks[0].db = magnitude; + } } - } - k = 0; - for (l=1; l 0.0; l++) { - sint_t harmonic; - for (harmonic=5; harmonic>1; harmonic--) { - if (peaks[0].bin / peaks[l].bin < harmonic+.02 && - peaks[0].bin / peaks[l].bin > harmonic-.02) { - if (harmonic > (sint_t)maxharm && - peaks[0].db < peaks[l].db/2) { - maxharm = harmonic; - k = l; + k = 0; + for (l = 1; l < MAX_PEAKS && peaks[l].bin > 0.0; l++) { + sint_t harmonic; + for (harmonic = 5; harmonic > 1; harmonic--) { + if (peaks[0].bin / peaks[l].bin < harmonic + .02 && + peaks[0].bin / peaks[l].bin > harmonic - .02) { + if (harmonic > (sint_t) maxharm && peaks[0].db < peaks[l].db / 2) { + maxharm = harmonic; + k = l; + } } } } - } - output->data[i][0] = peaks[k].bin; - /* quick hack to clean output a bit */ - if (peaks[k].bin > 5000.) output->data[i][0] = 0.; + output->data[i][0] = peaks[k].bin; + /* quick hack to clean output a bit */ + if (peaks[k].bin > 5000.) + output->data[i][0] = 0.; } } -void del_aubio_pitchfcomb (aubio_pitchfcomb_t * p) +void +del_aubio_pitchfcomb (aubio_pitchfcomb_t * p) { - del_cvec(p->fftOut); - del_fvec(p->fftLastPhase); - del_fvec(p->win); - del_fvec(p->winput); - del_aubio_fft(p->fft); - AUBIO_FREE(p); + del_cvec (p->fftOut); + del_fvec (p->fftLastPhase); + del_fvec (p->win); + del_fvec (p->winput); + del_aubio_fft (p->fft); + AUBIO_FREE (p); } - diff --git a/src/pitch/pitchfcomb.h b/src/pitch/pitchfcomb.h index dbb36f5b..6e020dfd 100644 --- a/src/pitch/pitchfcomb.h +++ b/src/pitch/pitchfcomb.h @@ -49,7 +49,9 @@ typedef struct _aubio_pitchfcomb_t aubio_pitchfcomb_t; \param output pitch candidates in bins */ -void aubio_pitchfcomb_do (aubio_pitchfcomb_t *p, fvec_t * input, fvec_t * output); +void aubio_pitchfcomb_do (aubio_pitchfcomb_t * p, fvec_t * input, + fvec_t * output); + /** creation of the pitch detection object \param bufsize size of the input buffer to analyse @@ -57,14 +59,15 @@ void aubio_pitchfcomb_do (aubio_pitchfcomb_t *p, fvec_t * input, fvec_t * output \param channels number of channels to detect pitch on */ -aubio_pitchfcomb_t * new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize, uint_t channels); +aubio_pitchfcomb_t *new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize, + uint_t channels); + /** deletion of the pitch detection object \param p pitch detection object as returned by new_aubio_pitchfcomb */ -void del_aubio_pitchfcomb (aubio_pitchfcomb_t *p); - +void del_aubio_pitchfcomb (aubio_pitchfcomb_t * p); #ifdef __cplusplus } diff --git a/src/pitch/pitchmcomb.c b/src/pitch/pitchmcomb.c index ea225906..d49625fb 100644 --- a/src/pitch/pitchmcomb.c +++ b/src/pitch/pitchmcomb.c @@ -28,26 +28,32 @@ typedef struct _aubio_spectralpeak_t aubio_spectralpeak_t; typedef struct _aubio_spectralcandidate_t aubio_spectralcandidate_t; -uint_t aubio_pitchmcomb_get_root_peak(aubio_spectralpeak_t * peaks, uint_t length); -uint_t aubio_pitchmcomb_quadpick(aubio_spectralpeak_t * spectral_peaks, fvec_t * X); -void aubio_pitchmcomb_spectral_pp(aubio_pitchmcomb_t * p, fvec_t * oldmag); -void aubio_pitchmcomb_combdet(aubio_pitchmcomb_t * p, fvec_t * newmag); +uint_t aubio_pitchmcomb_get_root_peak (aubio_spectralpeak_t * peaks, + uint_t length); +uint_t aubio_pitchmcomb_quadpick (aubio_spectralpeak_t * spectral_peaks, + fvec_t * X); +void aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, fvec_t * oldmag); +void aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, fvec_t * newmag); /* not used but useful : sort by amplitudes (or anything else) * sort_pitchpeak(peaks, length); */ /** spectral_peak comparison function (must return signed int) */ -static sint_t aubio_pitchmcomb_sort_peak_comp(const void *x, const void *y); +static sint_t aubio_pitchmcomb_sort_peak_comp (const void *x, const void *y); /** sort spectral_peak against their mag */ -void aubio_pitchmcomb_sort_peak(aubio_spectralpeak_t * peaks, uint_t nbins); +void aubio_pitchmcomb_sort_peak (aubio_spectralpeak_t * peaks, uint_t nbins); /** select the best candidates */ -uint_t aubio_pitch_cands(aubio_pitchmcomb_t * p, cvec_t * fftgrain, smpl_t * cands); +uint_t aubio_pitch_cands (aubio_pitchmcomb_t * p, cvec_t * fftgrain, + smpl_t * cands); /** sort spectral_candidate against their comb ene */ -void aubio_pitchmcomb_sort_cand_ene(aubio_spectralcandidate_t ** candidates, uint_t nbins); +void aubio_pitchmcomb_sort_cand_ene (aubio_spectralcandidate_t ** candidates, + uint_t nbins); /** sort spectral_candidate against their frequency */ -void aubio_pitchmcomb_sort_cand_freq(aubio_spectralcandidate_t ** candidates, uint_t nbins); +void aubio_pitchmcomb_sort_cand_freq (aubio_spectralcandidate_t ** candidates, + uint_t nbins); -struct _aubio_pitchmcomb_t { +struct _aubio_pitchmcomb_t +{ smpl_t threshold; /**< offset threshold [0.033 or 0.01] */ smpl_t alpha; /**< normalisation exponent [9] */ smpl_t cutoff; /**< low-pass filter cutoff [0.34, 1] */ @@ -60,14 +66,14 @@ struct _aubio_pitchmcomb_t { uint_t count; /**< picked picks */ uint_t goodcandidate; /**< best candidate */ uint_t spec_partition; /**< spectrum partition to consider */ - aubio_spectralpeak_t * peaks; /**< up to length win/spec_partition */ - aubio_spectralcandidate_t ** candidates; /** up to five candidates */ + aubio_spectralpeak_t *peaks; /**< up to length win/spec_partition */ + aubio_spectralcandidate_t **candidates; /** up to five candidates */ /* some scratch pads */ /** \bug (unnecessary copied from fftgrain?) */ - fvec_t * newmag; /**< vec to store mag */ - fvec_t * scratch; /**< vec to store modified mag */ - fvec_t * scratch2; /**< vec to compute moving median */ - fvec_t * theta; /**< vec to store phase */ + fvec_t *newmag; /**< vec to store mag */ + fvec_t *scratch; /**< vec to store modified mag */ + fvec_t *scratch2; /**< vec to compute moving median */ + fvec_t *theta; /**< vec to store phase */ smpl_t phasediff; smpl_t phasefreq; /** threshfn: name or handle of fn for computing adaptive threshold [median] */ @@ -77,121 +83,131 @@ struct _aubio_pitchmcomb_t { }; /** spectral peak object */ -struct _aubio_spectralpeak_t { +struct _aubio_spectralpeak_t +{ uint_t bin; /**< bin [0-(length-1)] */ smpl_t ebin; /**< estimated bin */ smpl_t mag; /**< peak magnitude */ }; /** spectral candidates array object */ -struct _aubio_spectralcandidate_t { +struct _aubio_spectralcandidate_t +{ smpl_t ebin; /**< interpolated bin */ - smpl_t * ecomb; /**< comb */ + smpl_t *ecomb; /**< comb */ smpl_t ene; /**< candidate energy */ smpl_t len; /**< length */ }; -void aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain, fvec_t * output) { - uint_t i,j; +void +aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain, fvec_t * output) +{ + uint_t i, j; smpl_t instfreq; - fvec_t * newmag = (fvec_t *)p->newmag; + fvec_t *newmag = (fvec_t *) p->newmag; //smpl_t hfc; //fe=instfreq(theta1,theta,ops); //theta1=theta; /* copy incoming grain to newmag */ - for (i=0; i< fftgrain->channels; i++) { - for (j=0; j< newmag->length; j++) - newmag->data[0][j]=fftgrain->norm[i][j]; - /* detect only if local energy > 10. */ - //if (fvec_local_energy(newmag)>10.) { + for (i = 0; i < fftgrain->channels; i++) { + for (j = 0; j < newmag->length; j++) + newmag->data[0][j] = fftgrain->norm[i][j]; + /* detect only if local energy > 10. */ + //if (fvec_local_energy(newmag)>10.) { //hfc = fvec_local_hfc(newmag); //not used - aubio_pitchmcomb_spectral_pp(p, newmag); - aubio_pitchmcomb_combdet(p,newmag); + aubio_pitchmcomb_spectral_pp (p, newmag); + aubio_pitchmcomb_combdet (p, newmag); //aubio_pitchmcomb_sort_cand_freq(p->candidates,p->ncand); //return p->candidates[p->goodcandidate]->ebin; - j = (uint_t)FLOOR(p->candidates[p->goodcandidate]->ebin+.5); - instfreq = aubio_unwrap2pi(fftgrain->phas[i][j] - - p->theta->data[i][j] - j*p->phasediff); - instfreq *= p->phasefreq; - /* store phase for next run */ - for (j=0; j< p->theta->length; j++) { - p->theta->data[i][j]=fftgrain->phas[i][j]; - } - //return p->candidates[p->goodcandidate]->ebin; - output->data[i][0] = FLOOR(p->candidates[p->goodcandidate]->ebin+.5) + instfreq; - /*} else { - return -1.; - }*/ + j = (uint_t) FLOOR (p->candidates[p->goodcandidate]->ebin + .5); + instfreq = aubio_unwrap2pi (fftgrain->phas[i][j] + - p->theta->data[i][j] - j * p->phasediff); + instfreq *= p->phasefreq; + /* store phase for next run */ + for (j = 0; j < p->theta->length; j++) { + p->theta->data[i][j] = fftgrain->phas[i][j]; + } + //return p->candidates[p->goodcandidate]->ebin; + output->data[i][0] = + FLOOR (p->candidates[p->goodcandidate]->ebin + .5) + instfreq; + /*} else { + return -1.; + } */ } } -uint_t aubio_pitch_cands(aubio_pitchmcomb_t * p, cvec_t * fftgrain, - smpl_t * cands) { - uint_t i=0,j; +uint_t +aubio_pitch_cands (aubio_pitchmcomb_t * p, cvec_t * fftgrain, smpl_t * cands) +{ + uint_t i = 0, j; uint_t k; - fvec_t * newmag = (fvec_t *)p->newmag; - aubio_spectralcandidate_t ** scands = - (aubio_spectralcandidate_t **)(p->candidates); + fvec_t *newmag = (fvec_t *) p->newmag; + aubio_spectralcandidate_t **scands = + (aubio_spectralcandidate_t **) (p->candidates); //smpl_t hfc; //fe=instfreq(theta1,theta,ops); //theta1=theta; /* copy incoming grain to newmag */ - for (j=0; j< newmag->length; j++) - newmag->data[i][j]=fftgrain->norm[i][j]; + for (j = 0; j < newmag->length; j++) + newmag->data[i][j] = fftgrain->norm[i][j]; /* detect only if local energy > 10. */ - if (fvec_local_energy(newmag)>10.) { + if (fvec_local_energy (newmag) > 10.) { /* hfc = fvec_local_hfc(newmag); do not use */ - aubio_pitchmcomb_spectral_pp(p, newmag); - aubio_pitchmcomb_combdet(p,newmag); - aubio_pitchmcomb_sort_cand_freq(scands,p->ncand); + aubio_pitchmcomb_spectral_pp (p, newmag); + aubio_pitchmcomb_combdet (p, newmag); + aubio_pitchmcomb_sort_cand_freq (scands, p->ncand); /* store ncand comb energies in cands[1:ncand] */ - for (k = 0; kncand; k++) + for (k = 0; k < p->ncand; k++) cands[k] = p->candidates[k]->ene; /* store ncand[end] freq in cands[end] */ - cands[p->ncand] = p->candidates[p->ncand-1]->ebin; + cands[p->ncand] = p->candidates[p->ncand - 1]->ebin; return 1; } else { - for (k = 0; kncand; k++) + for (k = 0; k < p->ncand; k++) cands[k] = 0; return 0; } } -void aubio_pitchmcomb_spectral_pp(aubio_pitchmcomb_t * p, fvec_t * newmag) { - fvec_t * mag = (fvec_t *)p->scratch; - fvec_t * tmp = (fvec_t *)p->scratch2; - uint_t i=0,j; +void +aubio_pitchmcomb_spectral_pp (aubio_pitchmcomb_t * p, fvec_t * newmag) +{ + fvec_t *mag = (fvec_t *) p->scratch; + fvec_t *tmp = (fvec_t *) p->scratch2; + uint_t i = 0, j; uint_t length = mag->length; /* copy newmag to mag (scracth) */ - for (j=0;jdata[i][j] = newmag->data[i][j]; } - fvec_min_removal(mag); /* min removal */ - fvec_alpha_normalise(mag,p->alpha); /* alpha normalisation */ - /* skipped */ /* low pass filtering */ + fvec_min_removal (mag); /* min removal */ + fvec_alpha_normalise (mag, p->alpha); /* alpha normalisation */ + /* skipped *//* low pass filtering */ /** \bug fvec_moving_thres may write out of bounds */ - fvec_adapt_thres(mag,tmp,p->win_post,p->win_pre,i); /* adaptative threshold */ - fvec_add(mag,-p->threshold); /* fixed threshold */ + fvec_adapt_thres (mag, tmp, p->win_post, p->win_pre, i); /* adaptative threshold */ + fvec_add (mag, -p->threshold); /* fixed threshold */ { - aubio_spectralpeak_t * peaks = (aubio_spectralpeak_t *)p->peaks; + aubio_spectralpeak_t *peaks = (aubio_spectralpeak_t *) p->peaks; uint_t count; /* return bin and ebin */ - count = aubio_pitchmcomb_quadpick(peaks,mag); - for (j=0;jdata[i][peaks[j].bin]; /* reset non peaks */ - for (j=count;jpeaks = peaks; p->count = count; } } -void aubio_pitchmcomb_combdet(aubio_pitchmcomb_t * p, fvec_t * newmag) { - aubio_spectralpeak_t * peaks = (aubio_spectralpeak_t *)p->peaks; - aubio_spectralcandidate_t ** candidate = - (aubio_spectralcandidate_t **)p->candidates; +void +aubio_pitchmcomb_combdet (aubio_pitchmcomb_t * p, fvec_t * newmag) +{ + aubio_spectralpeak_t *peaks = (aubio_spectralpeak_t *) p->peaks; + aubio_spectralcandidate_t **candidate = + (aubio_spectralcandidate_t **) p->candidates; /* parms */ - uint_t N = p->npartials; /* maximum number of partials to be considered 10 */ - uint_t M = p->ncand; /* maximum number of combs to be considered 5 */ + uint_t N = p->npartials; /* maximum number of partials to be considered 10 */ + uint_t M = p->ncand; /* maximum number of combs to be considered 5 */ uint_t length = newmag->length; uint_t count = p->count; uint_t k; @@ -208,32 +224,32 @@ void aubio_pitchmcomb_combdet(aubio_pitchmcomb_t * p, fvec_t * newmag) { smpl_t tmpene = 0.; /* get the biggest peak in the spectrum */ - root_peak = aubio_pitchmcomb_get_root_peak(peaks,count); + root_peak = aubio_pitchmcomb_get_root_peak (peaks, count); /* not enough partials in highest notes, could be forced */ //if (peaks[root_peak].ebin >= aubio_miditofreq(85.)/p->tau) N=2; //if (peaks[root_peak].ebin >= aubio_miditofreq(90.)/p->tau) N=1; /* now calculate the energy of each of the 5 combs */ - for (l=0;lene = 0.; /* reset ene and len sums */ + for (l = 0; l < M; l++) { + smpl_t scaler = (1. / (l + 1.)); + candidate[l]->ene = 0.; /* reset ene and len sums */ candidate[l]->len = 0.; - candidate[l]->ebin=scaler*peaks[root_peak].ebin; + candidate[l]->ebin = scaler * peaks[root_peak].ebin; /* if less than N peaks available, curlen < N */ if (candidate[l]->ebin != 0.) - curlen = (uint_t)FLOOR(length/(candidate[l]->ebin)); - curlen = (N < curlen )? N : curlen; + curlen = (uint_t) FLOOR (length / (candidate[l]->ebin)); + curlen = (N < curlen) ? N : curlen; /* fill candidate[l]->ecomb[k] with (k+1)*candidate[l]->ebin */ - for (k=0;kecomb[k]=(candidate[l]->ebin)*(k+1.); - for (k=curlen;kecomb[k]=0.; + for (k = 0; k < curlen; k++) + candidate[l]->ecomb[k] = (candidate[l]->ebin) * (k + 1.); + for (k = curlen; k < length; k++) + candidate[l]->ecomb[k] = 0.; /* for each in candidate[l]->ecomb[k] */ - for (k=0;kecomb the closer to peaks.ebin * (to cope with the inharmonicity)*/ - for (d=0;decomb[k]-peaks[d].ebin); + for (d = 0; d < count; d++) { + delta2 = ABS (candidate[l]->ecomb[k] - peaks[d].ebin); if (delta2 <= xx) { position = d; xx = delta2; @@ -241,17 +257,18 @@ void aubio_pitchmcomb_combdet(aubio_pitchmcomb_t * p, fvec_t * newmag) { } /* for a Q factor of 17, maintaining "constant Q filtering", * and sum energy and length over non null combs */ - if ( 17. * xx < candidate[l]->ecomb[k] ) { - candidate[l]->ecomb[k]=peaks[position].ebin; - candidate[l]->ene += /* ecomb rounded to nearest int */ - POW(newmag->data[0][(uint_t)FLOOR(candidate[l]->ecomb[k]+.5)],0.25); - candidate[l]->len += 1./curlen; + if (17. * xx < candidate[l]->ecomb[k]) { + candidate[l]->ecomb[k] = peaks[position].ebin; + candidate[l]->ene += /* ecomb rounded to nearest int */ + POW (newmag->data[0][(uint_t) FLOOR (candidate[l]->ecomb[k] + .5)], + 0.25); + candidate[l]->len += 1. / curlen; } else - candidate[l]->ecomb[k]=0.; + candidate[l]->ecomb[k] = 0.; } /* punishment */ /*if (candidate[l]->len<0.6) - candidate[l]->ene=0.; */ + candidate[l]->ene=0.; */ /* remember best candidate energy (in polyphonic, could check for * tmpene*1.1 < candidate->ene to reduce jumps towards low frequencies) */ if (tmpene < candidate[l]->ene) { @@ -269,25 +286,29 @@ void aubio_pitchmcomb_combdet(aubio_pitchmcomb_t * p, fvec_t * newmag) { * * \bug peak-picking too picky, sometimes counts too many peaks ? */ -uint_t aubio_pitchmcomb_quadpick(aubio_spectralpeak_t * spectral_peaks, fvec_t * X){ +uint_t +aubio_pitchmcomb_quadpick (aubio_spectralpeak_t * spectral_peaks, fvec_t * X) +{ uint_t i, j, ispeak, count = 0; - for (i=0;ichannels;i++) - for (j=1;jlength-1;j++) { - ispeak = fvec_peakpick(X,j); + for (i = 0; i < X->channels; i++) + for (j = 1; j < X->length - 1; j++) { + ispeak = fvec_peakpick (X, j); if (ispeak) { count += ispeak; - spectral_peaks[count-1].bin = j; - spectral_peaks[count-1].ebin = fvec_quadint(X, j, i) - 1.; + spectral_peaks[count - 1].bin = j; + spectral_peaks[count - 1].ebin = fvec_quadint (X, j, i) - 1.; } } return count; } /* get predominant partial */ -uint_t aubio_pitchmcomb_get_root_peak(aubio_spectralpeak_t * peaks, uint_t length) { - uint_t i,pos=0; +uint_t +aubio_pitchmcomb_get_root_peak (aubio_spectralpeak_t * peaks, uint_t length) +{ + uint_t i, pos = 0; smpl_t tmp = 0.; - for (i=0;imag - ((aubio_spectralpeak_t *)x)->mag); + +static sint_t +aubio_pitchmcomb_sort_peak_comp (const void *x, const void *y) +{ + return (((aubio_spectralpeak_t *) y)->mag - + ((aubio_spectralpeak_t *) x)->mag); } -void aubio_pitchmcomb_sort_cand_ene(aubio_spectralcandidate_t ** candidates, uint_t nbins) { +void +aubio_pitchmcomb_sort_cand_ene (aubio_spectralcandidate_t ** candidates, + uint_t nbins) +{ uint_t cur = 0; uint_t run = 0; - for (cur=0;curene > candidates[cur]->ene) - CAND_SWAP(candidates[run], candidates[cur]); + for (run = cur; run < nbins; run++) { + if (candidates[run]->ene > candidates[cur]->ene) + CAND_SWAP (candidates[run], candidates[cur]); } } } -void aubio_pitchmcomb_sort_cand_freq(aubio_spectralcandidate_t ** candidates, uint_t nbins) { +void +aubio_pitchmcomb_sort_cand_freq (aubio_spectralcandidate_t ** candidates, + uint_t nbins) +{ uint_t cur = 0; uint_t run = 0; - for (cur=0;curebin < candidates[cur]->ebin) - CAND_SWAP(candidates[run], candidates[cur]); + for (run = cur; run < nbins; run++) { + if (candidates[run]->ebin < candidates[cur]->ebin) + CAND_SWAP (candidates[run], candidates[cur]); } } } -aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t bufsize, uint_t hopsize, uint_t channels) { - aubio_pitchmcomb_t * p = AUBIO_NEW(aubio_pitchmcomb_t); +aubio_pitchmcomb_t * +new_aubio_pitchmcomb (uint_t bufsize, uint_t hopsize, uint_t channels) +{ + aubio_pitchmcomb_t *p = AUBIO_NEW (aubio_pitchmcomb_t); /* bug: should check if size / 8 > post+pre+1 */ uint_t i, j; uint_t spec_size; - p->spec_partition = 4; - p->ncand = 5; - p->npartials = 5; - p->cutoff = 1.; - p->threshold = 0.01; - p->win_post = 8; - p->win_pre = 7; + p->spec_partition = 4; + p->ncand = 5; + p->npartials = 5; + p->cutoff = 1.; + p->threshold = 0.01; + p->win_post = 8; + p->win_pre = 7; // p->tau = samplerate/bufsize; - p->alpha = 9.; - p->goodcandidate = 0; - p->phasefreq = bufsize/hopsize/TWO_PI; - p->phasediff = TWO_PI*hopsize/bufsize; - spec_size = bufsize/p->spec_partition; + p->alpha = 9.; + p->goodcandidate = 0; + p->phasefreq = bufsize / hopsize / TWO_PI; + p->phasediff = TWO_PI * hopsize / bufsize; + spec_size = bufsize / p->spec_partition; //p->pickerfn = quadpick; //p->biquad = new_biquad(0.1600,0.3200,0.1600, -0.5949, 0.2348); /* allocate temp memory */ - p->newmag = new_fvec(spec_size,1); + p->newmag = new_fvec (spec_size, 1); /* array for median */ - p->scratch = new_fvec(spec_size,1); + p->scratch = new_fvec (spec_size, 1); /* array for phase */ - p->theta = new_fvec(spec_size,channels); + p->theta = new_fvec (spec_size, channels); /* array for adaptative threshold */ - p->scratch2 = new_fvec(p->win_post+p->win_pre+1,1); + p->scratch2 = new_fvec (p->win_post + p->win_pre + 1, 1); /* array of spectral peaks */ - p->peaks = AUBIO_ARRAY(aubio_spectralpeak_t,spec_size); + p->peaks = AUBIO_ARRAY (aubio_spectralpeak_t, spec_size); for (i = 0; i < spec_size; i++) { p->peaks[i].bin = 0.; p->peaks[i].ebin = 0.; p->peaks[i].mag = 0.; } /* array of pointers to spectral candidates */ - p->candidates = AUBIO_ARRAY(aubio_spectralcandidate_t *,p->ncand); - for (i=0;incand;i++) { - p->candidates[i] = AUBIO_NEW(aubio_spectralcandidate_t); - p->candidates[i]->ecomb = AUBIO_ARRAY(smpl_t, spec_size); - for (j=0; j < spec_size; j++) { + p->candidates = AUBIO_ARRAY (aubio_spectralcandidate_t *, p->ncand); + for (i = 0; i < p->ncand; i++) { + p->candidates[i] = AUBIO_NEW (aubio_spectralcandidate_t); + p->candidates[i]->ecomb = AUBIO_ARRAY (smpl_t, spec_size); + for (j = 0; j < spec_size; j++) { p->candidates[i]->ecomb[j] = 0.; } p->candidates[i]->ene = 0.; @@ -380,17 +415,19 @@ aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t bufsize, uint_t hopsize, uint_t } -void del_aubio_pitchmcomb (aubio_pitchmcomb_t *p) { +void +del_aubio_pitchmcomb (aubio_pitchmcomb_t * p) +{ uint_t i; - del_fvec(p->newmag); - del_fvec(p->scratch); - del_fvec(p->theta); - del_fvec(p->scratch2); - AUBIO_FREE(p->peaks); - for (i=0;incand;i++) { - AUBIO_FREE(p->candidates[i]->ecomb); - AUBIO_FREE(p->candidates[i]); + del_fvec (p->newmag); + del_fvec (p->scratch); + del_fvec (p->theta); + del_fvec (p->scratch2); + AUBIO_FREE (p->peaks); + for (i = 0; i < p->ncand; i++) { + AUBIO_FREE (p->candidates[i]->ecomb); + AUBIO_FREE (p->candidates[i]); } - AUBIO_FREE(p->candidates); - AUBIO_FREE(p); + AUBIO_FREE (p->candidates); + AUBIO_FREE (p); } diff --git a/src/pitch/pitchmcomb.h b/src/pitch/pitchmcomb.h index f963cd19..8013dc3e 100644 --- a/src/pitch/pitchmcomb.h +++ b/src/pitch/pitchmcomb.h @@ -49,7 +49,9 @@ typedef struct _aubio_pitchmcomb_t aubio_pitchmcomb_t; \param fftgrain input signal spectrum as computed by aubio_pvoc_do */ -void aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain, fvec_t * output); +void aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain, + fvec_t * output); + /** creation of the pitch detection object \param bufsize size of the input buffer to analyse @@ -58,13 +60,15 @@ void aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain, fvec_t * ou \param samplerate sampling rate of the signal */ -aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t bufsize, uint_t hopsize, uint_t channels); +aubio_pitchmcomb_t *new_aubio_pitchmcomb (uint_t bufsize, uint_t hopsize, + uint_t channels); + /** deletion of the pitch detection object \param p pitch detection object as returned by new_aubio_pitchfcomb */ -void del_aubio_pitchmcomb(aubio_pitchmcomb_t *p); +void del_aubio_pitchmcomb (aubio_pitchmcomb_t * p); #ifdef __cplusplus } diff --git a/src/pitch/pitchyin.c b/src/pitch/pitchyin.c index 0917c3e8..73907a93 100644 --- a/src/pitch/pitchyin.c +++ b/src/pitch/pitchyin.c @@ -32,8 +32,9 @@ #include "mathutils.h" #include "pitch/pitchyin.h" -struct _aubio_pitchyin_t { - fvec_t * yin; +struct _aubio_pitchyin_t +{ + fvec_t *yin; smpl_t tol; }; @@ -43,129 +44,136 @@ struct _aubio_pitchyin_t { \param yinbuf output buffer to store difference function (half shorter than input) */ -void aubio_pitchyin_diff(fvec_t * input, fvec_t * yinbuf); +void aubio_pitchyin_diff (fvec_t * input, fvec_t * yinbuf); /** in place computation of the YIN cumulative normalised function \param yinbuf input signal (a square difference function), also used to store function */ -void aubio_pitchyin_getcum(fvec_t * yinbuf); +void aubio_pitchyin_getcum (fvec_t * yinbuf); /** detect pitch in a YIN function \param yinbuf input buffer as computed by aubio_pitchyin_getcum */ -uint_t aubio_pitchyin_getpitch(fvec_t *yinbuf); +uint_t aubio_pitchyin_getpitch (fvec_t * yinbuf); -aubio_pitchyin_t * new_aubio_pitchyin (uint_t bufsize) { - aubio_pitchyin_t * o = AUBIO_NEW(aubio_pitchyin_t); - o->yin = new_fvec (bufsize/2, 1); +aubio_pitchyin_t * +new_aubio_pitchyin (uint_t bufsize) +{ + aubio_pitchyin_t *o = AUBIO_NEW (aubio_pitchyin_t); + o->yin = new_fvec (bufsize / 2, 1); o->tol = 0.15; return o; } -void del_aubio_pitchyin (aubio_pitchyin_t *o) { - del_fvec(o->yin); - AUBIO_FREE(o); +void +del_aubio_pitchyin (aubio_pitchyin_t * o) +{ + del_fvec (o->yin); + AUBIO_FREE (o); } /* outputs the difference function */ -void aubio_pitchyin_diff(fvec_t * input, fvec_t * yin){ - uint_t c,j,tau; +void +aubio_pitchyin_diff (fvec_t * input, fvec_t * yin) +{ + uint_t c, j, tau; smpl_t tmp; - for (c=0;cchannels;c++) - { - for (tau=0;taulength;tau++) - { + for (c = 0; c < input->channels; c++) { + for (tau = 0; tau < yin->length; tau++) { yin->data[c][tau] = 0.; } - for (tau=1;taulength;tau++) - { - for (j=0;jlength;j++) - { - tmp = input->data[c][j] - input->data[c][j+tau]; - yin->data[c][tau] += SQR(tmp); + for (tau = 1; tau < yin->length; tau++) { + for (j = 0; j < yin->length; j++) { + tmp = input->data[c][j] - input->data[c][j + tau]; + yin->data[c][tau] += SQR (tmp); } } } } /* cumulative mean normalized difference function */ -void aubio_pitchyin_getcum(fvec_t * yin) { - uint_t c,tau; +void +aubio_pitchyin_getcum (fvec_t * yin) +{ + uint_t c, tau; smpl_t tmp; - for (c=0;cchannels;c++) - { + for (c = 0; c < yin->channels; c++) { tmp = 0.; yin->data[c][0] = 1.; //AUBIO_DBG("%f\t",yin->data[c][0]); - for (tau=1;taulength;tau++) - { + for (tau = 1; tau < yin->length; tau++) { tmp += yin->data[c][tau]; - yin->data[c][tau] *= tau/tmp; + yin->data[c][tau] *= tau / tmp; //AUBIO_DBG("%f\t",yin->data[c][tau]); } //AUBIO_DBG("\n"); } } -uint_t aubio_pitchyin_getpitch(fvec_t * yin) { - uint_t c=0,tau=1; - do - { - if(yin->data[c][tau] < 0.1) { - while (yin->data[c][tau+1] < yin->data[c][tau]) { +uint_t +aubio_pitchyin_getpitch (fvec_t * yin) +{ + uint_t c = 0, tau = 1; + do { + if (yin->data[c][tau] < 0.1) { + while (yin->data[c][tau + 1] < yin->data[c][tau]) { tau++; } return tau; } tau++; - } while (taulength); + } while (tau < yin->length); //AUBIO_DBG("No pitch found"); return 0; } /* all the above in one */ -void aubio_pitchyin_do(aubio_pitchyin_t *o, fvec_t * input, fvec_t * out){ +void +aubio_pitchyin_do (aubio_pitchyin_t * o, fvec_t * input, fvec_t * out) +{ smpl_t tol = o->tol; - fvec_t * yin = o->yin; - uint_t c , j,tau = 0; + fvec_t *yin = o->yin; + uint_t c, j, tau = 0; sint_t period; smpl_t tmp = 0., tmp2 = 0.; for (c = 0; c < input->channels; c++) { yin->data[c][0] = 1.; - for (tau=1;taulength;tau++) - { + for (tau = 1; tau < yin->length; tau++) { yin->data[c][tau] = 0.; - for (j=0;jlength;j++) - { - tmp = input->data[c][j] - input->data[c][j+tau]; - yin->data[c][tau] += SQR(tmp); + for (j = 0; j < yin->length; j++) { + tmp = input->data[c][j] - input->data[c][j + tau]; + yin->data[c][tau] += SQR (tmp); } tmp2 += yin->data[c][tau]; - yin->data[c][tau] *= tau/tmp2; - period = tau-3; - if(tau > 4 && (yin->data[c][period] < tol) && - (yin->data[c][period] < yin->data[c][period+1])) { - out->data[c][0] = fvec_quadint(yin,period,c); + yin->data[c][tau] *= tau / tmp2; + period = tau - 3; + if (tau > 4 && (yin->data[c][period] < tol) && + (yin->data[c][period] < yin->data[c][period + 1])) { + out->data[c][0] = fvec_quadint (yin, period, c); goto beach; } } - out->data[c][0] = fvec_quadint(yin,fvec_min_elem(yin),c); -beach: + out->data[c][0] = fvec_quadint (yin, fvec_min_elem (yin), c); + beach: continue; } //return 0; } -uint_t aubio_pitchyin_set_tolerance (aubio_pitchyin_t *o, smpl_t tol) { +uint_t +aubio_pitchyin_set_tolerance (aubio_pitchyin_t * o, smpl_t tol) +{ o->tol = tol; return 0; } -smpl_t aubio_pitchyin_get_tolerance (aubio_pitchyin_t *o) { +smpl_t +aubio_pitchyin_get_tolerance (aubio_pitchyin_t * o) +{ return o->tol; } diff --git a/src/pitch/pitchyin.h b/src/pitch/pitchyin.h index bff4bcef..a5f70016 100644 --- a/src/pitch/pitchyin.h +++ b/src/pitch/pitchyin.h @@ -47,7 +47,7 @@ typedef struct _aubio_pitchyin_t aubio_pitchyin_t; \param bufsize size of the input buffer to analyse */ -aubio_pitchyin_t * new_aubio_pitchyin (uint_t bufsize); +aubio_pitchyin_t *new_aubio_pitchyin (uint_t bufsize); /** deletion of the pitch detection object @@ -72,7 +72,7 @@ void aubio_pitchyin_do (aubio_pitchyin_t * o, fvec_t * in, fvec_t * out); \param tol tolerance parameter for minima selection [default 0.15] */ -uint_t aubio_pitchyin_set_tolerance (aubio_pitchyin_t *o, smpl_t tol); +uint_t aubio_pitchyin_set_tolerance (aubio_pitchyin_t * o, smpl_t tol); /** get tolerance parameter for YIN algorithm diff --git a/src/pitch/pitchyinfft.c b/src/pitch/pitchyinfft.c index a35e4529..0111f31f 100644 --- a/src/pitch/pitchyinfft.c +++ b/src/pitch/pitchyinfft.c @@ -26,145 +26,158 @@ #include "pitch/pitchyinfft.h" /** pitch yinfft structure */ -struct _aubio_pitchyinfft_t { - fvec_t * win; /**< temporal weighting window */ - fvec_t * winput; /**< windowed spectrum */ - cvec_t * res; /**< complex vector to compute square difference function */ - fvec_t * sqrmag; /**< square difference function */ - fvec_t * weight; /**< spectral weighting window (psychoacoustic model) */ - cvec_t * fftout; /**< Fourier transform output */ - aubio_fft_t * fft; /**< fft object to compute square difference function */ - fvec_t * yinfft; /**< Yin function */ +struct _aubio_pitchyinfft_t +{ + fvec_t *win; /**< temporal weighting window */ + fvec_t *winput; /**< windowed spectrum */ + cvec_t *res; /**< complex vector to compute square difference function */ + fvec_t *sqrmag; /**< square difference function */ + fvec_t *weight; /**< spectral weighting window (psychoacoustic model) */ + cvec_t *fftout; /**< Fourier transform output */ + aubio_fft_t *fft; /**< fft object to compute square difference function */ + fvec_t *yinfft; /**< Yin function */ smpl_t tol; /**< Yin tolerance */ }; -static const smpl_t freqs[] = {0., 20., 25., 31.5, 40., 50., 63., 80., 100., +static const smpl_t freqs[] = { 0., 20., 25., 31.5, 40., 50., 63., 80., 100., 125., 160., 200., 250., 315., 400., 500., 630., 800., 1000., 1250., 1600., 2000., 2500., 3150., 4000., 5000., 6300., 8000., 9000., 10000., - 12500., 15000., 20000., 25100}; + 12500., 15000., 20000., 25100 +}; -static const smpl_t weight[] = {-75.8, -70.1, -60.8, -52.1, -44.2, -37.5, +static const smpl_t weight[] = { -75.8, -70.1, -60.8, -52.1, -44.2, -37.5, -31.3, -25.6, -20.9, -16.5, -12.6, -9.6, -7.0, -4.7, -3.0, -1.8, -0.8, -0.2, -0.0, 0.5, 1.6, 3.2, 5.4, 7.8, 8.1, 5.3, -2.4, -11.1, -12.8, - -12.2, -7.4, -17.8, -17.8, -17.8}; + -12.2, -7.4, -17.8, -17.8, -17.8 +}; -aubio_pitchyinfft_t * new_aubio_pitchyinfft (uint_t bufsize) +aubio_pitchyinfft_t * +new_aubio_pitchyinfft (uint_t bufsize) { - aubio_pitchyinfft_t * p = AUBIO_NEW(aubio_pitchyinfft_t); - p->winput = new_fvec(bufsize,1); - p->fft = new_aubio_fft(bufsize, 1); - p->fftout = new_cvec(bufsize,1); - p->sqrmag = new_fvec(bufsize,1); - p->res = new_cvec(bufsize,1); - p->yinfft = new_fvec(bufsize/2+1,1); - p->tol = 0.85; - p->win = new_aubio_window("hanningz", bufsize); - p->weight = new_fvec(bufsize/2+1,1); + aubio_pitchyinfft_t *p = AUBIO_NEW (aubio_pitchyinfft_t); + p->winput = new_fvec (bufsize, 1); + p->fft = new_aubio_fft (bufsize, 1); + p->fftout = new_cvec (bufsize, 1); + p->sqrmag = new_fvec (bufsize, 1); + p->res = new_cvec (bufsize, 1); + p->yinfft = new_fvec (bufsize / 2 + 1, 1); + p->tol = 0.85; + p->win = new_aubio_window ("hanningz", bufsize); + p->weight = new_fvec (bufsize / 2 + 1, 1); { uint_t i = 0, j = 1; smpl_t freq = 0, a0 = 0, a1 = 0, f0 = 0, f1 = 0; - for (i=0; iweight->length; i++) { - freq = (smpl_t)i/(smpl_t)bufsize*(smpl_t)44100.; + for (i = 0; i < p->weight->length; i++) { + freq = (smpl_t) i / (smpl_t) bufsize *(smpl_t) 44100.; while (freq > freqs[j]) { - j +=1; - } - a0 = weight[j-1]; - f0 = freqs[j-1]; - a1 = weight[j]; + j += 1; + } + a0 = weight[j - 1]; + f0 = freqs[j - 1]; + a1 = weight[j]; f1 = freqs[j]; - if (f0 == f1) { // just in case + if (f0 == f1) { // just in case p->weight->data[0][i] = a0; - } else if (f0 == 0) { // y = ax+b - p->weight->data[0][i] = (a1-a0)/f1*freq + a0; + } else if (f0 == 0) { // y = ax+b + p->weight->data[0][i] = (a1 - a0) / f1 * freq + a0; } else { - p->weight->data[0][i] = (a1-a0)/(f1-f0)*freq + - (a0 - (a1 - a0)/(f1/f0 - 1.)); + p->weight->data[0][i] = (a1 - a0) / (f1 - f0) * freq + + (a0 - (a1 - a0) / (f1 / f0 - 1.)); } while (freq > freqs[j]) { - j +=1; + j += 1; } //AUBIO_DBG("%f\n",p->weight->data[0][i]); - p->weight->data[0][i] = DB2LIN(p->weight->data[0][i]); + p->weight->data[0][i] = DB2LIN (p->weight->data[0][i]); //p->weight->data[0][i] = SQRT(DB2LIN(p->weight->data[0][i])); } } return p; } -void aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, fvec_t * input, fvec_t * output) { +void +aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, fvec_t * input, fvec_t * output) +{ uint_t i, tau, l; uint_t halfperiod; smpl_t tmp, sum; - cvec_t * res = (cvec_t *)p->res; - fvec_t * yin = (fvec_t *)p->yinfft; - for (i=0; i < input->channels; i++){ - l = 0; tmp = 0.; sum = 0.; - for (l=0; l < input->length; l++){ - p->winput->data[0][l] = p->win->data[0][l] * input->data[i][l]; - } - aubio_fft_do(p->fft,p->winput,p->fftout); - for (l=0; l < p->fftout->length; l++){ - p->sqrmag->data[0][l] = SQR(p->fftout->norm[0][l]); - p->sqrmag->data[0][l] *= p->weight->data[0][l]; - } - for (l=1; l < p->fftout->length; l++){ - p->sqrmag->data[0][(p->fftout->length-1)*2-l] = - SQR(p->fftout->norm[0][l]); - p->sqrmag->data[0][(p->fftout->length-1)*2-l] *= - p->weight->data[0][l]; - } - for (l=0; l < p->sqrmag->length/2+1; l++) { - sum += p->sqrmag->data[0][l]; - } - sum *= 2.; - aubio_fft_do(p->fft,p->sqrmag,res); - yin->data[0][0] = 1.; - for (tau=1; tau < yin->length; tau++) { - yin->data[0][tau] = sum - - res->norm[0][tau]*COS(res->phas[0][tau]); - tmp += yin->data[0][tau]; - yin->data[0][tau] *= tau/tmp; - } - tau = fvec_min_elem(yin); - if (yin->data[0][tau] < p->tol) { - /* no interpolation */ - //return tau; - /* 3 point quadratic interpolation */ - //return fvec_quadint_min(yin,tau,1); - /* additional check for (unlikely) octave doubling in higher frequencies */ - if (tau>35) { - output->data[i][0] = fvec_quadint(yin,tau,i); + cvec_t *res = (cvec_t *) p->res; + fvec_t *yin = (fvec_t *) p->yinfft; + for (i = 0; i < input->channels; i++) { + l = 0; + tmp = 0.; + sum = 0.; + for (l = 0; l < input->length; l++) { + p->winput->data[0][l] = p->win->data[0][l] * input->data[i][l]; + } + aubio_fft_do (p->fft, p->winput, p->fftout); + for (l = 0; l < p->fftout->length; l++) { + p->sqrmag->data[0][l] = SQR (p->fftout->norm[0][l]); + p->sqrmag->data[0][l] *= p->weight->data[0][l]; + } + for (l = 1; l < p->fftout->length; l++) { + p->sqrmag->data[0][(p->fftout->length - 1) * 2 - l] = + SQR (p->fftout->norm[0][l]); + p->sqrmag->data[0][(p->fftout->length - 1) * 2 - l] *= + p->weight->data[0][l]; + } + for (l = 0; l < p->sqrmag->length / 2 + 1; l++) { + sum += p->sqrmag->data[0][l]; + } + sum *= 2.; + aubio_fft_do (p->fft, p->sqrmag, res); + yin->data[0][0] = 1.; + for (tau = 1; tau < yin->length; tau++) { + yin->data[0][tau] = sum - res->norm[0][tau] * COS (res->phas[0][tau]); + tmp += yin->data[0][tau]; + yin->data[0][tau] *= tau / tmp; + } + tau = fvec_min_elem (yin); + if (yin->data[0][tau] < p->tol) { + /* no interpolation */ + //return tau; + /* 3 point quadratic interpolation */ + //return fvec_quadint_min(yin,tau,1); + /* additional check for (unlikely) octave doubling in higher frequencies */ + if (tau > 35) { + output->data[i][0] = fvec_quadint (yin, tau, i); + } else { + /* should compare the minimum value of each interpolated peaks */ + halfperiod = FLOOR (tau / 2 + .5); + if (yin->data[0][halfperiod] < p->tol) + output->data[i][0] = fvec_quadint (yin, halfperiod, i); + else + output->data[i][0] = fvec_quadint (yin, tau, i); + } } else { - /* should compare the minimum value of each interpolated peaks */ - halfperiod = FLOOR(tau/2+.5); - if (yin->data[0][halfperiod] < p->tol) - output->data[i][0] = fvec_quadint(yin,halfperiod,i); - else - output->data[i][0] = fvec_quadint(yin,tau,i); + output->data[i][0] = 0.; } - } else { - output->data[i][0] = 0.; - } } } -void del_aubio_pitchyinfft(aubio_pitchyinfft_t *p){ - del_fvec(p->win); - del_aubio_fft(p->fft); - del_fvec(p->yinfft); - del_fvec(p->sqrmag); - del_cvec(p->res); - del_cvec(p->fftout); - del_fvec(p->winput); - del_fvec(p->weight); - AUBIO_FREE(p); +void +del_aubio_pitchyinfft (aubio_pitchyinfft_t * p) +{ + del_fvec (p->win); + del_aubio_fft (p->fft); + del_fvec (p->yinfft); + del_fvec (p->sqrmag); + del_cvec (p->res); + del_cvec (p->fftout); + del_fvec (p->winput); + del_fvec (p->weight); + AUBIO_FREE (p); } -uint_t aubio_pitchyinfft_set_tolerance (aubio_pitchyinfft_t * p, smpl_t tol) { +uint_t +aubio_pitchyinfft_set_tolerance (aubio_pitchyinfft_t * p, smpl_t tol) +{ p->tol = tol; return 0; } -smpl_t aubio_pitchyinfft_get_tolerance (aubio_pitchyinfft_t * p) { +smpl_t +aubio_pitchyinfft_get_tolerance (aubio_pitchyinfft_t * p) +{ return p->tol; } diff --git a/src/pitch/pitchyinfft.h b/src/pitch/pitchyinfft.h index 945d46c5..3bb3ace7 100644 --- a/src/pitch/pitchyinfft.h +++ b/src/pitch/pitchyinfft.h @@ -50,19 +50,19 @@ typedef struct _aubio_pitchyinfft_t aubio_pitchyinfft_t; \param output pitch period candidates, in samples */ -void aubio_pitchyinfft_do (aubio_pitchyinfft_t *p, fvec_t * in, fvec_t * out); +void aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, fvec_t * in, fvec_t * out); /** creation of the pitch detection object \param bufsize size of the input buffer to analyse */ -aubio_pitchyinfft_t * new_aubio_pitchyinfft (uint_t bufsize); +aubio_pitchyinfft_t *new_aubio_pitchyinfft (uint_t bufsize); /** deletion of the pitch detection object \param p pitch detection object as returned by new_aubio_pitchyinfft() */ -void del_aubio_pitchyinfft (aubio_pitchyinfft_t *p); +void del_aubio_pitchyinfft (aubio_pitchyinfft_t * p); /** get tolerance parameter for YIN algorithm