From: Paul Brossier Date: Tue, 3 Nov 2009 15:06:15 +0000 (+0100) Subject: src/pitch/pitchschmitt.c: indent X-Git-Tag: 0.4.0-beta1~582 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=ad044676e88a0b80b1fc901f00df7c388f918a08;p=aubio.git src/pitch/pitchschmitt.c: indent --- diff --git a/src/pitch/pitchschmitt.c b/src/pitch/pitchschmitt.c index f4c8e731..4aed3145 100644 --- a/src/pitch/pitchschmitt.c +++ b/src/pitch/pitchschmitt.c @@ -23,22 +23,25 @@ #include "fvec.h" #include "pitch/pitchschmitt.h" -smpl_t aubio_schmittS16LE (aubio_pitchschmitt_t *p, uint_t nframes, signed short int *indata); - -struct _aubio_pitchschmitt_t { - uint_t blockSize; - uint_t rate; - signed short int *schmittBuffer; - signed short int *schmittPointer; - signed short int *buf; +smpl_t aubio_schmittS16LE (aubio_pitchschmitt_t * p, uint_t nframes, + signed short int *indata); + +struct _aubio_pitchschmitt_t +{ + uint_t blockSize; + uint_t rate; + signed short int *schmittBuffer; + signed short int *schmittPointer; + signed short int *buf; }; -aubio_pitchschmitt_t * new_aubio_pitchschmitt (uint_t size) +aubio_pitchschmitt_t * +new_aubio_pitchschmitt (uint_t size) { - aubio_pitchschmitt_t * p = AUBIO_NEW(aubio_pitchschmitt_t); + aubio_pitchschmitt_t *p = AUBIO_NEW (aubio_pitchschmitt_t); p->blockSize = size; - p->schmittBuffer = AUBIO_ARRAY(signed short int,p->blockSize); - p->buf = AUBIO_ARRAY(signed short int,p->blockSize); + p->schmittBuffer = AUBIO_ARRAY (signed short int, p->blockSize); + p->buf = AUBIO_ARRAY (signed short int, p->blockSize); p->schmittPointer = p->schmittBuffer; return p; } @@ -56,7 +59,9 @@ aubio_pitchschmitt_do (aubio_pitchschmitt_t * p, fvec_t * input, } } -smpl_t aubio_schmittS16LE (aubio_pitchschmitt_t *p, uint_t nframes, signed short int *indata) +smpl_t +aubio_schmittS16LE (aubio_pitchschmitt_t * p, uint_t nframes, + signed short int *indata) { uint_t i, j; uint_t blockSize = p->blockSize; @@ -65,49 +70,51 @@ smpl_t aubio_schmittS16LE (aubio_pitchschmitt_t *p, uint_t nframes, signed short smpl_t period = 0., trigfact = 0.6; - for (i=0; i= (sint_t)blockSize) { + if (schmittPointer - schmittBuffer >= (sint_t) blockSize) { sint_t endpoint, startpoint, t1, t2, A1, A2, tc, schmittTriggered; schmittPointer = schmittBuffer; - for (j=0,A1=0,A2=0; j0 && A1 0 && A1 < schmittBuffer[j]) + A1 = schmittBuffer[j]; + if (schmittBuffer[j] < 0 && A2 < -schmittBuffer[j]) + A2 = -schmittBuffer[j]; } - t1 = (sint_t)( A1 * trigfact + 0.5); - t2 = - (sint_t)( A2 * trigfact + 0.5); - startpoint=0; - for (j=1; schmittBuffer[j]<=t1 && j=t2 && - schmittBuffer[j+1]< t2) && j= t1); - } else if (schmittBuffer[j]>=t2 && schmittBuffer[j+1]= t2 && + schmittBuffer[j + 1] < t2) && j < blockSize; j++); + startpoint = j; + schmittTriggered = 0; + endpoint = startpoint + 1; + for (j = startpoint, tc = 0; j < blockSize; j++) { + if (!schmittTriggered) { + schmittTriggered = (schmittBuffer[j] >= t1); + } else if (schmittBuffer[j] >= t2 && schmittBuffer[j + 1] < t2) { + endpoint = j; + tc++; + schmittTriggered = 0; + } } if ((endpoint > startpoint) && (tc > 0)) { - period = (smpl_t)(endpoint-startpoint)/tc; + period = (smpl_t) (endpoint - startpoint) / tc; } } } - p->schmittBuffer = schmittBuffer; + p->schmittBuffer = schmittBuffer; p->schmittPointer = schmittPointer; return period; } -void del_aubio_pitchschmitt (aubio_pitchschmitt_t *p) +void +del_aubio_pitchschmitt (aubio_pitchschmitt_t * p) { - AUBIO_FREE(p->schmittBuffer); - AUBIO_FREE(p); + AUBIO_FREE (p->schmittBuffer); + AUBIO_FREE (p); } -