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 */
/* 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);
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) {
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);
#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:
}
-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));
}
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 {
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;
}
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;
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);
}
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
*
* \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);
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]);
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]);
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;
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.;
}
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);
/* 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];
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);
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);