Changeset 155cc10 for src/tempo/tempo.c


Ignore:
Timestamp:
Mar 10, 2017, 2:26:32 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/applefworks, fix/ffmpeg5, master, sampler
Children:
ee8a57c
Parents:
00d0275 (diff), 67b6618 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into awhitening

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tempo/tempo.c

    r00d0275 r155cc10  
    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 */
     
    7655
    7756/* execute tempo detection function on iput buffer */
    78 void aubio_tempo_do(aubio_tempo_t *o, fvec_t * input, fvec_t * tempo)
     57void aubio_tempo_do(aubio_tempo_t *o, const fvec_t * input, fvec_t * tempo)
    7958{
    8059  uint_t i;
     
    10180  o->blockpos++;
    10281  aubio_peakpicker_do (o->pp, o->of, o->onset);
    103   tempo->data[1] = o->onset->data[0];
     82  // store onset detection function in second sample of vector
     83  //tempo->data[1] = o->onset->data[0];
    10484  thresholded = aubio_peakpicker_get_thresholded_input(o->pp);
    10585  o->dfframe->data[winlen - step + o->blockpos] = thresholded->data[0];
     
    125105uint_t aubio_tempo_get_last (aubio_tempo_t *o)
    126106{
    127   return o->last_beat - o->delay;
     107  return o->last_beat + o->delay;
    128108}
    129109
     
    138118}
    139119
    140 uint_t aubio_tempo_set_delay(aubio_tempo_t * o, uint_t delay) {
     120uint_t aubio_tempo_set_delay(aubio_tempo_t * o, sint_t delay) {
    141121  o->delay = delay;
     122  return AUBIO_OK;
     123}
     124
     125uint_t aubio_tempo_set_delay_s(aubio_tempo_t * o, smpl_t delay) {
     126  o->delay = delay * o->samplerate;
     127  return AUBIO_OK;
     128}
     129
     130uint_t aubio_tempo_set_delay_ms(aubio_tempo_t * o, smpl_t delay) {
     131  o->delay = 1000. * delay * o->samplerate;
    142132  return AUBIO_OK;
    143133}
     
    145135uint_t aubio_tempo_get_delay(aubio_tempo_t * o) {
    146136  return o->delay;
     137}
     138
     139smpl_t aubio_tempo_get_delay_s(aubio_tempo_t * o) {
     140  return o->delay / (smpl_t)(o->samplerate);
     141}
     142
     143smpl_t aubio_tempo_get_delay_ms(aubio_tempo_t * o) {
     144  return o->delay / (smpl_t)(o->samplerate) / 1000.;
    147145}
    148146
     
    167165
    168166/* Allocate memory for an tempo detection */
    169 aubio_tempo_t * new_aubio_tempo (char_t * tempo_mode,
     167aubio_tempo_t * new_aubio_tempo (const char_t * tempo_mode,
    170168    uint_t buf_size, uint_t hop_size, uint_t samplerate)
    171169{
     
    177175    AUBIO_ERR("tempo: got hop size %d, but can not be < 1\n", hop_size);
    178176    goto beach;
    179   } else if ((sint_t)buf_size < 1) {
    180     AUBIO_ERR("tempo: got window size %d, but can not be < 1\n", buf_size);
     177  } else if ((sint_t)buf_size < 2) {
     178    AUBIO_ERR("tempo: got window size %d, but can not be < 2\n", buf_size);
    181179    goto beach;
    182180  } else if (buf_size < hop_size) {
Note: See TracChangeset for help on using the changeset viewer.