- Timestamp:
- Oct 27, 2013, 12:44:29 PM (10 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, pitchshift, sampler, timestretch, yinfft+
- Children:
- 8247249
- Parents:
- dd15573 (diff), 7fc5ba2 (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. - Location:
- src
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
src/aubio.h
rdd15573 rdc467b5d 110 110 111 111 Several examples of C programs are available in the \p examples/ and \p tests/src 112 director yof the source tree.112 directories of the source tree. 113 113 114 114 \subsection unstable_api Unstable API … … 185 185 #include "io/source.h" 186 186 #include "io/sink.h" 187 #include "io/audio_unit.h" 187 188 #include "synth/sampler.h" 188 189 #include "synth/wavetable.h" -
src/fmat.c
rdd15573 rdc467b5d 55 55 s->data[channel] = data; 56 56 } 57 smpl_t * fmat_get_channel(fmat_t *s, uint_t channel) { 58 return s->data[channel]; 57 void fmat_get_channel(fmat_t *s, uint_t channel, fvec_t *output) { 58 output->data = s->data[channel]; 59 output->length = s->length; 60 return; 59 61 } 60 62 -
src/fmat.h
rdd15573 rdc467b5d 92 92 93 93 */ 94 smpl_t * fmat_get_channel(fmat_t *s, uint_t channel);94 void fmat_get_channel (fmat_t *s, uint_t channel, fvec_t *output); 95 95 /** write channel vector into a buffer 96 96 -
src/io/source_sndfile.c
rdd15573 rdc467b5d 59 59 // some temporary memory for sndfile to write at 60 60 uint_t scratch_size; 61 smpl_t *scratch_data;61 float *scratch_data; 62 62 }; 63 63 … … 199 199 } 200 200 201 /* de-interleaving data */ 202 for (j = 0; j < read_samples / input_channels; j++) { 203 for (i = 0; i < input_channels; i++) { 204 data[i][j] = (smpl_t)s->scratch_data[input_channels*j+i]; 205 } 206 } 207 // if read_data has more channels than the file 201 if (read_data->height < input_channels) { 202 // destination matrix has less channels than the file; copy only first 203 // channels of the file, de-interleaving data 204 for (j = 0; j < read_samples / input_channels; j++) { 205 for (i = 0; i < read_data->height; i++) { 206 data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i]; 207 } 208 } 209 } else { 210 // destination matrix has as many or more channels than the file; copy each 211 // channel from the file to the destination matrix, de-interleaving data 212 for (j = 0; j < read_samples / input_channels; j++) { 213 for (i = 0; i < input_channels; i++) { 214 data[i][j] = (smpl_t)s->scratch_data[j * input_channels + i]; 215 } 216 } 217 } 218 208 219 if (read_data->height > input_channels) { 209 // copy last channel to all additional channels 220 // destination matrix has more channels than the file; copy last channel 221 // of the file to each additional channels, de-interleaving data 210 222 for (j = 0; j < read_samples / input_channels; j++) { 211 223 for (i = input_channels; i < read_data->height; i++) { 212 data[i][j] = s->scratch_data[j * input_channels + (input_channels - 1)];224 data[i][j] = (smpl_t)s->scratch_data[j * input_channels + (input_channels - 1)]; 213 225 } 214 226 } -
src/mathutils.c
rdd15573 rdc467b5d 27 27 #include "config.h" 28 28 29 #ifdef HAVE_ACCELERATE 30 #include <Accelerate/Accelerate.h> 31 #endif 29 32 30 33 /** Window types */ … … 170 173 fvec_max (fvec_t * s) 171 174 { 175 #ifndef HAVE_ACCELERATE 172 176 uint_t j; 173 177 smpl_t tmp = 0.0; … … 175 179 tmp = (tmp > s->data[j]) ? tmp : s->data[j]; 176 180 } 181 #else 182 smpl_t tmp = 0.; 183 #if !HAVE_AUBIO_DOUBLE 184 vDSP_maxv(s->data, 1, &tmp, s->length); 185 #else 186 vDSP_maxvD(s->data, 1, &tmp, s->length); 187 #endif 188 #endif 177 189 return tmp; 178 190 } … … 181 193 fvec_min (fvec_t * s) 182 194 { 195 #ifndef HAVE_ACCELERATE 183 196 uint_t j; 184 197 smpl_t tmp = s->data[0]; … … 186 199 tmp = (tmp < s->data[j]) ? tmp : s->data[j]; 187 200 } 201 #else 202 smpl_t tmp = 0.; 203 #if !HAVE_AUBIO_DOUBLE 204 vDSP_minv(s->data, 1, &tmp, s->length); 205 #else 206 vDSP_minvD(s->data, 1, &tmp, s->length); 207 #endif 208 #endif 188 209 return tmp; 189 210 } … … 192 213 fvec_min_elem (fvec_t * s) 193 214 { 215 #ifndef HAVE_ACCELERATE 194 216 uint_t j, pos = 0.; 195 217 smpl_t tmp = s->data[0]; … … 198 220 tmp = (tmp < s->data[j]) ? tmp : s->data[j]; 199 221 } 222 #else 223 smpl_t tmp = 0.; 224 uint_t pos = 0.; 225 #if !HAVE_AUBIO_DOUBLE 226 vDSP_minvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length); 227 #else 228 vDSP_minviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length); 229 #endif 230 #endif 200 231 return pos; 201 232 } … … 204 235 fvec_max_elem (fvec_t * s) 205 236 { 237 #ifndef HAVE_ACCELERATE 206 238 uint_t j, pos = 0; 207 239 smpl_t tmp = 0.0; … … 210 242 tmp = (tmp > s->data[j]) ? tmp : s->data[j]; 211 243 } 244 #else 245 smpl_t tmp = 0.; 246 uint_t pos = 0.; 247 #if !HAVE_AUBIO_DOUBLE 248 vDSP_maxvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length); 249 #else 250 vDSP_maxviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length); 251 #endif 252 #endif 212 253 return pos; 213 254 } … … 368 409 } 369 410 370 smpl_t fvec_quadint (fvec_t * x, uint_t pos) {371 smpl_t s0, s1, s2;372 uint_t x0 = (pos < 1) ? pos : pos - 1;373 uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos;374 if (x0 == pos) return (x->data[pos] <= x->data[x2]) ? pos : x2;375 if (x2 == pos) return (x->data[pos] <= x->data[x0]) ? pos : x0;376 s0 = x->data[x0];377 s1 = x->data[pos];378 s2 = x->data[x2];379 return pos + 0.5 * (s2 - s0 ) / (s2 - 2.* s1 + s0);380 }381 382 411 smpl_t fvec_quadratic_peak_pos (fvec_t * x, uint_t pos) { 383 412 smpl_t s0, s1, s2; 413 if (pos == 0 || pos == x->length - 1) return pos; 384 414 uint_t x0 = (pos < 1) ? pos : pos - 1; 385 415 uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos; -
src/mathutils.h
rdd15573 rdc467b5d 232 232 smpl_t fvec_median (fvec_t * v); 233 233 234 /** finds exact peak index by quadratic interpolation*/235 smpl_t fvec_quadint (fvec_t * x, uint_t pos);236 237 234 /** finds exact peak index by quadratic interpolation 238 235 -
src/onset/onset.c
rdd15573 rdc467b5d 93 93 smpl_t aubio_onset_get_last_ms (aubio_onset_t *o) 94 94 { 95 return aubio_onset_get_last_s (o) /1000.;95 return aubio_onset_get_last_s (o) * 1000.; 96 96 } 97 97 -
src/onset/peakpicker.c
rdd15573 rdc467b5d 125 125 out->data[0] = (p->pickerfn) (onset_peek, 1); 126 126 if (out->data[0]) { 127 out->data[0] = fvec_quad int(onset_peek, 1);127 out->data[0] = fvec_quadratic_peak_pos (onset_peek, 1); 128 128 } 129 129 } -
src/pitch/pitchspecacf.c
rdd15573 rdc467b5d 50 50 p->acf = new_fvec (bufsize / 2 + 1); 51 51 p->tol = 1.; 52 p->confidence = 0.; 52 53 return p; 53 54 } … … 92 93 smpl_t 93 94 aubio_pitchspecacf_get_confidence (aubio_pitchspecacf_t * o) { 94 return 0; 95 // no confidence for now 96 return o->confidence; 95 97 } 96 98 -
src/spectral/fft.c
rdd15573 rdc467b5d 100 100 #ifdef HAVE_ACCELERATE // using ACCELERATE 101 101 int log2fftsize; 102 #if !HAVE_AUBIO_DOUBLE 102 103 FFTSetup fftSetup; 103 104 DSPSplitComplex spec; 104 105 float *in, *out; 106 #else 107 FFTSetupD fftSetup; 108 DSPDoubleSplitComplex spec; 109 double *in, *out; 110 #endif 105 111 #else // using OOURA 106 112 double *in, *out; … … 148 154 s->compspec = new_fvec(winsize); 149 155 s->log2fftsize = (uint_t)log2f(s->fft_size); 156 #if !HAVE_AUBIO_DOUBLE 150 157 s->in = AUBIO_ARRAY(float, s->fft_size); 151 158 s->out = AUBIO_ARRAY(float, s->fft_size); … … 153 160 s->spec.imagp = AUBIO_ARRAY(float, s->fft_size/2); 154 161 s->fftSetup = vDSP_create_fftsetup(s->log2fftsize, FFT_RADIX2); 162 #else 163 s->in = AUBIO_ARRAY(double, s->fft_size); 164 s->out = AUBIO_ARRAY(double, s->fft_size); 165 s->spec.realp = AUBIO_ARRAY(double, s->fft_size/2); 166 s->spec.imagp = AUBIO_ARRAY(double, s->fft_size/2); 167 s->fftSetup = vDSP_create_fftsetupD(s->log2fftsize, FFT_RADIX2); 168 #endif 155 169 #else // using OOURA 156 170 s->winsize = winsize; … … 219 233 #else /* HAVE_FFTW3 */ 220 234 #ifdef HAVE_ACCELERATE // using ACCELERATE 235 #if !HAVE_AUBIO_DOUBLE 221 236 // convert real data to even/odd format used in vDSP 222 vDSP_ctoz(( COMPLEX*)s->in, 2, &s->spec, 1, s->fft_size/2);237 vDSP_ctoz((DSPComplex*)s->in, 2, &s->spec, 1, s->fft_size/2); 223 238 // compute the FFT 224 239 vDSP_fft_zrip(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_FORWARD); 240 #else 241 // convert real data to even/odd format used in vDSP 242 vDSP_ctozD((DSPDoubleComplex*)s->in, 2, &s->spec, 1, s->fft_size/2); 243 // compute the FFT 244 vDSP_fft_zripD(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_FORWARD); 245 #endif 225 246 // convert from vDSP complex split to [ r0, r1, ..., rN, iN-1, .., i2, i1] 226 247 compspec->data[0] = s->spec.realp[0]; … … 232 253 // apply scaling 233 254 smpl_t scale = 1./2.; 255 #if !HAVE_AUBIO_DOUBLE 234 256 vDSP_vsmul(compspec->data, 1, &scale, compspec->data, 1, s->fft_size); 257 #else 258 vDSP_vsmulD(compspec->data, 1, &scale, compspec->data, 1, s->fft_size); 259 #endif 235 260 #else // using OOURA 236 261 rdft(s->winsize, 1, s->in, s->ip, s->w); … … 275 300 s->out[2 * i + 1] = compspec->data[s->winsize - i]; 276 301 } 302 #if !HAVE_AUBIO_DOUBLE 277 303 // convert to split complex format used in vDSP 278 vDSP_ctoz(( COMPLEX*)s->out, 2, &s->spec, 1, s->fft_size/2);304 vDSP_ctoz((DSPComplex*)s->out, 2, &s->spec, 1, s->fft_size/2); 279 305 // compute the FFT 280 306 vDSP_fft_zrip(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_INVERSE); 281 307 // convert result to real output 282 vDSP_ztoc(&s->spec, 1, ( COMPLEX*)output->data, 2, s->fft_size/2);308 vDSP_ztoc(&s->spec, 1, (DSPComplex*)output->data, 2, s->fft_size/2); 283 309 // apply scaling 284 310 smpl_t scale = 1.0 / s->winsize; 285 311 vDSP_vsmul(output->data, 1, &scale, output->data, 1, s->fft_size); 312 #else 313 // convert to split complex format used in vDSP 314 vDSP_ctozD((DSPDoubleComplex*)s->out, 2, &s->spec, 1, s->fft_size/2); 315 // compute the FFT 316 vDSP_fft_zripD(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_INVERSE); 317 // convert result to real output 318 vDSP_ztocD(&s->spec, 1, (DSPDoubleComplex*)output->data, 2, s->fft_size/2); 319 // apply scaling 320 smpl_t scale = 1.0 / s->winsize; 321 vDSP_vsmulD(output->data, 1, &scale, output->data, 1, s->fft_size); 322 #endif 286 323 #else // using OOURA 287 324 smpl_t scale = 2.0 / s->winsize; -
src/spectral/filterbank.h
rdd15573 rdc467b5d 55 55 /** destroy filterbank object 56 56 57 \param f b filterbank, as returned by new_aubio_filterbank() method57 \param f filterbank object, as returned by new_aubio_filterbank() 58 58 59 59 */ 60 void del_aubio_filterbank (aubio_filterbank_t * f b);60 void del_aubio_filterbank (aubio_filterbank_t * f); 61 61 62 62 /** compute filterbank 63 63 64 \param f b filterbank containing nfilt x win_s filter coefficients65 \param in input spectrum containing chans x win_s spectrum66 \param out output vector containing chans x nfiltoutput values64 \param f filterbank object, as returned by new_aubio_filterbank() 65 \param in input spectrum containing an input spectrum of length `win_s` 66 \param out output vector containing the energy found in each band, `nfilt` output values 67 67 68 68 */ 69 void aubio_filterbank_do (aubio_filterbank_t * f b, cvec_t * in, fvec_t * out);69 void aubio_filterbank_do (aubio_filterbank_t * f, cvec_t * in, fvec_t * out); 70 70 71 /** return a pointer to the matrix object containing all filter coefficients 71 /** return a pointer to the matrix object containing all filter coefficients 72 72 73 \param f filterbank object to get coefficients from73 \param f filterbank object, as returned by new_aubio_filterbank() 74 74 75 75 */ … … 78 78 /** copy filter coefficients to the filterbank 79 79 80 \param f filterbank object to set coefficients80 \param f filterbank object, as returned by new_aubio_filterbank() 81 81 \param filters filter bank coefficients to copy from 82 82 -
src/tempo/beattracking.c
rdd15573 rdc467b5d 171 171 /* find non-zero Rayleigh period */ 172 172 maxindex = fvec_max_elem (bt->acfout); 173 bt->rp = maxindex ? fvec_quad int(bt->acfout, maxindex) : 1;173 bt->rp = maxindex ? fvec_quadratic_peak_pos (bt->acfout, maxindex) : 1; 174 174 //rp = (maxindex==127) ? 43 : maxindex; //rayparam 175 175 bt->rp = (maxindex == bt->acfout->length - 1) ? bt->rayparam : maxindex; //rayparam … … 183 183 /* end of biased filterbank */ 184 184 185 if (bp == 0) { 186 output->data[0] = 0; 187 return; 188 } 185 189 186 190 /* deliberate integer operation, could be set to 3 max eventually */ … … 204 208 phase = step - bt->lastbeat; 205 209 } else { 206 phase = fvec_quad int(bt->phout, maxindex);210 phase = fvec_quadratic_peak_pos (bt->phout, maxindex); 207 211 } 208 212 /* take back one frame delay */ … … 306 310 } 307 311 fvec_weight (acfout, bt->gwv); 308 gp = fvec_quad int(acfout, fvec_max_elem (acfout));312 gp = fvec_quadratic_peak_pos (acfout, fvec_max_elem (acfout)); 309 313 /* 310 314 while(gp<32) gp =gp*2; … … 382 386 383 387 /* if tempo is > 206 bpm, half it */ 384 while ( bp < 25) {388 while (0 < bp && bp < 25) { 385 389 #if AUBIO_BEAT_WARNINGS 386 390 AUBIO_WRN ("doubling from %f (%f bpm) to %f (%f bpm)\n", … … 409 413 aubio_beattracking_get_bpm (aubio_beattracking_t * bt) 410 414 { 411 if (bt-> timesig != 0 && bt->counter == 0 && bt->flagstep == 0) {412 return 5168. / fvec_quad int(bt->acfout, bt->bp);415 if (bt->bp != 0 && bt->timesig != 0 && bt->counter == 0 && bt->flagstep == 0) { 416 return 5168. / fvec_quadratic_peak_pos (bt->acfout, bt->bp); 413 417 } else { 414 418 return 0.; -
src/tempo/tempo.c
rdd15573 rdc467b5d 113 113 smpl_t aubio_tempo_get_last_ms (aubio_tempo_t *o) 114 114 { 115 return aubio_tempo_get_last_s (o) /1000.;115 return aubio_tempo_get_last_s (o) * 1000.; 116 116 } 117 117 -
src/wscript_build
rdd15573 rdc467b5d 12 12 # build libaubio 13 13 from waflib import Options 14 if Options.platform == 'ios': build_lib_func = ctx.stlib 15 else: build_lib_func = ctx.shlib 14 if Options.platform in ['ios', 'iosimulator']: 15 build_lib_func = ctx.stlib 16 else: 17 build_lib_func = ctx.shlib 18 16 19 build_lib_func( 17 20 includes = ['.'], … … 20 23 lib = 'm', 21 24 uselib = uselib, 25 install_path = '${PREFIX}/lib', 22 26 vnum = ctx.env['LIB_VERSION']) 23 27 24 28 # install headers, except _priv.h ones 25 29 ctx.install_files('${PREFIX}/include/aubio/', 26 27 30 ctx.path.ant_glob('**/*.h', excl = ['**_priv.h', 'config.h']), 28 31 relative_trick=True)
Note: See TracChangeset
for help on using the changeset viewer.