aubio
0.4.1
|
00001 /* 00002 Copyright (C) 2003-2013 Paul Brossier <piem@aubio.org> 00003 00004 This file is part of aubio. 00005 00006 aubio is free software: you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation, either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 aubio is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with aubio. If not, see <http://www.gnu.org/licenses/>. 00018 00019 */ 00020 00021 /** @file 00022 * various functions useful in audio signal processing 00023 */ 00024 00025 #ifndef _AUBIO__MUSICUTILS_H 00026 #define _AUBIO__MUSICUTILS_H 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 /** create window 00033 00034 \param window_type type of the window to create 00035 \param size length of the window to create (see fvec_set_window()) 00036 00037 */ 00038 fvec_t *new_aubio_window (char_t * window_type, uint_t size); 00039 00040 /** set elements of a vector to window coefficients 00041 00042 \param window exsting ::fvec_t to use 00043 \param window_type type of the window to create 00044 00045 List of available window types: "rectangle", "hamming", "hanning", 00046 "hanningz", "blackman", "blackman_harris", "gaussian", "welch", "parzen", 00047 "default". 00048 00049 "default" is equivalent to "hanningz". 00050 00051 References: 00052 00053 - <a href="http://en.wikipedia.org/wiki/Window_function">Window 00054 function</a> on Wikipedia 00055 - Amalia de Götzen, Nicolas Bernardini, and Daniel Arfib. Traditional (?) 00056 implementations of a phase vocoder: the tricks of the trade. In Proceedings of 00057 the International Conference on Digital Audio Effects (DAFx-00), pages 37–44, 00058 Uni- versity of Verona, Italy, 2000. 00059 (<a href="http://profs.sci.univr.it/%7Edafx/Final-Papers/ps/Bernardini.ps.gz"> 00060 ps.gz</a>) 00061 00062 */ 00063 uint_t fvec_set_window (fvec_t * window, char_t * window_type); 00064 00065 /** compute the principal argument 00066 00067 This function maps the input phase to its corresponding value wrapped in the 00068 range \f$ [-\pi, \pi] \f$. 00069 00070 \param phase unwrapped phase to map to the unit circle 00071 00072 \return equivalent phase wrapped to the unit circle 00073 00074 */ 00075 smpl_t aubio_unwrap2pi (smpl_t phase); 00076 00077 /** convert frequency bin to midi value */ 00078 smpl_t aubio_bintomidi (smpl_t bin, smpl_t samplerate, smpl_t fftsize); 00079 00080 /** convert midi value to frequency bin */ 00081 smpl_t aubio_miditobin (smpl_t midi, smpl_t samplerate, smpl_t fftsize); 00082 00083 /** convert frequency bin to frequency (Hz) */ 00084 smpl_t aubio_bintofreq (smpl_t bin, smpl_t samplerate, smpl_t fftsize); 00085 00086 /** convert frequency (Hz) to frequency bin */ 00087 smpl_t aubio_freqtobin (smpl_t freq, smpl_t samplerate, smpl_t fftsize); 00088 00089 /** convert frequency (Hz) to midi value (0-128) */ 00090 smpl_t aubio_freqtomidi (smpl_t freq); 00091 00092 /** convert midi value (0-128) to frequency (Hz) */ 00093 smpl_t aubio_miditofreq (smpl_t midi); 00094 00095 /** clean up cached memory at the end of program 00096 00097 This function should be used at the end of programs to purge all cached 00098 memory. So far it is only useful to clean FFTW's cache. 00099 00100 */ 00101 void aubio_cleanup (void); 00102 00103 /** zero-crossing rate (ZCR) 00104 00105 The zero-crossing rate is the number of times a signal changes sign, 00106 divided by the length of this signal. 00107 00108 \param v vector to compute ZCR from 00109 00110 \return zero-crossing rate of v 00111 00112 */ 00113 smpl_t aubio_zero_crossing_rate (fvec_t * v); 00114 00115 /** compute sound level on a linear 00116 00117 This gives the average of the square amplitudes. 00118 00119 \param v vector to compute dB SPL from 00120 00121 \return level of v 00122 00123 */ 00124 smpl_t aubio_level_lin (fvec_t * v); 00125 00126 /** compute sound pressure level (SPL) in dB 00127 00128 This quantity is often wrongly called 'loudness'. 00129 00130 This gives ten times the log10 of the average of the square amplitudes. 00131 00132 \param v vector to compute dB SPL from 00133 00134 \return level of v in dB SPL 00135 00136 */ 00137 smpl_t aubio_db_spl (fvec_t * v); 00138 00139 /** check if buffer level in dB SPL is under a given threshold 00140 00141 \param v vector to get level from 00142 \param threshold threshold in dB SPL 00143 00144 \return 0 if level is under the given threshold, 1 otherwise 00145 00146 */ 00147 uint_t aubio_silence_detection (fvec_t * v, smpl_t threshold); 00148 00149 /** get buffer level if level >= threshold, 1. otherwise 00150 00151 \param v vector to get level from 00152 \param threshold threshold in dB SPL 00153 00154 \return level in dB SPL if level >= threshold, 1. otherwise 00155 00156 */ 00157 smpl_t aubio_level_detection (fvec_t * v, smpl_t threshold); 00158 00159 #ifdef __cplusplus 00160 } 00161 #endif 00162 00163 #endif /* _AUBIO__MUSICUTILS_H */