[96fb8ad] | 1 | /* |
---|
[b235c0e] | 2 | Copyright (C) 2003-2013 Paul Brossier <piem@aubio.org> |
---|
[e6a78ea] | 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 | */ |
---|
[96fb8ad] | 20 | |
---|
[6f42c16] | 21 | #ifndef AUBIO_PITCH_H |
---|
| 22 | #define AUBIO_PITCH_H |
---|
[96fb8ad] | 23 | |
---|
| 24 | #ifdef __cplusplus |
---|
| 25 | extern "C" { |
---|
| 26 | #endif |
---|
| 27 | |
---|
[f44b111] | 28 | /** \file |
---|
| 29 | |
---|
[f0dd5fb] | 30 | Pitch detection object |
---|
[f44b111] | 31 | |
---|
| 32 | This file creates the objects required for the computation of the selected |
---|
| 33 | pitch detection algorithm and output the results, in midi note or Hz. |
---|
| 34 | |
---|
[f0dd5fb] | 35 | \section pitch Pitch detection methods |
---|
| 36 | |
---|
| 37 | A list of the pitch detection methods currently available follows. |
---|
| 38 | |
---|
| 39 | \b \p default : use the default method |
---|
| 40 | |
---|
| 41 | Currently, the default method is set to \p yinfft . |
---|
| 42 | |
---|
| 43 | \b \p schmitt : Schmitt trigger |
---|
| 44 | |
---|
| 45 | This pitch extraction method implements a Schmitt trigger to estimate the |
---|
| 46 | period of a signal. |
---|
| 47 | |
---|
| 48 | This file was derived from the tuneit project, written by Mario Lang to |
---|
| 49 | detect the fundamental frequency of a sound. |
---|
| 50 | |
---|
| 51 | See http://delysid.org/tuneit.html |
---|
| 52 | |
---|
| 53 | \b \p fcomb : a fast harmonic comb filter |
---|
| 54 | |
---|
| 55 | This pitch extraction method implements a fast harmonic comb filter to |
---|
| 56 | determine the fundamental frequency of a harmonic sound. |
---|
| 57 | |
---|
| 58 | This file was derived from the tuneit project, written by Mario Lang to |
---|
| 59 | detect the fundamental frequency of a sound. |
---|
| 60 | |
---|
| 61 | See http://delysid.org/tuneit.html |
---|
| 62 | |
---|
| 63 | \b \p mcomb : multiple-comb filter |
---|
| 64 | |
---|
| 65 | This fundamental frequency estimation algorithm implements spectral |
---|
| 66 | flattening, multi-comb filtering and peak histogramming. |
---|
| 67 | |
---|
| 68 | This method was designed by Juan P. Bello and described in: |
---|
| 69 | |
---|
| 70 | Juan-Pablo Bello. ``Towards the Automated Analysis of Simple Polyphonic |
---|
| 71 | Music''. PhD thesis, Centre for Digital Music, Queen Mary University of |
---|
| 72 | London, London, UK, 2003. |
---|
| 73 | |
---|
| 74 | \b \p yin : YIN algorithm |
---|
| 75 | |
---|
[7f0fd1d] | 76 | This algorithm was developed by A. de Cheveigne and H. Kawahara and |
---|
[f0dd5fb] | 77 | published in: |
---|
| 78 | |
---|
| 79 | De Cheveigné, A., Kawahara, H. (2002) "YIN, a fundamental frequency |
---|
| 80 | estimator for speech and music", J. Acoust. Soc. Am. 111, 1917-1930. |
---|
| 81 | |
---|
| 82 | see http://recherche.ircam.fr/equipes/pcm/pub/people/cheveign.html |
---|
| 83 | |
---|
[482641d] | 84 | \b \p yinfast : Yinfast algorithm |
---|
[48fa81d] | 85 | |
---|
| 86 | This algorithm is equivalent to the YIN algorithm, but computed in the |
---|
| 87 | spectral domain for efficiency. See also `python/demos/demo_yin_compare.py`. |
---|
| 88 | |
---|
[f0dd5fb] | 89 | \b \p yinfft : Yinfft algorithm |
---|
| 90 | |
---|
| 91 | This algorithm was derived from the YIN algorithm. In this implementation, a |
---|
| 92 | Fourier transform is used to compute a tapered square difference function, |
---|
| 93 | which allows spectral weighting. Because the difference function is tapered, |
---|
| 94 | the selection of the period is simplified. |
---|
| 95 | |
---|
| 96 | Paul Brossier, [Automatic annotation of musical audio for interactive |
---|
| 97 | systems](http://aubio.org/phd/), Chapter 3, Pitch Analysis, PhD thesis, |
---|
| 98 | Centre for Digital music, Queen Mary University of London, London, UK, 2006. |
---|
| 99 | |
---|
[69b11d8] | 100 | \example pitch/test-pitch.c |
---|
[f0dd5fb] | 101 | \example examples/aubiopitch.c |
---|
[69b11d8] | 102 | |
---|
[f44b111] | 103 | */ |
---|
| 104 | |
---|
| 105 | /** pitch detection object */ |
---|
[ca1abdd] | 106 | typedef struct _aubio_pitch_t aubio_pitch_t; |
---|
[f44b111] | 107 | |
---|
| 108 | /** execute pitch detection on an input signal frame |
---|
[6d4ec49] | 109 | |
---|
[ca1abdd] | 110 | \param o pitch detection object as returned by new_aubio_pitch() |
---|
[168337e] | 111 | \param in input signal of size [hop_size] |
---|
| 112 | \param out output pitch candidates of size [1] |
---|
[6d4ec49] | 113 | |
---|
[f44b111] | 114 | */ |
---|
[ce3ff2b] | 115 | void aubio_pitch_do (aubio_pitch_t * o, const fvec_t * in, fvec_t * out); |
---|
[96fb8ad] | 116 | |
---|
[f44b111] | 117 | /** change yin or yinfft tolerance threshold |
---|
[6d4ec49] | 118 | |
---|
[ca1abdd] | 119 | \param o pitch detection object as returned by new_aubio_pitch() |
---|
[93177fa] | 120 | \param tol tolerance default is 0.15 for yin and 0.85 for yinfft |
---|
[6d4ec49] | 121 | |
---|
[f44b111] | 122 | */ |
---|
[fddfa64] | 123 | uint_t aubio_pitch_set_tolerance (aubio_pitch_t * o, smpl_t tol); |
---|
[f44b111] | 124 | |
---|
[0cf2b44] | 125 | /** get yin or yinfft tolerance threshold |
---|
| 126 | |
---|
| 127 | \param o pitch detection object as returned by new_aubio_pitch() |
---|
| 128 | \return tolerance (default is 0.15 for yin and 0.85 for yinfft) |
---|
| 129 | |
---|
| 130 | */ |
---|
| 131 | smpl_t aubio_pitch_get_tolerance (aubio_pitch_t * o); |
---|
| 132 | |
---|
[f44b111] | 133 | /** deletion of the pitch detection object |
---|
[6d4ec49] | 134 | |
---|
[ca1abdd] | 135 | \param o pitch detection object as returned by new_aubio_pitch() |
---|
[6d4ec49] | 136 | |
---|
[f44b111] | 137 | */ |
---|
[ca1abdd] | 138 | void del_aubio_pitch (aubio_pitch_t * o); |
---|
[96fb8ad] | 139 | |
---|
[f44b111] | 140 | /** creation of the pitch detection object |
---|
[6d4ec49] | 141 | |
---|
[3ac7cb0] | 142 | \param method set pitch detection algorithm |
---|
| 143 | \param buf_size size of the input buffer to analyse |
---|
| 144 | \param hop_size step size between two consecutive analysis instant |
---|
[6d4ec49] | 145 | \param samplerate sampling rate of the signal |
---|
| 146 | |
---|
[f0dd5fb] | 147 | \return newly created ::aubio_pitch_t |
---|
| 148 | |
---|
[f44b111] | 149 | */ |
---|
[ce3ff2b] | 150 | aubio_pitch_t *new_aubio_pitch (const char_t * method, |
---|
[168337e] | 151 | uint_t buf_size, uint_t hop_size, uint_t samplerate); |
---|
[fe163ad] | 152 | |
---|
[f0dd5fb] | 153 | /** set the output unit of the pitch detection object |
---|
[93177fa] | 154 | |
---|
[ca1abdd] | 155 | \param o pitch detection object as returned by new_aubio_pitch() |
---|
[93177fa] | 156 | \param mode set pitch units for output |
---|
| 157 | |
---|
[9ad0dcc] | 158 | mode can be one of "Hz", "midi", "cent", or "bin". Defaults to "Hz". |
---|
| 159 | |
---|
[4b7a740] | 160 | \return 0 if successfull, non-zero otherwise |
---|
| 161 | |
---|
[93177fa] | 162 | */ |
---|
[ce3ff2b] | 163 | uint_t aubio_pitch_set_unit (aubio_pitch_t * o, const char_t * mode); |
---|
[96fb8ad] | 164 | |
---|
[8c3f717] | 165 | /** set the silence threshold of the pitch detection object |
---|
| 166 | |
---|
| 167 | \param o pitch detection object as returned by new_aubio_pitch() |
---|
| 168 | \param silence level threshold under which pitch should be ignored, in dB |
---|
| 169 | |
---|
[4b7a740] | 170 | \return 0 if successfull, non-zero otherwise |
---|
| 171 | |
---|
[8c3f717] | 172 | */ |
---|
| 173 | uint_t aubio_pitch_set_silence (aubio_pitch_t * o, smpl_t silence); |
---|
| 174 | |
---|
| 175 | /** set the silence threshold of the pitch detection object |
---|
| 176 | |
---|
[4b7a740] | 177 | \param o pitch detection object as returned by ::new_aubio_pitch() |
---|
[8c3f717] | 178 | |
---|
[4b7a740] | 179 | \return level threshold under which pitch should be ignored, in dB |
---|
[8c3f717] | 180 | |
---|
| 181 | */ |
---|
| 182 | smpl_t aubio_pitch_get_silence (aubio_pitch_t * o); |
---|
| 183 | |
---|
[426e6f7] | 184 | /** get the current confidence |
---|
| 185 | |
---|
| 186 | \param o pitch detection object as returned by new_aubio_pitch() |
---|
| 187 | |
---|
[4b7a740] | 188 | \return the current confidence of the pitch algorithm |
---|
[426e6f7] | 189 | |
---|
| 190 | */ |
---|
| 191 | smpl_t aubio_pitch_get_confidence (aubio_pitch_t * o); |
---|
| 192 | |
---|
[96fb8ad] | 193 | #ifdef __cplusplus |
---|
| 194 | } |
---|
| 195 | #endif |
---|
| 196 | |
---|
[6f42c16] | 197 | #endif /* AUBIO_PITCH_H */ |
---|