Changeset ad04467


Ignore:
Timestamp:
Nov 3, 2009, 4:06:15 PM (10 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
63f3c70
Parents:
8bc4800
Message:

src/pitch/pitchschmitt.c: indent

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/pitch/pitchschmitt.c

    r8bc4800 rad04467  
    2424#include "pitch/pitchschmitt.h"
    2525
    26 smpl_t aubio_schmittS16LE (aubio_pitchschmitt_t *p, uint_t nframes, signed short int *indata);
     26smpl_t aubio_schmittS16LE (aubio_pitchschmitt_t * p, uint_t nframes,
     27    signed short int *indata);
    2728
    28 struct _aubio_pitchschmitt_t {
    29         uint_t blockSize;
    30         uint_t rate;
    31         signed short int *schmittBuffer;
    32         signed short int *schmittPointer;
    33         signed short int *buf;
     29struct _aubio_pitchschmitt_t
     30{
     31  uint_t blockSize;
     32  uint_t rate;
     33  signed short int *schmittBuffer;
     34  signed short int *schmittPointer;
     35  signed short int *buf;
    3436};
    3537
    36 aubio_pitchschmitt_t * new_aubio_pitchschmitt (uint_t size)
     38aubio_pitchschmitt_t *
     39new_aubio_pitchschmitt (uint_t size)
    3740{
    38   aubio_pitchschmitt_t * p = AUBIO_NEW(aubio_pitchschmitt_t);
     41  aubio_pitchschmitt_t *p = AUBIO_NEW (aubio_pitchschmitt_t);
    3942  p->blockSize = size;
    40   p->schmittBuffer = AUBIO_ARRAY(signed short int,p->blockSize);
    41   p->buf = AUBIO_ARRAY(signed short int,p->blockSize);
     43  p->schmittBuffer = AUBIO_ARRAY (signed short int, p->blockSize);
     44  p->buf = AUBIO_ARRAY (signed short int, p->blockSize);
    4245  p->schmittPointer = p->schmittBuffer;
    4346  return p;
     
    5760}
    5861
    59 smpl_t aubio_schmittS16LE (aubio_pitchschmitt_t *p, uint_t nframes, signed short int *indata)
     62smpl_t
     63aubio_schmittS16LE (aubio_pitchschmitt_t * p, uint_t nframes,
     64    signed short int *indata)
    6065{
    6166  uint_t i, j;
     
    6671  smpl_t period = 0., trigfact = 0.6;
    6772
    68   for (i=0; i<nframes; i++) {
     73  for (i = 0; i < nframes; i++) {
    6974    *schmittPointer++ = indata[i];
    70     if (schmittPointer-schmittBuffer >= (sint_t)blockSize) {
     75    if (schmittPointer - schmittBuffer >= (sint_t) blockSize) {
    7176      sint_t endpoint, startpoint, t1, t2, A1, A2, tc, schmittTriggered;
    7277
    7378      schmittPointer = schmittBuffer;
    7479
    75       for (j=0,A1=0,A2=0; j<blockSize; j++) {
    76         if (schmittBuffer[j]>0 && A1<schmittBuffer[j])  A1 = schmittBuffer[j];
    77         if (schmittBuffer[j]<0 && A2<-schmittBuffer[j]) A2 = -schmittBuffer[j];
     80      for (j = 0, A1 = 0, A2 = 0; j < blockSize; j++) {
     81        if (schmittBuffer[j] > 0 && A1 < schmittBuffer[j])
     82          A1 = schmittBuffer[j];
     83        if (schmittBuffer[j] < 0 && A2 < -schmittBuffer[j])
     84          A2 = -schmittBuffer[j];
    7885      }
    79       t1 =   (sint_t)( A1 * trigfact + 0.5);
    80       t2 = - (sint_t)( A2 * trigfact + 0.5);
    81       startpoint=0;
    82       for (j=1; schmittBuffer[j]<=t1 && j<blockSize; j++);
    83       for (; !(schmittBuffer[j]  >=t2 &&
    84                schmittBuffer[j+1]< t2) && j<blockSize; j++);
    85       startpoint=j;
    86       schmittTriggered=0;
    87       endpoint=startpoint+1;
    88       for(j=startpoint,tc=0; j<blockSize; j++) {
    89         if (!schmittTriggered) {
    90           schmittTriggered = (schmittBuffer[j] >= t1);
    91         } else if (schmittBuffer[j]>=t2 && schmittBuffer[j+1]<t2) {
    92           endpoint=j;
    93           tc++;
    94           schmittTriggered = 0;
    95         }
     86      t1 = (sint_t) (A1 * trigfact + 0.5);
     87      t2 = -(sint_t) (A2 * trigfact + 0.5);
     88      startpoint = 0;
     89      for (j = 1; schmittBuffer[j] <= t1 && j < blockSize; j++);
     90      for (; !(schmittBuffer[j] >= t2 &&
     91              schmittBuffer[j + 1] < t2) && j < blockSize; j++);
     92      startpoint = j;
     93      schmittTriggered = 0;
     94      endpoint = startpoint + 1;
     95      for (j = startpoint, tc = 0; j < blockSize; j++) {
     96        if (!schmittTriggered) {
     97          schmittTriggered = (schmittBuffer[j] >= t1);
     98        } else if (schmittBuffer[j] >= t2 && schmittBuffer[j + 1] < t2) {
     99          endpoint = j;
     100          tc++;
     101          schmittTriggered = 0;
     102        }
    96103      }
    97104      if ((endpoint > startpoint) && (tc > 0)) {
    98         period = (smpl_t)(endpoint-startpoint)/tc;
     105        period = (smpl_t) (endpoint - startpoint) / tc;
    99106      }
    100107    }
    101108  }
    102109
    103   p->schmittBuffer  = schmittBuffer;
     110  p->schmittBuffer = schmittBuffer;
    104111  p->schmittPointer = schmittPointer;
    105112  return period;
    106113}
    107114
    108 void del_aubio_pitchschmitt (aubio_pitchschmitt_t *p)
     115void
     116del_aubio_pitchschmitt (aubio_pitchschmitt_t * p)
    109117{
    110   AUBIO_FREE(p->schmittBuffer);
    111   AUBIO_FREE(p);
     118  AUBIO_FREE (p->schmittBuffer);
     119  AUBIO_FREE (p);
    112120}
    113 
Note: See TracChangeset for help on using the changeset viewer.