From ade9afe663f3175a6ed9e75c0866fa436591e3e1 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Wed, 2 May 2007 15:10:42 +0200 Subject: [PATCH] =?utf8?q?mathutils.c:=20indentation,=C2=A0remove=20tabs,?= =?utf8?q?=20no=20{=20at=20beginning=20of=20line,=20no=20spaces=20at=20end?= =?utf8?q?=20of=20line?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/mathutils.c | 144 ++++++++++++++++++++---------------------------- 1 file changed, 59 insertions(+), 85 deletions(-) diff --git a/src/mathutils.c b/src/mathutils.c index d561fced..f82549a6 100644 --- a/src/mathutils.c +++ b/src/mathutils.c @@ -29,7 +29,7 @@ void aubio_window(smpl_t *w, uint_t size, aubio_window_type wintype) { switch(wintype) { case aubio_win_rectangle: for (i=0;ichannels; i++) @@ -90,9 +87,7 @@ smpl_t vec_mean(fvec_t *s) return tmp/(smpl_t)(s->length); } - -smpl_t vec_sum(fvec_t *s) -{ +smpl_t vec_sum(fvec_t *s) { uint_t i,j; smpl_t tmp = 0.0f; for (i=0; i < s->channels; i++) @@ -101,9 +96,7 @@ smpl_t vec_sum(fvec_t *s) return tmp; } - -smpl_t vec_max(fvec_t *s) -{ +smpl_t vec_max(fvec_t *s) { uint_t i,j; smpl_t tmp = 0.0f; for (i=0; i < s->channels; i++) @@ -112,8 +105,7 @@ smpl_t vec_max(fvec_t *s) return tmp; } -smpl_t vec_min(fvec_t *s) -{ +smpl_t vec_min(fvec_t *s) { uint_t i,j; smpl_t tmp = s->data[0][0]; for (i=0; i < s->channels; i++) @@ -122,9 +114,7 @@ smpl_t vec_min(fvec_t *s) return tmp; } - -uint_t vec_min_elem(fvec_t *s) -{ +uint_t vec_min_elem(fvec_t *s) { uint_t i,j=0, pos=0.; smpl_t tmp = s->data[0][0]; for (i=0; i < s->channels; i++) @@ -135,8 +125,7 @@ uint_t vec_min_elem(fvec_t *s) return pos; } -uint_t vec_max_elem(fvec_t *s) -{ +uint_t vec_max_elem(fvec_t *s) { uint_t i,j=0, pos=0.; smpl_t tmp = 0.0f; for (i=0; i < s->channels; i++) @@ -147,8 +136,7 @@ uint_t vec_max_elem(fvec_t *s) return pos; } -void vec_shift(fvec_t *s) -{ +void vec_shift(fvec_t *s) { uint_t i,j; //smpl_t tmp = 0.0f; for (i=0; i < s->channels; i++) @@ -160,8 +148,7 @@ void vec_shift(fvec_t *s) } } -smpl_t vec_local_energy(fvec_t * f) -{ +smpl_t vec_local_energy(fvec_t * f) { smpl_t locE = 0.; uint_t i,j; for (i=0;ichannels;i++) @@ -170,8 +157,7 @@ smpl_t vec_local_energy(fvec_t * f) return locE; } -smpl_t vec_local_hfc(fvec_t * f) -{ +smpl_t vec_local_hfc(fvec_t * f) { smpl_t locE = 0.; uint_t i,j; for (i=0;ichannels;i++) @@ -180,8 +166,7 @@ smpl_t vec_local_hfc(fvec_t * f) return locE; } -smpl_t vec_alpha_norm(fvec_t * DF, smpl_t alpha) -{ +smpl_t vec_alpha_norm(fvec_t * DF, smpl_t alpha) { smpl_t tmp = 0.; uint_t i,j; for (i=0;ichannels;i++) @@ -190,9 +175,7 @@ smpl_t vec_alpha_norm(fvec_t * DF, smpl_t alpha) return POW(tmp/DF->length,1./alpha); } - -void vec_dc_removal(fvec_t * mag) -{ +void vec_dc_removal(fvec_t * mag) { smpl_t mini = 0.; uint_t length = mag->length, i=0, j; mini = vec_min(mag); @@ -201,9 +184,7 @@ void vec_dc_removal(fvec_t * mag) } } - -void vec_alpha_normalise(fvec_t * mag, uint_t alpha) -{ +void vec_alpha_normalise(fvec_t * mag, uint_t alpha) { smpl_t alphan = 1.; uint_t length = mag->length, i=0, j; alphan = vec_alpha_norm(mag,alpha); @@ -212,7 +193,6 @@ void vec_alpha_normalise(fvec_t * mag, uint_t alpha) } } - void vec_add(fvec_t * mag, smpl_t threshold) { uint_t length = mag->length, i=0, j; for (j=0;jlength, i=0, j; for (j=0;jdata[i][j] -= vec_moving_thres(vec, tmp, post, pre, j); @@ -231,15 +209,14 @@ void vec_adapt_thres(fvec_t * vec, fvec_t * tmp, } smpl_t vec_moving_thres(fvec_t * vec, fvec_t * tmpvec, - uint_t post, uint_t pre, uint_t pos) -{ + uint_t post, uint_t pre, uint_t pos) { smpl_t * medar = (smpl_t *)tmpvec->data[0]; uint_t k; uint_t win_length = post+pre+1; uint_t length = vec->length; /* post part of the buffer does not exist */ if (posdata[0][k+pos-post]; @@ -251,9 +228,9 @@ smpl_t vec_moving_thres(fvec_t * vec, fvec_t * tmpvec, } else { for (k=0;kdata[0][k+pos-post]; - for (k=length-pos+post+1;k resold) + if (res > resold) resold = res; - else { + else { exactpos += (frac-step)*2. - 1.; break; } @@ -344,7 +321,7 @@ smpl_t vec_quadint_min(fvec_t * x,uint_t pos, uint_t span) { res = aubio_quadfrac(s0, s1, s2, frac); if (res < resold) { resold = res; - } else { + } else { exactpos += (frac-step)*span - span/2.; break; } @@ -359,28 +336,28 @@ smpl_t aubio_quadfrac(smpl_t s0, smpl_t s1, smpl_t s2, smpl_t pf) { } uint_t vec_peakpick(fvec_t * onset, uint_t pos) { - uint_t i=0, tmp=0; - /*for (i=0;ichannels;i++)*/ - tmp = (onset->data[i][pos] > onset->data[i][pos-1] - && onset->data[i][pos] > onset->data[i][pos+1] - && onset->data[i][pos] > 0.); - return tmp; + uint_t i=0, tmp=0; + /*for (i=0;ichannels;i++)*/ + tmp = (onset->data[i][pos] > onset->data[i][pos-1] + && onset->data[i][pos] > onset->data[i][pos+1] + && onset->data[i][pos] > 0.); + return tmp; } smpl_t aubio_freqtomidi(smpl_t freq) { - /* log(freq/A-2)/log(2) */ - smpl_t midi = freq/6.875; - midi = LOG(midi)/0.69314718055995; - midi *= 12; - midi -= 3; - return midi; + /* log(freq/A-2)/log(2) */ + smpl_t midi = freq/6.875; + midi = LOG(midi)/0.69314718055995; + midi *= 12; + midi -= 3; + return midi; } smpl_t aubio_miditofreq(smpl_t midi) { - smpl_t freq = (midi+3.)/12.; - freq = EXP(freq*0.69314718055995); - freq *= 6.875; - return freq; + smpl_t freq = (midi+3.)/12.; + freq = EXP(freq*0.69314718055995); + freq *= 6.875; + return freq; } smpl_t aubio_bintofreq(smpl_t bin, smpl_t samplerate, smpl_t fftsize) { @@ -403,9 +380,7 @@ smpl_t aubio_miditobin(smpl_t midi, smpl_t samplerate, smpl_t fftsize) { return aubio_freqtobin(freq,samplerate,fftsize); } - - -/** returns 1 if wassilence is 0 and RMS(ibuf)data[i][j] <= 0. ){ + } else if ( input->data[i][j] <= 0. ) { zcr += 1; } } @@ -470,27 +445,26 @@ smpl_t aubio_spectral_centroid(cvec_t * spectrum, smpl_t samplerate) { return sc / sum * samplerate / (smpl_t)(spectrum->length); } -void aubio_autocorr(fvec_t * input, fvec_t * output){ - uint_t i = 0, j = 0, length = input->length; - smpl_t * data = input->data[0]; - smpl_t * acf = output->data[0]; - smpl_t tmp =0.; - for(i=0;ilength; + smpl_t * data = input->data[0]; + smpl_t * acf = output->data[0]; + smpl_t tmp =0.; + for(i=0;i