Changeset 7e80dc9 for src/tempo/tempo.c


Ignore:
Timestamp:
Feb 8, 2016, 6:06:52 PM (8 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

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.