strip down stable public API, defining add AUBIO_UNSTABLE to access unstable API
[aubio.git] / src / mathutils.h
index be1b465f528b4ccf5af869f4fe1b2d725cb7e91d..9c545e00a5eb99eefc760c862e3df4255a96b51b 100644 (file)
 #ifndef MATHUTILS_H
 #define MATHUTILS_H
 
+#include "fvec.h"
+#include "musicutils.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-/** create window 
-  References:
-    
-    - <a href="http://en.wikipedia.org/wiki/Window_function">Window
-function</a> on Wikipedia
-    - Amalia de Götzen, Nicolas Bernardini, and Daniel Arfib. Traditional (?)
-implementations of a phase vocoder: the tricks of the trade. In Proceedings of
-the International Conference on Digital Audio Effects (DAFx-00), pages 37–44,
-Uni- versity of Verona, Italy, 2000.
-  (<a href="http://profs.sci.univr.it/%7Edafx/Final-Papers/ps/Bernardini.ps.gz">
-  ps.gz</a>)
-
-*/
-fvec_t *new_aubio_window (char_t * window_type, uint_t size);
-
-/** compute the principal argument
+/** compute the mean of a vector
 
-  This function maps the input phase to its corresponding value wrapped in the
-range \f$ [-\pi, \pi] \f$.
+  \param s vector to compute mean from
 
-  \param phase unwrapped phase to map to the unit circle
-  
-  \return equivalent phase wrapped to the unit circle
+  \return the mean of v
 
 */
-smpl_t aubio_unwrap2pi (smpl_t phase);
+smpl_t fvec_mean (fvec_t * s);
 
-/** compute the mean of a vector
+/** compute the mean of a vector channel
 
-  \param s vector to compute norm from
+  \param s vector to compute mean from
+  \param i channel to compute mean from
 
   \return the mean of v
 
 */
-smpl_t fvec_mean (fvec_t * s);
+smpl_t fvec_mean_channel (fvec_t * s, uint_t i);
 
 /** find the max of a vector
 
@@ -219,7 +204,7 @@ pre elements after pos.
 
 */
 smpl_t fvec_moving_thres (fvec_t * v, fvec_t * tmp, uint_t post, uint_t pre,
-    uint_t pos);
+    uint_t pos, uint_t channel);
 
 /** apply adaptive threshold to a vector
 
@@ -232,7 +217,8 @@ moving median threshold computed at p.
   \param pre length of anti-causal part to take after pos
 
 */
-void fvec_adapt_thres (fvec_t * v, fvec_t * tmp, uint_t post, uint_t pre);
+void fvec_adapt_thres (fvec_t * v, fvec_t * tmp, uint_t post, uint_t pre, 
+    uint_t channel);
 
 /** returns the median of a vector 
 
@@ -245,14 +231,15 @@ Devillard's implementation, available at http://ndevilla.free.fr/median/median/
 and in the Public Domain.
 
   \param v vector to get median from
+  \param channel channel to get median from
 
   \return the median of v
  
 */
-smpl_t fvec_median (fvec_t * v);
+smpl_t fvec_median_channel (fvec_t * v, uint_t channel);
 
 /** finds exact peak index by quadratic interpolation*/
-smpl_t fvec_quadint (fvec_t * x, uint_t pos, uint_t span);
+smpl_t fvec_quadint (fvec_t * x, uint_t pos, uint_t channel);
 
 /** Quadratic interpolation using Lagrange polynomial.
  
@@ -284,61 +271,12 @@ peak is defined as follows:
 */
 uint_t fvec_peakpick (fvec_t * v, uint_t p);
 
-/** convert frequency bin to midi value */
-smpl_t aubio_bintomidi (smpl_t bin, smpl_t samplerate, smpl_t fftsize);
-
-/** convert midi value to frequency bin */
-smpl_t aubio_miditobin (smpl_t midi, smpl_t samplerate, smpl_t fftsize);
-
-/** convert frequency bin to frequency (Hz) */
-smpl_t aubio_bintofreq (smpl_t bin, smpl_t samplerate, smpl_t fftsize);
-
-/** convert frequency (Hz) to frequency bin */
-smpl_t aubio_freqtobin (smpl_t freq, smpl_t samplerate, smpl_t fftsize);
-
-/** convert frequency (Hz) to midi value (0-128) */
-smpl_t aubio_freqtomidi (smpl_t freq);
-
-/** convert midi value (0-128) to frequency (Hz) */
-smpl_t aubio_miditofreq (smpl_t midi);
-
 /** return 1 if a is a power of 2, 0 otherwise */
 uint_t aubio_is_power_of_two(uint_t a);
 
 /** return the next power of power of 2 greater than a */
 uint_t aubio_next_power_of_two(uint_t a);
 
-/** compute sound pressure level (SPL) in dB
-
-  This quantity is often wrongly called 'loudness'.
-
-  \param v vector to compute dB SPL from
-
-  \return level of v in dB SPL
-
-*/
-smpl_t aubio_db_spl (fvec_t * v);
-
-/** check if buffer level in dB SPL is under a given threshold
-  \param v vector to get level from
-  \param threshold threshold in dB SPL
-
-  \return 0 if level is under the given threshold, 1 otherwise
-
-*/
-uint_t aubio_silence_detection (fvec_t * v, smpl_t threshold);
-
-/** get buffer level if level >= threshold, 1. otherwise
-
-  \param v vector to get level from
-  \param threshold threshold in dB SPL
-
-  \return level in dB SPL if level >= threshold, 1. otherwise
-
-*/
-smpl_t aubio_level_detection (fvec_t * v, smpl_t threshold);
-
 /** compute normalised autocorrelation function
 
   \param input vector to compute autocorrelation from
@@ -347,26 +285,6 @@ smpl_t aubio_level_detection (fvec_t * v, smpl_t threshold);
 */
 void aubio_autocorr (fvec_t * input, fvec_t * output);
 
-/** zero-crossing rate (ZCR)
-
-  The zero-crossing rate is the number of times a signal changes sign,
-  divided by the length of this signal.
-
-  \param v vector to compute ZCR from
-
-  \return zero-crossing rate of v
-
-*/
-smpl_t aubio_zero_crossing_rate (fvec_t * v);
-
-/** clean up cached memory at the end of program
-  This function should be used at the end of programs to purge all cached
-  memory. So far it is only useful to clean FFTW's cache.
-
-*/
-void aubio_cleanup (void);
-
 #ifdef __cplusplus
 }
 #endif