2 Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
4 This file is part of aubio.
6 aubio is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 aubio is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with aubio. If not, see <http://www.gnu.org/licenses/>.
22 * various functions useful in audio signal processing
36 - <a href="http://en.wikipedia.org/wiki/Window_function">Window
37 function</a> on Wikipedia
38 - Amalia de Götzen, Nicolas Bernardini, and Daniel Arfib. Traditional (?)
39 implementations of a phase vocoder: the tricks of the trade. In Proceedings of
40 the International Conference on Digital Audio Effects (DAFx-00), pages 37–44,
41 Uni- versity of Verona, Italy, 2000.
42 (<a href="http://profs.sci.univr.it/%7Edafx/Final-Papers/ps/Bernardini.ps.gz">
46 fvec_t *new_aubio_window (char_t * window_type, uint_t size);
48 /** set elements of a vector to window coefficients
51 uint_t fvec_set_window (fvec_t * window, char_t * window_type);
53 /** compute the principal argument
55 This function maps the input phase to its corresponding value wrapped in the
56 range \f$ [-\pi, \pi] \f$.
58 \param phase unwrapped phase to map to the unit circle
60 \return equivalent phase wrapped to the unit circle
63 smpl_t aubio_unwrap2pi (smpl_t phase);
65 /** convert frequency bin to midi value */
66 smpl_t aubio_bintomidi (smpl_t bin, smpl_t samplerate, smpl_t fftsize);
68 /** convert midi value to frequency bin */
69 smpl_t aubio_miditobin (smpl_t midi, smpl_t samplerate, smpl_t fftsize);
71 /** convert frequency bin to frequency (Hz) */
72 smpl_t aubio_bintofreq (smpl_t bin, smpl_t samplerate, smpl_t fftsize);
74 /** convert frequency (Hz) to frequency bin */
75 smpl_t aubio_freqtobin (smpl_t freq, smpl_t samplerate, smpl_t fftsize);
77 /** convert frequency (Hz) to midi value (0-128) */
78 smpl_t aubio_freqtomidi (smpl_t freq);
80 /** convert midi value (0-128) to frequency (Hz) */
81 smpl_t aubio_miditofreq (smpl_t midi);
83 /** clean up cached memory at the end of program
85 This function should be used at the end of programs to purge all cached
86 memory. So far it is only useful to clean FFTW's cache.
89 void aubio_cleanup (void);
91 /** zero-crossing rate (ZCR)
93 The zero-crossing rate is the number of times a signal changes sign,
94 divided by the length of this signal.
96 \param v vector to compute ZCR from
98 \return zero-crossing rate of v
101 smpl_t aubio_zero_crossing_rate (fvec_t * v);
103 /** compute sound level on a linear
105 This gives the average of the square amplitudes.
107 \param v vector to compute dB SPL from
112 smpl_t aubio_level_lin (fvec_t * v);
114 /** compute sound pressure level (SPL) in dB
116 This quantity is often wrongly called 'loudness'.
118 This gives ten times the log10 of the average of the square amplitudes.
120 \param v vector to compute dB SPL from
122 \return level of v in dB SPL
125 smpl_t aubio_db_spl (fvec_t * v);
127 /** check if buffer level in dB SPL is under a given threshold
129 \param v vector to get level from
130 \param threshold threshold in dB SPL
132 \return 0 if level is under the given threshold, 1 otherwise
135 uint_t aubio_silence_detection (fvec_t * v, smpl_t threshold);
137 /** get buffer level if level >= threshold, 1. otherwise
139 \param v vector to get level from
140 \param threshold threshold in dB SPL
142 \return level in dB SPL if level >= threshold, 1. otherwise
145 smpl_t aubio_level_detection (fvec_t * v, smpl_t threshold);