Changeset 155cc10 for src/onset/onset.c
- Timestamp:
- Mar 10, 2017, 2:26:32 PM (7 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, 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/onset/onset.c
r00d0275 r155cc10 52 52 53 53 /* execute onset detection function on iput buffer */ 54 void aubio_onset_do (aubio_onset_t *o, fvec_t * input, fvec_t * onset)54 void aubio_onset_do (aubio_onset_t *o, const fvec_t * input, fvec_t * onset) 55 55 { 56 56 smpl_t isonset = 0; … … 100 100 } 101 101 102 uint_t aubio_onset_get_last ( aubio_onset_t *o)102 uint_t aubio_onset_get_last (const aubio_onset_t *o) 103 103 { 104 104 return o->last_onset - o->delay; 105 105 } 106 106 107 smpl_t aubio_onset_get_last_s ( aubio_onset_t *o)107 smpl_t aubio_onset_get_last_s (const aubio_onset_t *o) 108 108 { 109 109 return aubio_onset_get_last (o) / (smpl_t) (o->samplerate); 110 110 } 111 111 112 smpl_t aubio_onset_get_last_ms ( aubio_onset_t *o)112 smpl_t aubio_onset_get_last_ms (const aubio_onset_t *o) 113 113 { 114 114 return aubio_onset_get_last_s (o) * 1000.; … … 131 131 } 132 132 133 smpl_t aubio_onset_get_silence( aubio_onset_t * o) {133 smpl_t aubio_onset_get_silence(const aubio_onset_t * o) { 134 134 return o->silence; 135 135 } … … 140 140 } 141 141 142 smpl_t aubio_onset_get_threshold( aubio_onset_t * o) {142 smpl_t aubio_onset_get_threshold(const aubio_onset_t * o) { 143 143 return aubio_peakpicker_get_threshold(o->pp); 144 144 } … … 149 149 } 150 150 151 uint_t aubio_onset_get_minioi( aubio_onset_t * o) {151 uint_t aubio_onset_get_minioi(const aubio_onset_t * o) { 152 152 return o->minioi; 153 153 } 154 154 155 155 uint_t aubio_onset_set_minioi_s(aubio_onset_t * o, smpl_t minioi) { 156 return aubio_onset_set_minioi (o, minioi * o->samplerate);157 } 158 159 smpl_t aubio_onset_get_minioi_s( aubio_onset_t * o) {156 return aubio_onset_set_minioi (o, (uint_t)ROUND(minioi * o->samplerate)); 157 } 158 159 smpl_t aubio_onset_get_minioi_s(const aubio_onset_t * o) { 160 160 return aubio_onset_get_minioi (o) / (smpl_t) o->samplerate; 161 161 } … … 165 165 } 166 166 167 smpl_t aubio_onset_get_minioi_ms( aubio_onset_t * o) {167 smpl_t aubio_onset_get_minioi_ms(const aubio_onset_t * o) { 168 168 return aubio_onset_get_minioi_s (o) * 1000.; 169 169 } … … 174 174 } 175 175 176 uint_t aubio_onset_get_delay( aubio_onset_t * o) {176 uint_t aubio_onset_get_delay(const aubio_onset_t * o) { 177 177 return o->delay; 178 178 } … … 182 182 } 183 183 184 smpl_t aubio_onset_get_delay_s( aubio_onset_t * o) {184 smpl_t aubio_onset_get_delay_s(const aubio_onset_t * o) { 185 185 return aubio_onset_get_delay (o) / (smpl_t) o->samplerate; 186 186 } … … 190 190 } 191 191 192 smpl_t aubio_onset_get_delay_ms( aubio_onset_t * o) {192 smpl_t aubio_onset_get_delay_ms(const aubio_onset_t * o) { 193 193 return aubio_onset_get_delay_s (o) * 1000.; 194 194 } 195 195 196 smpl_t aubio_onset_get_descriptor( aubio_onset_t * o) {196 smpl_t aubio_onset_get_descriptor(const aubio_onset_t * o) { 197 197 return o->desc->data[0]; 198 198 } 199 199 200 smpl_t aubio_onset_get_thresholded_descriptor( aubio_onset_t * o) {200 smpl_t aubio_onset_get_thresholded_descriptor(const aubio_onset_t * o) { 201 201 fvec_t * thresholded = aubio_peakpicker_get_thresholded_input(o->pp); 202 202 return thresholded->data[0]; … … 204 204 205 205 /* Allocate memory for an onset detection */ 206 aubio_onset_t * new_aubio_onset (c har_t * onset_mode,206 aubio_onset_t * new_aubio_onset (const char_t * onset_mode, 207 207 uint_t buf_size, uint_t hop_size, uint_t samplerate) 208 208 { … … 213 213 AUBIO_ERR("onset: got hop_size %d, but can not be < 1\n", hop_size); 214 214 goto beach; 215 } else if ((sint_t)buf_size < 1) {216 AUBIO_ERR("onset: got buffer_size %d, but can not be < 1\n", buf_size);215 } else if ((sint_t)buf_size < 2) { 216 AUBIO_ERR("onset: got buffer_size %d, but can not be < 2\n", buf_size); 217 217 goto beach; 218 218 } else if (buf_size < hop_size) { 219 AUBIO_ERR("onset: hop size (%d) is larger than win size (%d)\n", buf_size, hop_size);219 AUBIO_ERR("onset: hop size (%d) is larger than win size (%d)\n", hop_size, buf_size); 220 220 goto beach; 221 221 } else if ((sint_t)samplerate < 1) { … … 232 232 o->pp = new_aubio_peakpicker(); 233 233 o->od = new_aubio_specdesc(onset_mode,buf_size); 234 if (o->od == NULL) goto beach_specdesc; 234 235 o->fftgrain = new_cvec(buf_size); 235 236 o->desc = new_fvec(1); … … 244 245 return o; 245 246 247 beach_specdesc: 248 del_aubio_peakpicker(o->pp); 249 del_aubio_pvoc(o->pv); 246 250 beach: 247 251 AUBIO_FREE(o);
Note: See TracChangeset
for help on using the changeset viewer.