ref: 28d8c4aa38dfbbb65fcc01c83037c0fb223e791a
parent: ea865c9b175ecdff475cbd21d32ba3624ba51911
author: Paul Brossier <piem@altern.org>
date: Tue Aug 9 06:09:36 EDT 2005
prefix mathutils function with aubio_
--- a/examples/tests/test-fft.c
+++ b/examples/tests/test-fft.c
@@ -19,7 +19,7 @@
for (i=0; i < channels; i++)
spec[i] = AUBIO_ARRAY(fft_data_t,win_s);
/* initialize the window (see mathutils.c) */
- window(w,win_s,aubio_win_hanningz);
+ aubio_window(w,win_s,aubio_win_hanningz);
/* fill input with some data */
@@ -34,7 +34,7 @@
/* execute inverse fourier transform */
for (i=0; i < channels; i++) {
for (j=0; j<win_s/2+1; j++) {
- spec[i][j] = CEXPC(I*unwrap2pi(fftgrain->phas[i][j]));
+ spec[i][j] = CEXPC(I*aubio_unwrap2pi(fftgrain->phas[i][j]));
spec[i][j] *= fftgrain->norm[i][j];
}
aubio_fft_rdo(fft,spec[i],out->data[i],win_s);
--- a/examples/utils.c
+++ b/examples/utils.c
@@ -329,7 +329,7 @@
void send_noteon(int pitch, int velo)
{
- smpl_t mpitch = (FLOOR)(freqtomidi(pitch)+.5);
+ smpl_t mpitch = (FLOOR)(aubio_freqtomidi(pitch)+.5);
/* we should check if we use midi here, not jack */
#if ALSA_SUPPORT
if (usejack) {
--- a/src/fft.c
+++ b/src/fft.c
@@ -149,7 +149,7 @@
uint_t i=0,j;
for (i=0; i < fft->channels; i++) {
for (j=0; j<fft->winsize/2+1; j++) {
- fft->spec[i][j] = CEXPC(I*unwrap2pi(fftgrain->phas[i][j]));
+ fft->spec[i][j] = CEXPC(I*aubio_unwrap2pi(fftgrain->phas[i][j]));
fft->spec[i][j] *= fftgrain->norm[i][j];
}
aubio_fft_rdo(fft->fft,fft->spec[i],out->data[i],fft->winsize);
--- a/src/mathutils.c
+++ b/src/mathutils.c
@@ -23,7 +23,7 @@
#include "sample.h"
#include "mathutils.h"
-void window(smpl_t *w, uint_t size, aubio_window_type_t wintype) {
+void aubio_window(smpl_t *w, uint_t size, aubio_window_type wintype) {
uint_t i;
switch(wintype) {
case aubio_win_rectangle:
@@ -73,7 +73,7 @@
}
-smpl_t unwrap2pi(smpl_t phase) {
+smpl_t aubio_unwrap2pi(smpl_t phase) {
/* mod(phase+pi,-2pi)+pi */
return phase + TWO_PI * (1. + floorf(-(phase+PI)/TWO_PI));
}
@@ -318,7 +318,7 @@
s2 = x->data[0][pos+span];
/* increase frac */
for (frac = 0.; frac < 2.; frac = frac + step) {
- res = quadfrac(s0, s1, s2, frac);
+ res = aubio_quadfrac(s0, s1, s2, frac);
if (res > resold)
resold = res;
else {
@@ -330,7 +330,7 @@
return exactpos;
}
-smpl_t quadfrac(smpl_t s0, smpl_t s1, smpl_t s2, smpl_t pf) {
+smpl_t aubio_quadfrac(smpl_t s0, smpl_t s1, smpl_t s2, smpl_t pf) {
smpl_t tmp = s0 + (pf/2.) * (pf * ( s0 - 2.*s1 + s2 ) - 3.*s0 + 4.*s1 - s2);
return tmp;
}
@@ -344,7 +344,7 @@
return tmp;
}
-smpl_t freqtomidi(smpl_t freq) {
+smpl_t aubio_freqtomidi(smpl_t freq) {
smpl_t midi = freq/6.875;
/* log(freq/A-2)/log(2) */
midi = LOG(midi)/0.69314718055995;
@@ -353,15 +353,15 @@
return midi;
}
-smpl_t bintofreq(smpl_t bin, smpl_t samplerate, smpl_t fftsize) {
+smpl_t aubio_bintofreq(smpl_t bin, smpl_t samplerate, smpl_t fftsize) {
smpl_t freq = samplerate/fftsize;
return freq*bin;
}
-smpl_t bintomidi(smpl_t bin, smpl_t samplerate, smpl_t fftsize) {
- smpl_t midi = bintofreq(bin,samplerate,fftsize);
- return freqtomidi(midi);
+smpl_t aubio_bintomidi(smpl_t bin, smpl_t samplerate, smpl_t fftsize) {
+ smpl_t midi = aubio_bintofreq(bin,samplerate,fftsize);
+ return aubio_freqtomidi(midi);
}
--- a/src/mathutils.h
+++ b/src/mathutils.h
@@ -103,16 +103,16 @@
aubio_win_gaussian,
aubio_win_welch,
aubio_win_parzen
-} aubio_window_type_t;
+} aubio_window_type;
/** create window */
-void window(smpl_t *w, uint_t size, aubio_window_type_t wintype);
+void aubio_window(smpl_t *w, uint_t size, aubio_window_type wintype);
/** principal argument
*
* mod(phase+PI,-TWO_PI)+PI
*/
-smpl_t unwrap2pi (smpl_t phase);
+smpl_t aubio_unwrap2pi (smpl_t phase);
/** calculates the mean of a vector
*
@@ -224,14 +224,14 @@
* \param s0,s1,s2 are 3 known points on the curve,
* \param pf is the floating point index [0;2]
*/
-smpl_t quadfrac(smpl_t s0, smpl_t s1, smpl_t s2, smpl_t pf);
+smpl_t aubio_quadfrac(smpl_t s0, smpl_t s1, smpl_t s2, smpl_t pf);
/** returns 1 if X1 is a peak and positive */
uint_t vec_peakpick(fvec_t * input, uint_t pos);
-smpl_t bintomidi(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
-smpl_t bintofreq(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
-smpl_t freqtomidi(smpl_t freq);
+smpl_t aubio_bintomidi(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
+smpl_t aubio_bintofreq(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
+smpl_t aubio_freqtomidi(smpl_t freq);
uint_t aubio_silence_detection(fvec_t * ibuf, smpl_t threshold);
smpl_t aubio_level_detection(fvec_t * ibuf, smpl_t threshold);
--- a/src/onsetdetection.c
+++ b/src/onsetdetection.c
@@ -73,7 +73,7 @@
for (i=0;i<fftgrain->channels; i++) {
onset->data[i][0] = 0.;
for (j=0;j<nbins; j++) {
- o->dev1->data[i][j] = unwrap2pi(
+ o->dev1->data[i][j] = aubio_unwrap2pi(
fftgrain->phas[i][j]
-2.0*o->theta1->data[i][j]+
o->theta2->data[i][j]);
@@ -103,7 +103,7 @@
o->dev1->data[i][0]=0.;
for ( j=0;j<nbins; j++ ) {
o->dev1->data[i][j] =
- unwrap2pi(
+ aubio_unwrap2pi(
fftgrain->phas[i][j]
-2.0*o->theta1->data[i][j]
+o->theta2->data[i][j]);
--- a/src/phasevoc.c
+++ b/src/phasevoc.c
@@ -113,7 +113,7 @@
pv->dataold = new_fvec (win_s-hop_s, channels);
pv->synthold = new_fvec (win_s-hop_s, channels);
pv->w = AUBIO_ARRAY(smpl_t,win_s);
- window(pv->w,win_s,aubio_win_hanningz);
+ aubio_window(pv->w,win_s,aubio_win_hanningz);
pv->channels = channels;
pv->hop_s = hop_s;
--- a/src/pitchdetection.c
+++ b/src/pitchdetection.c
@@ -138,9 +138,9 @@
smpl_t pitch = 0.;
aubio_pvoc_do(p->pv,ibuf,p->fftgrain);
pitch = aubio_pitchmcomb_detect(p->mcomb,p->fftgrain);
- /** \bug should move the >0 check within bintofreq */
+ /** \bug should move the >0 check within aubio_bintofreq */
if (pitch>0.) {
- pitch = bintofreq(pitch,p->srate,p->bufsize);
+ pitch = aubio_bintofreq(pitch,p->srate,p->bufsize);
} else {
pitch = 0.;
}
--- a/src/pitchfcomb.c
+++ b/src/pitchfcomb.c
@@ -90,7 +90,7 @@
tmp -= (smpl_t)k*phaseDifference;
/* map delta phase into +/- Pi interval */
- tmp = unwrap2pi(tmp);
+ tmp = aubio_unwrap2pi(tmp);
/* get deviation from bin frequency from the +/- Pi interval */
tmp = p->fftSize/input->length*tmp/(TWO_PI);
--- a/src/tss.c
+++ b/src/tss.c
@@ -55,7 +55,7 @@
/* second phase derivative */
for (i=0;i<channels; i++){
for (j=0;j<nbins; j++){
- dev[i][j] = unwrap2pi(input->phas[i][j]
+ dev[i][j] = aubio_unwrap2pi(input->phas[i][j]
-2.0*theta1[i][j]+theta2[i][j]);
theta2[i][j] = theta1[i][j];
theta1[i][j] = input->phas[i][j];
--- a/swig/aubio.i
+++ b/swig/aubio.i
@@ -97,10 +97,10 @@
aubio_win_gaussian,
aubio_win_welch,
aubio_win_parzen
-} aubio_window_type_t;
+} aubio_window_type;
-void window(smpl_t *w, uint_t size, aubio_window_type_t wintype);
-smpl_t unwrap2pi (smpl_t phase);
+void aubio_window(smpl_t *w, uint_t size, aubio_window_type wintype);
+smpl_t aubio_unwrap2pi (smpl_t phase);
smpl_t vec_mean(fvec_t *s);
smpl_t vec_max(fvec_t *s);
smpl_t vec_min(fvec_t *s);
@@ -118,11 +118,11 @@
smpl_t vec_moving_thres(fvec_t * vec, fvec_t * tmp, uint_t post, uint_t pre, uint_t pos);
smpl_t vec_median(fvec_t * input);
smpl_t vec_quadint(fvec_t * x,uint_t pos);
-smpl_t quadfrac(smpl_t s0, smpl_t s1, smpl_t s2, smpl_t pf);
+smpl_t aubio_quadfrac(smpl_t s0, smpl_t s1, smpl_t s2, smpl_t pf);
uint_t vec_peakpick(fvec_t * input, uint_t pos);
-smpl_t bintomidi(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
-smpl_t bintofreq(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
-smpl_t freqtomidi(smpl_t freq);
+smpl_t aubio_bintomidi(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
+smpl_t aubio_bintofreq(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
+smpl_t aubio_freqtomidi(smpl_t freq);
uint_t aubio_silence_detection(fvec_t * ibuf, smpl_t threshold);
smpl_t aubio_level_detection(fvec_t * ibuf, smpl_t threshold);