#ifndef MATHUTILS_H
#define MATHUTILS_H
-#define PI (M_PI)
-#define TWO_PI (PI*2.)
-
-/* aliases to math.h functions */
-#define EXP expf
-#define COS cosf
-#define SIN sinf
-#define ABS fabsf
-#define POW powf
-#define SQRT sqrtf
-#define LOG10 log10f
-#define LOG logf
-#define FLOOR floorf
-#define TRUNC truncf
-
-/* aliases to complex.h functions */
-#if defined(WIN32)
-/* mingw32 does not know about c*f functions */
-#define EXPC cexp
-/** complex = CEXPC(complex) */
-#define CEXPC cexp
-/** sample = ARGC(complex) */
-#define ARGC carg
-/** sample = ABSC(complex) norm */
-#define ABSC cabs
-/** sample = REAL(complex) */
-#define REAL creal
-/** sample = IMAG(complex) */
-#define IMAG cimag
-#else
-/** sample = EXPC(complex) */
-#define EXPC cexpf
-/** complex = CEXPC(complex) */
-#define CEXPC cexp
-/** sample = ARGC(complex) */
-#define ARGC cargf
-/** sample = ABSC(complex) norm */
-#define ABSC cabsf
-/** sample = REAL(complex) */
-#define REAL crealf
-/** sample = IMAG(complex) */
-#define IMAG cimagf
-#endif
-
-/* handy shortcuts */
-#define DB2LIN(g) (POW(10.0f,(g)*0.05f))
-#define LIN2DB(v) (20.0f*LOG10(v))
-#define SQR(_a) (_a*_a)
-
-#define ELEM_SWAP(a,b) { register smpl_t t=(a);(a)=(b);(b)=t; }
-
/** Window types
*
* inspired from
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
*
*/
smpl_t vec_median(fvec_t * input);
-/** finds exact peak position by quadratic interpolation*/
+/** finds exact maximum position by quadratic interpolation*/
smpl_t vec_quadint(fvec_t * x,uint_t pos);
+/** finds exact minimum position by quadratic interpolation*/
+smpl_t vec_quadint_min(fvec_t * x,uint_t pos, uint_t span);
+
/** Quadratic interpolation using Lagrange polynomial.
*
* inspired from ``Comparison of interpolation algorithms in real-time sound
* \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_miditobin(smpl_t midi, smpl_t samplerate, smpl_t fftsize);
+smpl_t aubio_bintofreq(smpl_t bin, smpl_t samplerate, smpl_t fftsize);
+smpl_t aubio_freqtobin(smpl_t freq, smpl_t samplerate, smpl_t fftsize);
+smpl_t aubio_freqtomidi(smpl_t freq);
+smpl_t aubio_miditofreq(smpl_t midi);
uint_t aubio_silence_detection(fvec_t * ibuf, smpl_t threshold);
smpl_t aubio_level_detection(fvec_t * ibuf, smpl_t threshold);
* calculate normalised autocorrelation function
*/
void aubio_autocorr(fvec_t * input, fvec_t * output);
+/**
+ * clean up cached memory at the end of program
+ *
+ * use this function at the end of programs to purge all
+ * cached memory. so far this function is only used to clean
+ * fftw cache.
+ */
+void aubio_cleanup(void);
#ifdef __cplusplus
}