/usr/include/aubio/mathutils.h is in libaubio-dev 0.3.2-4.2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | /*
Copyright (C) 2003 Paul Brossier
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file
* various math functions
*
* \todo multichannel (each function should return -or set- an array sized to
* the number of channel in the input vector)
*
* \todo appropriate switches depending on types.h content
*/
#ifndef MATHUTILS_H
#define MATHUTILS_H
/** Window types
*
* inspired from
*
* - dafx : http://profs.sci.univr.it/%7Edafx/Final-Papers/ps/Bernardini.ps.gz
* - freqtweak : http://freqtweak.sf.net/
* - extace : http://extace.sf.net/
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
aubio_win_rectangle,
aubio_win_hamming,
aubio_win_hanning,
aubio_win_hanningz,
aubio_win_blackman,
aubio_win_blackman_harris,
aubio_win_gaussian,
aubio_win_welch,
aubio_win_parzen
} aubio_window_type;
/** create window */
void aubio_window(smpl_t *w, uint_t size, aubio_window_type wintype);
/** principal argument
*
* mod(phase+PI,-TWO_PI)+PI
*/
smpl_t aubio_unwrap2pi (smpl_t phase);
/** calculates the mean of a vector
*
* \bug mono
*/
smpl_t vec_mean(fvec_t *s);
/** returns the max of a vector
*
* \bug mono
*/
smpl_t vec_max(fvec_t *s);
/** returns the min of a vector
*
* \bug mono
*/
smpl_t vec_min(fvec_t *s);
/** returns the index of the min of a vector
*
* \bug mono
*/
uint_t vec_min_elem(fvec_t *s);
/** returns the index of the max of a vector
*
* \bug mono
*/
uint_t vec_max_elem(fvec_t *s);
/** implement 'fftshift' like function
*
* a[0]...,a[n/2],a[n/2+1],...a[n]
*
* becomes
*
* a[n/2+1],...a[n],a[0]...,a[n/2]
*/
void vec_shift(fvec_t *s);
/** returns sum */
smpl_t vec_sum(fvec_t *s);
/** returns energy
*
* \bug mono
*/
smpl_t vec_local_energy(fvec_t * f);
/** returns High Frequency Energy Content
*
* \bug mono */
smpl_t vec_local_hfc(fvec_t * f);
/** return alpha norm.
*
* alpha=2 means normalise variance.
* alpha=1 means normalise abs value.
* as alpha goes large, tends to normalisation
* by max value.
*
* \bug should not use POW :(
*/
smpl_t vec_alpha_norm(fvec_t * DF, smpl_t alpha);
/** dc(min) removal */
void vec_dc_removal(fvec_t * mag);
/** alpha normalisation */
void vec_alpha_normalise(fvec_t * mag, uint_t alpha);
/** add a constant to all members of a vector */
void vec_add(fvec_t * mag, smpl_t threshold);
/** compute adaptive threshold of input vector */
void vec_adapt_thres(fvec_t * vec, fvec_t * tmp,
uint_t win_post, uint_t win_pre);
/** adaptative thresholding
*
* y=fn_thresh(fn,x,post,pre)
* compute adaptive threshold at each time
* fn : a function name or pointer, eg 'median'
* x: signal vector
* post: window length, causal part
* pre: window length, anti-causal part
* Returns:
* y: signal the same length as x
*
* Formerly median_thresh, used compute median over a
* window of post+pre+1 samples, but now works with any
* function that takes a vector or matrix and returns a
* 'representative' value for each column, eg
* medians=fn_thresh(median,x,8,8)
* minima=fn_thresh(min,x,8,8)
* see SPARMS for explanation of post and pre
*/
smpl_t vec_moving_thres(fvec_t * vec, fvec_t * tmp,
uint_t win_post, uint_t win_pre, uint_t win_pos);
/** returns the median of the vector
*
* This Quickselect routine is based on the algorithm described in
* "Numerical recipes in C", Second Edition,
* Cambridge University Press, 1992, Section 8.5, ISBN 0-521-43108-5
*
* This code by Nicolas Devillard - 1998. Public domain,
* available at http://ndevilla.free.fr/median/median/
*/
smpl_t vec_median(fvec_t * input);
/** 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
* processing'', Vladimir Arnost,
*
* estimate = s0 + (pf/2.)*((pf-3.)*s0-2.*(pf-2.)*s1+(pf-1.)*s2);
* where
* \param s0,s1,s2 are 3 known points on the curve,
* \param pf is the floating point index [0;2]
*/
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);
/** 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);
/** check if current buffer level is under a given threshold */
uint_t aubio_silence_detection(fvec_t * ibuf, smpl_t threshold);
/** get the current buffer level */
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
}
#endif
#endif
|