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 #ifndef AUBIO_PITCH_H 00022 #define AUBIO_PITCH_H 00023 00024 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 /** \file 00029 00030 Pitch detection object 00031 00032 This file creates the objects required for the computation of the selected 00033 pitch detection algorithm and output the results, in midi note or Hz. 00034 00035 \section pitch Pitch detection methods 00036 00037 A list of the pitch detection methods currently available follows. 00038 00039 \b \p default : use the default method 00040 00041 Currently, the default method is set to \p yinfft . 00042 00043 \b \p schmitt : Schmitt trigger 00044 00045 This pitch extraction method implements a Schmitt trigger to estimate the 00046 period of a signal. 00047 00048 This file was derived from the tuneit project, written by Mario Lang to 00049 detect the fundamental frequency of a sound. 00050 00051 See http://delysid.org/tuneit.html 00052 00053 \b \p fcomb : a fast harmonic comb filter 00054 00055 This pitch extraction method implements a fast harmonic comb filter to 00056 determine the fundamental frequency of a harmonic sound. 00057 00058 This file was derived from the tuneit project, written by Mario Lang to 00059 detect the fundamental frequency of a sound. 00060 00061 See http://delysid.org/tuneit.html 00062 00063 \b \p mcomb : multiple-comb filter 00064 00065 This fundamental frequency estimation algorithm implements spectral 00066 flattening, multi-comb filtering and peak histogramming. 00067 00068 This method was designed by Juan P. Bello and described in: 00069 00070 Juan-Pablo Bello. ``Towards the Automated Analysis of Simple Polyphonic 00071 Music''. PhD thesis, Centre for Digital Music, Queen Mary University of 00072 London, London, UK, 2003. 00073 00074 \b \p yin : YIN algorithm 00075 00076 This algorithm was developed by A. de Cheveigne and H. Kawahara and 00077 published in: 00078 00079 De Cheveigné, A., Kawahara, H. (2002) "YIN, a fundamental frequency 00080 estimator for speech and music", J. Acoust. Soc. Am. 111, 1917-1930. 00081 00082 see http://recherche.ircam.fr/equipes/pcm/pub/people/cheveign.html 00083 00084 \b \p yinfft : Yinfft algorithm 00085 00086 This algorithm was derived from the YIN algorithm. In this implementation, a 00087 Fourier transform is used to compute a tapered square difference function, 00088 which allows spectral weighting. Because the difference function is tapered, 00089 the selection of the period is simplified. 00090 00091 Paul Brossier, [Automatic annotation of musical audio for interactive 00092 systems](http://aubio.org/phd/), Chapter 3, Pitch Analysis, PhD thesis, 00093 Centre for Digital music, Queen Mary University of London, London, UK, 2006. 00094 00095 \example pitch/test-pitch.c 00096 \example examples/aubiopitch.c 00097 00098 */ 00099 00100 /** pitch detection object */ 00101 typedef struct _aubio_pitch_t aubio_pitch_t; 00102 00103 /** execute pitch detection on an input signal frame 00104 00105 \param o pitch detection object as returned by new_aubio_pitch() 00106 \param in input signal of size [hop_size] 00107 \param out output pitch candidates of size [1] 00108 00109 */ 00110 void aubio_pitch_do (aubio_pitch_t * o, const fvec_t * in, fvec_t * out); 00111 00112 /** change yin or yinfft tolerance threshold 00113 00114 \param o pitch detection object as returned by new_aubio_pitch() 00115 \param tol tolerance default is 0.15 for yin and 0.85 for yinfft 00116 00117 */ 00118 uint_t aubio_pitch_set_tolerance (aubio_pitch_t * o, smpl_t tol); 00119 00120 /** get yin or yinfft tolerance threshold 00121 00122 \param o pitch detection object as returned by new_aubio_pitch() 00123 \return tolerance (default is 0.15 for yin and 0.85 for yinfft) 00124 00125 */ 00126 smpl_t aubio_pitch_get_tolerance (aubio_pitch_t * o); 00127 00128 /** deletion of the pitch detection object 00129 00130 \param o pitch detection object as returned by new_aubio_pitch() 00131 00132 */ 00133 void del_aubio_pitch (aubio_pitch_t * o); 00134 00135 /** creation of the pitch detection object 00136 00137 \param method set pitch detection algorithm 00138 \param buf_size size of the input buffer to analyse 00139 \param hop_size step size between two consecutive analysis instant 00140 \param samplerate sampling rate of the signal 00141 00142 \return newly created ::aubio_pitch_t 00143 00144 */ 00145 aubio_pitch_t *new_aubio_pitch (const char_t * method, 00146 uint_t buf_size, uint_t hop_size, uint_t samplerate); 00147 00148 /** set the output unit of the pitch detection object 00149 00150 \param o pitch detection object as returned by new_aubio_pitch() 00151 \param mode set pitch units for output 00152 00153 mode can be one of "Hz", "midi", "cent", or "bin". Defaults to "Hz". 00154 00155 \return 0 if successfull, non-zero otherwise 00156 00157 */ 00158 uint_t aubio_pitch_set_unit (aubio_pitch_t * o, const char_t * mode); 00159 00160 /** set the silence threshold of the pitch detection object 00161 00162 \param o pitch detection object as returned by new_aubio_pitch() 00163 \param silence level threshold under which pitch should be ignored, in dB 00164 00165 \return 0 if successfull, non-zero otherwise 00166 00167 */ 00168 uint_t aubio_pitch_set_silence (aubio_pitch_t * o, smpl_t silence); 00169 00170 /** set the silence threshold of the pitch detection object 00171 00172 \param o pitch detection object as returned by ::new_aubio_pitch() 00173 00174 \return level threshold under which pitch should be ignored, in dB 00175 00176 */ 00177 smpl_t aubio_pitch_get_silence (aubio_pitch_t * o); 00178 00179 /** get the current confidence 00180 00181 \param o pitch detection object as returned by new_aubio_pitch() 00182 00183 \return the current confidence of the pitch algorithm 00184 00185 */ 00186 smpl_t aubio_pitch_get_confidence (aubio_pitch_t * o); 00187 00188 #ifdef __cplusplus 00189 } 00190 #endif 00191 00192 #endif /* AUBIO_PITCH_H */
1.5.6