2 Copyright (C) 2006-2013 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/>.
23 Tempo detection object
25 This object stores all the memory required for tempo detection algorithm
26 and returns the estimated beat locations.
28 \example tempo/test-tempo.c
29 \example examples/aubiotrack.c
40 /** tempo detection structure */
41 typedef struct _aubio_tempo_t aubio_tempo_t;
43 /** create tempo detection object
45 \param method beat tracking method, unused for now (use "default")
46 \param buf_size length of FFT
47 \param hop_size number of frames between two consecutive runs
48 \param samplerate sampling rate of the signal to analyze
50 \return newly created ::aubio_tempo_t if successful, `NULL` otherwise
53 aubio_tempo_t * new_aubio_tempo (const char_t * method,
54 uint_t buf_size, uint_t hop_size, uint_t samplerate);
56 /** execute tempo detection
58 \param o beat tracking object
59 \param input new samples
60 \param tempo output beats
63 void aubio_tempo_do (aubio_tempo_t *o, const fvec_t * input, fvec_t * tempo);
65 /** get the time of the latest beat detected, in samples
67 \param o tempo detection object as returned by ::new_aubio_tempo
70 uint_t aubio_tempo_get_last (aubio_tempo_t *o);
72 /** get the time of the latest beat detected, in seconds
74 \param o tempo detection object as returned by ::new_aubio_tempo
77 smpl_t aubio_tempo_get_last_s (aubio_tempo_t *o);
79 /** get the time of the latest beat detected, in milliseconds
81 \param o tempo detection object as returned by ::new_aubio_tempo
84 smpl_t aubio_tempo_get_last_ms (aubio_tempo_t *o);
86 /** set tempo detection silence threshold
88 \param o beat tracking object
89 \param silence new silence threshold, in dB
91 \return `0` if successful, non-zero otherwise
94 uint_t aubio_tempo_set_silence(aubio_tempo_t * o, smpl_t silence);
96 /** get tempo detection silence threshold
98 \param o tempo detection object as returned by new_aubio_tempo()
100 \return current silence threshold
103 smpl_t aubio_tempo_get_silence(aubio_tempo_t * o);
105 /** set tempo detection peak picking threshold
107 \param o beat tracking object
108 \param threshold new threshold
110 \return `0` if successful, non-zero otherwise
113 uint_t aubio_tempo_set_threshold(aubio_tempo_t * o, smpl_t threshold);
115 /** get tempo peak picking threshold
117 \param o tempo detection object as returned by new_aubio_tempo()
119 \return current tempo detection threshold
122 smpl_t aubio_tempo_get_threshold(aubio_tempo_t * o);
124 /** get current beat period in samples
126 \param bt beat tracking object
128 Returns the currently observed period, in samples, or 0 if no consistent
132 smpl_t aubio_tempo_get_period (aubio_tempo_t * bt);
134 /** get current beat period in seconds
136 \param bt beat tracking object
138 Returns the currently observed period, in seconds, or 0 if no consistent
142 smpl_t aubio_tempo_get_period_s (aubio_tempo_t * bt);
144 /** get current tempo
146 \param o beat tracking object
148 \return the currently observed tempo, or `0` if no consistent value is found
151 smpl_t aubio_tempo_get_bpm(aubio_tempo_t * o);
153 /** get current tempo confidence
155 \param o beat tracking object
157 \return confidence with which the tempo has been observed, the higher the
158 more confidence, `0` if no consistent value is found.
161 smpl_t aubio_tempo_get_confidence(aubio_tempo_t * o);
163 /** set number of tatum per beat
165 \param o beat tracking object
166 \param signature number of tatum per beat (between 1 and 64)
169 uint_t aubio_tempo_set_tatum_signature(aubio_tempo_t *o, uint_t signature);
171 /** check whether a tatum was detected in the current frame
173 \param o beat tracking object
175 \return 2 if a beat was detected, 1 if a tatum was detected, 0 otherwise
178 uint_t aubio_tempo_was_tatum(aubio_tempo_t *o);
180 /** get position of last_tatum, in samples
182 \param o beat tracking object
185 smpl_t aubio_tempo_get_last_tatum(aubio_tempo_t *o);
187 /** get current delay
189 \param o beat tracking object
191 \return current delay, in samples
194 uint_t aubio_tempo_get_delay(aubio_tempo_t * o);
196 /** get current delay in seconds
198 \param o beat tracking object
200 \return current delay, in seconds
203 smpl_t aubio_tempo_get_delay_s(aubio_tempo_t * o);
205 /** get current delay in ms
207 \param o beat tracking object
209 \return current delay, in milliseconds
212 smpl_t aubio_tempo_get_delay_ms(aubio_tempo_t * o);
214 /** set current delay
216 \param o beat tracking object
217 \param delay delay to set tempo to, in samples
219 \return `0` if successful, non-zero otherwise
222 uint_t aubio_tempo_set_delay(aubio_tempo_t * o, sint_t delay);
224 /** set current delay in seconds
226 \param o beat tracking object
227 \param delay delay to set tempo to, in seconds
229 \return `0` if successful, non-zero otherwise
232 uint_t aubio_tempo_set_delay_s(aubio_tempo_t * o, smpl_t delay);
234 /** set current delay
236 \param o beat tracking object
237 \param delay delay to set tempo to, in samples
239 \return `0` if successful, non-zero otherwise
242 uint_t aubio_tempo_set_delay_ms(aubio_tempo_t * o, smpl_t delay);
244 /** delete tempo detection object
246 \param o beat tracking object
249 void del_aubio_tempo(aubio_tempo_t * o);
255 #endif /* AUBIO_TEMPO_H */