Changeset 7e80dc9 for src/tempo


Ignore:
Timestamp:
Feb 8, 2016, 6:06:52 PM (9 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
a33d406
Parents:
fa74361
Message:

src/tempo/tempo.h: implement get/set_delay

Location:
src/tempo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/tempo/tempo.c

    rfa74361 r7e80dc9  
    2828#include "mathutils.h"
    2929#include "tempo/tempo.h"
    30 
    31 // TODO implement get/set_delay
    32 
    33 /** set current delay
    34 
    35   \param o beat tracking object
    36 
    37   \return current delay, in samples
    38 
    39  */
    40 uint_t aubio_tempo_get_delay(aubio_tempo_t * o);
    41 
    42 /** set current delay
    43 
    44   \param o beat tracking object
    45   \param delay delay to set tempo to, in samples
    46 
    47   \return `0` if successful, non-zero otherwise
    48 
    49  */
    50 uint_t aubio_tempo_set_delay(aubio_tempo_t * o, uint_t delay);
    5130
    5231/* structure to store object state */
     
    7049  uint_t total_frames;           /** total frames since beginning */
    7150  uint_t last_beat;              /** time of latest detected beat, in samples */
    72   uint_t delay;                  /** delay to remove to last beat, in samples */
     51  sint_t delay;                  /** delay to remove to last beat, in samples */
    7352  uint_t last_tatum;             /** time of latest detected tatum, in samples */
    7453  uint_t tatum_signature;        /** number of tatum between each beats */
     
    125104uint_t aubio_tempo_get_last (aubio_tempo_t *o)
    126105{
    127   return o->last_beat - o->delay;
     106  return o->last_beat + o->delay;
    128107}
    129108
     
    138117}
    139118
    140 uint_t aubio_tempo_set_delay(aubio_tempo_t * o, uint_t delay) {
     119uint_t aubio_tempo_set_delay(aubio_tempo_t * o, sint_t delay) {
    141120  o->delay = delay;
     121  return AUBIO_OK;
     122}
     123
     124uint_t aubio_tempo_set_delay_s(aubio_tempo_t * o, smpl_t delay) {
     125  o->delay = delay * o->samplerate;
     126  return AUBIO_OK;
     127}
     128
     129uint_t aubio_tempo_set_delay_ms(aubio_tempo_t * o, smpl_t delay) {
     130  o->delay = 1000. * delay * o->samplerate;
    142131  return AUBIO_OK;
    143132}
     
    145134uint_t aubio_tempo_get_delay(aubio_tempo_t * o) {
    146135  return o->delay;
     136}
     137
     138smpl_t aubio_tempo_get_delay_s(aubio_tempo_t * o) {
     139  return o->delay / (smpl_t)(o->samplerate);
     140}
     141
     142smpl_t aubio_tempo_get_delay_ms(aubio_tempo_t * o) {
     143  return o->delay / (smpl_t)(o->samplerate) / 1000.;
    147144}
    148145
  • src/tempo/tempo.h

    rfa74361 r7e80dc9  
    185185smpl_t aubio_tempo_get_last_tatum(aubio_tempo_t *o);
    186186
     187/** get current delay
     188
     189  \param o beat tracking object
     190
     191  \return current delay, in samples
     192
     193 */
     194uint_t aubio_tempo_get_delay(aubio_tempo_t * o);
     195
     196/** get current delay in seconds
     197
     198  \param o beat tracking object
     199
     200  \return current delay, in seconds
     201
     202 */
     203smpl_t aubio_tempo_get_delay_s(aubio_tempo_t * o);
     204
     205/** get current delay in ms
     206
     207  \param o beat tracking object
     208
     209  \return current delay, in milliseconds
     210
     211 */
     212smpl_t aubio_tempo_get_delay_ms(aubio_tempo_t * o);
     213
     214/** set current delay
     215
     216  \param o beat tracking object
     217  \param delay delay to set tempo to, in samples
     218
     219  \return `0` if successful, non-zero otherwise
     220
     221 */
     222uint_t aubio_tempo_set_delay(aubio_tempo_t * o, sint_t delay);
     223
     224/** set current delay in seconds
     225
     226  \param o beat tracking object
     227  \param delay delay to set tempo to, in seconds
     228
     229  \return `0` if successful, non-zero otherwise
     230
     231 */
     232uint_t aubio_tempo_set_delay_s(aubio_tempo_t * o, smpl_t delay);
     233
     234/** set current delay
     235
     236  \param o beat tracking object
     237  \param delay delay to set tempo to, in samples
     238
     239  \return `0` if successful, non-zero otherwise
     240
     241 */
     242uint_t aubio_tempo_set_delay_ms(aubio_tempo_t * o, smpl_t delay);
     243
    187244/** delete tempo detection object
    188245
Note: See TracChangeset for help on using the changeset viewer.