[83963b3] | 1 | /* |
---|
| 2 | Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org> |
---|
| 3 | |
---|
| 4 | This file is part of aubio. |
---|
| 5 | |
---|
| 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. |
---|
| 10 | |
---|
| 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. |
---|
| 15 | |
---|
| 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/>. |
---|
| 18 | |
---|
| 19 | */ |
---|
| 20 | |
---|
| 21 | /** @file |
---|
[a17e8c9] | 22 | * various functions useful in audio signal processing |
---|
[83963b3] | 23 | */ |
---|
| 24 | |
---|
| 25 | #ifndef MUSICUTILS_H |
---|
| 26 | #define MUSICUTILS_H |
---|
| 27 | |
---|
| 28 | #ifdef __cplusplus |
---|
| 29 | extern "C" { |
---|
| 30 | #endif |
---|
| 31 | |
---|
| 32 | /** create window |
---|
| 33 | |
---|
| 34 | References: |
---|
| 35 | |
---|
| 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"> |
---|
| 43 | ps.gz</a>) |
---|
| 44 | |
---|
| 45 | */ |
---|
| 46 | fvec_t *new_aubio_window (char_t * window_type, uint_t size); |
---|
| 47 | |
---|
[33cd81f] | 48 | /** set elements of a vector to window coefficients |
---|
| 49 | |
---|
| 50 | */ |
---|
| 51 | uint_t fvec_set_window (fvec_t * window, char_t * window_type); |
---|
| 52 | |
---|
[83963b3] | 53 | /** compute the principal argument |
---|
| 54 | |
---|
| 55 | This function maps the input phase to its corresponding value wrapped in the |
---|
| 56 | range \f$ [-\pi, \pi] \f$. |
---|
| 57 | |
---|
| 58 | \param phase unwrapped phase to map to the unit circle |
---|
| 59 | |
---|
| 60 | \return equivalent phase wrapped to the unit circle |
---|
| 61 | |
---|
| 62 | */ |
---|
| 63 | smpl_t aubio_unwrap2pi (smpl_t phase); |
---|
| 64 | |
---|
| 65 | /** convert frequency bin to midi value */ |
---|
| 66 | smpl_t aubio_bintomidi (smpl_t bin, smpl_t samplerate, smpl_t fftsize); |
---|
| 67 | |
---|
| 68 | /** convert midi value to frequency bin */ |
---|
| 69 | smpl_t aubio_miditobin (smpl_t midi, smpl_t samplerate, smpl_t fftsize); |
---|
| 70 | |
---|
| 71 | /** convert frequency bin to frequency (Hz) */ |
---|
| 72 | smpl_t aubio_bintofreq (smpl_t bin, smpl_t samplerate, smpl_t fftsize); |
---|
| 73 | |
---|
| 74 | /** convert frequency (Hz) to frequency bin */ |
---|
| 75 | smpl_t aubio_freqtobin (smpl_t freq, smpl_t samplerate, smpl_t fftsize); |
---|
| 76 | |
---|
| 77 | /** convert frequency (Hz) to midi value (0-128) */ |
---|
| 78 | smpl_t aubio_freqtomidi (smpl_t freq); |
---|
| 79 | |
---|
| 80 | /** convert midi value (0-128) to frequency (Hz) */ |
---|
| 81 | smpl_t aubio_miditofreq (smpl_t midi); |
---|
| 82 | |
---|
| 83 | /** clean up cached memory at the end of program |
---|
| 84 | |
---|
| 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. |
---|
| 87 | |
---|
| 88 | */ |
---|
| 89 | void aubio_cleanup (void); |
---|
| 90 | |
---|
| 91 | /** zero-crossing rate (ZCR) |
---|
| 92 | |
---|
| 93 | The zero-crossing rate is the number of times a signal changes sign, |
---|
| 94 | divided by the length of this signal. |
---|
| 95 | |
---|
| 96 | \param v vector to compute ZCR from |
---|
| 97 | |
---|
| 98 | \return zero-crossing rate of v |
---|
| 99 | |
---|
| 100 | */ |
---|
| 101 | smpl_t aubio_zero_crossing_rate (fvec_t * v); |
---|
| 102 | |
---|
[5b41ef9] | 103 | /** compute sound level on a linear |
---|
| 104 | |
---|
| 105 | This gives the average of the square amplitudes. |
---|
| 106 | |
---|
| 107 | \param v vector to compute dB SPL from |
---|
| 108 | |
---|
| 109 | \return level of v |
---|
| 110 | |
---|
| 111 | */ |
---|
| 112 | smpl_t aubio_level_lin (fvec_t * v); |
---|
| 113 | |
---|
[83963b3] | 114 | /** compute sound pressure level (SPL) in dB |
---|
| 115 | |
---|
| 116 | This quantity is often wrongly called 'loudness'. |
---|
| 117 | |
---|
[5b41ef9] | 118 | This gives ten times the log10 of the average of the square amplitudes. |
---|
| 119 | |
---|
[83963b3] | 120 | \param v vector to compute dB SPL from |
---|
| 121 | |
---|
| 122 | \return level of v in dB SPL |
---|
| 123 | |
---|
| 124 | */ |
---|
| 125 | smpl_t aubio_db_spl (fvec_t * v); |
---|
| 126 | |
---|
| 127 | /** check if buffer level in dB SPL is under a given threshold |
---|
| 128 | |
---|
| 129 | \param v vector to get level from |
---|
| 130 | \param threshold threshold in dB SPL |
---|
| 131 | |
---|
| 132 | \return 0 if level is under the given threshold, 1 otherwise |
---|
| 133 | |
---|
| 134 | */ |
---|
| 135 | uint_t aubio_silence_detection (fvec_t * v, smpl_t threshold); |
---|
| 136 | |
---|
| 137 | /** get buffer level if level >= threshold, 1. otherwise |
---|
| 138 | |
---|
| 139 | \param v vector to get level from |
---|
| 140 | \param threshold threshold in dB SPL |
---|
| 141 | |
---|
| 142 | \return level in dB SPL if level >= threshold, 1. otherwise |
---|
| 143 | |
---|
| 144 | */ |
---|
| 145 | smpl_t aubio_level_detection (fvec_t * v, smpl_t threshold); |
---|
| 146 | |
---|
| 147 | #ifdef __cplusplus |
---|
| 148 | } |
---|
| 149 | #endif |
---|
| 150 | |
---|
| 151 | #endif |
---|
| 152 | |
---|