Changeset 155cc10 for src/tempo/tempo.c
- Timestamp:
- Mar 10, 2017, 2:26:32 PM (8 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tempo/tempo.c
r00d0275 r155cc10 28 28 #include "mathutils.h" 29 29 #include "tempo/tempo.h" 30 31 // TODO implement get/set_delay32 33 /** set current delay34 35 \param o beat tracking object36 37 \return current delay, in samples38 39 */40 uint_t aubio_tempo_get_delay(aubio_tempo_t * o);41 42 /** set current delay43 44 \param o beat tracking object45 \param delay delay to set tempo to, in samples46 47 \return `0` if successful, non-zero otherwise48 49 */50 uint_t aubio_tempo_set_delay(aubio_tempo_t * o, uint_t delay);51 30 52 31 /* structure to store object state */ … … 70 49 uint_t total_frames; /** total frames since beginning */ 71 50 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 */ 73 52 uint_t last_tatum; /** time of latest detected tatum, in samples */ 74 53 uint_t tatum_signature; /** number of tatum between each beats */ … … 76 55 77 56 /* execute tempo detection function on iput buffer */ 78 void aubio_tempo_do(aubio_tempo_t *o, fvec_t * input, fvec_t * tempo)57 void aubio_tempo_do(aubio_tempo_t *o, const fvec_t * input, fvec_t * tempo) 79 58 { 80 59 uint_t i; … … 101 80 o->blockpos++; 102 81 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]; 104 84 thresholded = aubio_peakpicker_get_thresholded_input(o->pp); 105 85 o->dfframe->data[winlen - step + o->blockpos] = thresholded->data[0]; … … 125 105 uint_t aubio_tempo_get_last (aubio_tempo_t *o) 126 106 { 127 return o->last_beat -o->delay;107 return o->last_beat + o->delay; 128 108 } 129 109 … … 138 118 } 139 119 140 uint_t aubio_tempo_set_delay(aubio_tempo_t * o, uint_t delay) {120 uint_t aubio_tempo_set_delay(aubio_tempo_t * o, sint_t delay) { 141 121 o->delay = delay; 122 return AUBIO_OK; 123 } 124 125 uint_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 130 uint_t aubio_tempo_set_delay_ms(aubio_tempo_t * o, smpl_t delay) { 131 o->delay = 1000. * delay * o->samplerate; 142 132 return AUBIO_OK; 143 133 } … … 145 135 uint_t aubio_tempo_get_delay(aubio_tempo_t * o) { 146 136 return o->delay; 137 } 138 139 smpl_t aubio_tempo_get_delay_s(aubio_tempo_t * o) { 140 return o->delay / (smpl_t)(o->samplerate); 141 } 142 143 smpl_t aubio_tempo_get_delay_ms(aubio_tempo_t * o) { 144 return o->delay / (smpl_t)(o->samplerate) / 1000.; 147 145 } 148 146 … … 167 165 168 166 /* Allocate memory for an tempo detection */ 169 aubio_tempo_t * new_aubio_tempo (c har_t * tempo_mode,167 aubio_tempo_t * new_aubio_tempo (const char_t * tempo_mode, 170 168 uint_t buf_size, uint_t hop_size, uint_t samplerate) 171 169 { … … 177 175 AUBIO_ERR("tempo: got hop size %d, but can not be < 1\n", hop_size); 178 176 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); 181 179 goto beach; 182 180 } else if (buf_size < hop_size) {
Note: See TracChangeset
for help on using the changeset viewer.