- Timestamp:
- Jan 3, 2014, 12:47:22 AM (11 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:
- 2e01060
- Parents:
- 89e9e71 (diff), 4fe62ba (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:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
src/aubio_priv.h
r89e9e71 rd4791e5 34 34 */ 35 35 36 #if 1 //HAVE_CONFIG_H37 36 #include "config.h" 38 #endif39 37 40 38 #if HAVE_STDLIB_H … … 47 45 48 46 /* must be included before fftw3.h */ 49 #if HAVE_COMPLEX_H47 #ifdef HAVE_COMPLEX_H 50 48 #include <complex.h> 51 49 #endif 52 50 53 #if HAVE_FFTW3 || HAVE_FFTW3F51 #if defined(HAVE_FFTW3) || defined(HAVE_FFTW3F) 54 52 #include <fftw3.h> 55 53 #endif 56 54 57 #if HAVE_MATH_H55 #ifdef HAVE_MATH_H 58 56 #include <math.h> 59 57 #endif 60 58 61 #if HAVE_STRING_H59 #ifdef HAVE_STRING_H 62 60 #include <string.h> 63 61 #endif 64 62 65 #if HAVE_LIMITS_H63 #ifdef HAVE_LIMITS_H 66 64 #include <limits.h> // for CHAR_BIT, in C99 standard 67 65 #endif -
src/cvec.c
r89e9e71 rd4791e5 23 23 24 24 cvec_t * new_cvec( uint_t length) { 25 cvec_t * s; 25 26 if ((sint_t)length <= 0) { 26 27 return NULL; 27 28 } 28 cvec_t *s = AUBIO_NEW(cvec_t);29 s = AUBIO_NEW(cvec_t); 29 30 s->length = length/2 + 1; 30 31 s->norm = AUBIO_ARRAY(smpl_t,s->length); -
src/fmat.c
r89e9e71 rd4791e5 23 23 24 24 fmat_t * new_fmat (uint_t height, uint_t length) { 25 fmat_t * s; 26 uint_t i,j; 25 27 if ((sint_t)length <= 0 || (sint_t)height <= 0 ) { 26 28 return NULL; 27 29 } 28 fmat_t * s = AUBIO_NEW(fmat_t); 29 uint_t i,j; 30 s = AUBIO_NEW(fmat_t); 30 31 s->height = height; 31 32 s->length = length; … … 127 128 128 129 void fmat_copy(fmat_t *s, fmat_t *t) { 130 uint_t i; 131 #if !HAVE_MEMCPY_HACKS 132 uint_t i,j; 133 #endif 129 134 if (s->height != t->height) { 130 135 AUBIO_ERR("trying to copy %d rows to %d rows \n", … … 138 143 } 139 144 #if HAVE_MEMCPY_HACKS 140 uint_t i;141 145 for (i=0; i< s->height; i++) { 142 146 memcpy(t->data[i], s->data[i], t->length * sizeof(smpl_t)); 143 147 } 144 148 #else 145 uint_t i,j;146 149 for (i=0; i< t->height; i++) { 147 150 for (j=0; j< t->length; j++) { -
src/fvec.c
r89e9e71 rd4791e5 23 23 24 24 fvec_t * new_fvec( uint_t length) { 25 fvec_t * s; 25 26 if ((sint_t)length <= 0) { 26 27 return NULL; 27 28 } 28 fvec_t *s = AUBIO_NEW(fvec_t);29 s = AUBIO_NEW(fvec_t); 29 30 s->length = length; 30 31 s->data = AUBIO_ARRAY(smpl_t, s->length); -
src/io/sink_sndfile.c
r89e9e71 rd4791e5 47 47 aubio_sink_sndfile_t * new_aubio_sink_sndfile(char_t * path, uint_t samplerate) { 48 48 aubio_sink_sndfile_t * s = AUBIO_NEW(aubio_sink_sndfile_t); 49 SF_INFO sfinfo; 49 50 50 51 if (path == NULL) { … … 59 60 60 61 /* set output format */ 61 SF_INFO sfinfo;62 62 AUBIO_MEMSET(&sfinfo, 0, sizeof (sfinfo)); 63 63 sfinfo.samplerate = s->samplerate; … … 92 92 int nsamples = channels*write; 93 93 smpl_t *pwrite; 94 sf_count_t written_frames; 94 95 95 96 if (write > s->max_size) { … … 107 108 } 108 109 109 sf_count_twritten_frames = sf_write_float (s->handle, s->scratch_data, nsamples);110 written_frames = sf_write_float (s->handle, s->scratch_data, nsamples); 110 111 if (written_frames/channels != write) { 111 112 AUBIO_WRN("trying to write %d frames to %s, but only %d could be written", -
src/io/source_avcodec.c
r89e9e71 rd4791e5 62 62 // hack to create or re-create the context the first time _do or _do_multi is called 63 63 void aubio_source_avcodec_reset_resampler(aubio_source_avcodec_t * s, uint_t multi); 64 void aubio_source_avcodec_readframe(aubio_source_avcodec_t *s, uint_t * read_samples); 64 65 65 66 aubio_source_avcodec_t * new_aubio_source_avcodec(char_t * path, uint_t samplerate, uint_t hop_size) { … … 279 280 (uint8_t **)avFrame->data, in_linesize, in_samples); 280 281 if (out_samples <= 0) { 281 AUBIO_ERR("No sample found while converting frame (%s)\n", s->path);282 //AUBIO_ERR("No sample found while converting frame (%s)\n", s->path); 282 283 goto beach; 283 284 } -
src/io/source_sndfile.c
r89e9e71 rd4791e5 64 64 aubio_source_sndfile_t * new_aubio_source_sndfile(char_t * path, uint_t samplerate, uint_t hop_size) { 65 65 aubio_source_sndfile_t * s = AUBIO_NEW(aubio_source_sndfile_t); 66 SF_INFO sfinfo; 66 67 67 68 if (path == NULL) { … … 83 84 84 85 // try opening the file, getting the info in sfinfo 85 SF_INFO sfinfo;86 86 AUBIO_MEMSET(&sfinfo, 0, sizeof (sfinfo)); 87 87 s->handle = sf_open (s->path, SFM_READ, &sfinfo); -
src/lvec.c
r89e9e71 rd4791e5 23 23 24 24 lvec_t * new_lvec( uint_t length) { 25 lvec_t * s; 25 26 if ((sint_t)length <= 0) { 26 27 return NULL; 27 28 } 28 lvec_t *s = AUBIO_NEW(lvec_t);29 s = AUBIO_NEW(lvec_t); 29 30 s->length = length; 30 31 s->data = AUBIO_ARRAY(lsmp_t, s->length); … … 37 38 } 38 39 39 void lvec_ write_sample(lvec_t *s, lsmp_t data, uint_t position) {40 void lvec_set_sample(lvec_t *s, lsmp_t data, uint_t position) { 40 41 s->data[position] = data; 41 42 } 43 42 44 lsmp_t lvec_get_sample(lvec_t *s, uint_t position) { 43 45 return s->data[position]; -
src/mathutils.c
r89e9e71 rd4791e5 50 50 { 51 51 fvec_t * win = new_fvec (length); 52 uint_t err; 52 53 if (win == NULL) { 53 54 return NULL; 54 55 } 55 uint_terr = fvec_set_window (win, window_type);56 err = fvec_set_window (win, window_type); 56 57 if (err != 0) { 57 58 del_fvec(win); … … 417 418 418 419 smpl_t fvec_quadratic_peak_pos (fvec_t * x, uint_t pos) { 419 smpl_t s0, s1, s2; 420 smpl_t s0, s1, s2; uint_t x0, x2; 420 421 if (pos == 0 || pos == x->length - 1) return pos; 421 uint_tx0 = (pos < 1) ? pos : pos - 1;422 uint_tx2 = (pos + 1 < x->length) ? pos + 1 : pos;422 x0 = (pos < 1) ? pos : pos - 1; 423 x2 = (pos + 1 < x->length) ? pos + 1 : pos; 423 424 if (x0 == pos) return (x->data[pos] <= x->data[x2]) ? pos : x2; 424 425 if (x2 == pos) return (x->data[pos] <= x->data[x0]) ? pos : x0; … … 448 449 aubio_freqtomidi (smpl_t freq) 449 450 { 451 smpl_t midi; 450 452 if (freq < 2. || freq > 100000.) return 0.; // avoid nans and infs 451 453 /* log(freq/A-2)/log(2) */ 452 smpl_tmidi = freq / 6.875;454 midi = freq / 6.875; 453 455 midi = LOG (midi) / 0.69314718055995; 454 456 midi *= 12; … … 460 462 aubio_miditofreq (smpl_t midi) 461 463 { 464 smpl_t freq; 462 465 if (midi > 140.) return 0.; // avoid infs 463 smpl_tfreq = (midi + 3.) / 12.;466 freq = (midi + 3.) / 12.; 464 467 freq = EXP (freq * 0.69314718055995); 465 468 freq *= 6.875; -
src/onset/peakpicker.c
r89e9e71 rd4791e5 166 166 167 167 aubio_peakpicker_t * 168 new_aubio_peakpicker ( )168 new_aubio_peakpicker (void) 169 169 { 170 170 aubio_peakpicker_t *t = AUBIO_NEW (aubio_peakpicker_t); -
src/pitch/pitch.c
r89e9e71 rd4791e5 367 367 aubio_pitch_do_specacf (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * out) 368 368 { 369 smpl_t pitch = 0., period; 369 370 aubio_pitch_slideblock (p, ibuf); 370 371 aubio_pitchspecacf_do (p->p_object, p->buf, out); 371 372 //out->data[0] = aubio_bintofreq (out->data[0], p->samplerate, p->bufsize); 372 smpl_t pitch = 0.,period = out->data[0];373 period = out->data[0]; 373 374 if (period > 0) { 374 375 pitch = p->samplerate / period; -
src/pitch/pitchspecacf.c
r89e9e71 rd4791e5 57 57 aubio_pitchspecacf_do (aubio_pitchspecacf_t * p, fvec_t * input, fvec_t * output) 58 58 { 59 uint_t l ;59 uint_t l, tau; 60 60 fvec_t *fftout = p->fftout; 61 61 // window the input … … 75 75 } 76 76 // get the minimum 77 uint_ttau = fvec_min_elem (p->acf);77 tau = fvec_min_elem (p->acf); 78 78 // get the interpolated minimum 79 79 output->data[0] = fvec_quadratic_peak_pos (p->acf, tau) * 2.; -
src/pitch/pitchyinfft.c
r89e9e71 rd4791e5 58 58 new_aubio_pitchyinfft (uint_t samplerate, uint_t bufsize) 59 59 { 60 uint_t i = 0, j = 1; 61 smpl_t freq = 0, a0 = 0, a1 = 0, f0 = 0, f1 = 0; 60 62 aubio_pitchyinfft_t *p = AUBIO_NEW (aubio_pitchyinfft_t); 61 63 p->winput = new_fvec (bufsize); … … 67 69 p->win = new_aubio_window ("hanningz", bufsize); 68 70 p->weight = new_fvec (bufsize / 2 + 1); 69 uint_t i = 0, j = 1;70 smpl_t freq = 0, a0 = 0, a1 = 0, f0 = 0, f1 = 0;71 71 for (i = 0; i < p->weight->length; i++) { 72 72 freq = (smpl_t) i / (smpl_t) bufsize *(smpl_t) samplerate; -
src/spectral/filterbank_mel.c
r89e9e71 rd4791e5 25 25 #include "cvec.h" 26 26 #include "spectral/filterbank.h" 27 #include "spectral/filterbank_mel.h" 27 28 #include "mathutils.h" 28 29 … … 34 35 fmat_t *filters = aubio_filterbank_get_coeffs (fb); 35 36 uint_t n_filters = filters->height, win_s = filters->length; 37 fvec_t *lower_freqs, *upper_freqs, *center_freqs; 38 fvec_t *triangle_heights, *fft_freqs; 36 39 37 40 uint_t fn; /* filter counter */ 38 41 uint_t bin; /* bin counter */ 42 43 smpl_t riseInc, downInc; 39 44 40 45 /* freqs define the bands of triangular overlapping windows. … … 56 61 57 62 /* convenience reference to lower/center/upper frequency for each triangle */ 58 fvec_t *lower_freqs = new_fvec (n_filters);59 fvec_t *upper_freqs = new_fvec (n_filters);60 fvec_t *center_freqs = new_fvec (n_filters);63 lower_freqs = new_fvec (n_filters); 64 upper_freqs = new_fvec (n_filters); 65 center_freqs = new_fvec (n_filters); 61 66 62 67 /* height of each triangle */ 63 fvec_t *triangle_heights = new_fvec (n_filters);68 triangle_heights = new_fvec (n_filters); 64 69 65 70 /* lookup table of each bin frequency in hz */ 66 f vec_t *fft_freqs = new_fvec (win_s);71 fft_freqs = new_fvec (win_s); 67 72 68 73 /* fill up the lower/center/upper */ … … 112 117 113 118 /* compute positive slope step size */ 114 smpl_triseInc =119 riseInc = 115 120 triangle_heights->data[fn] / 116 121 (center_freqs->data[fn] - lower_freqs->data[fn]); … … 128 133 129 134 /* compute negative slope step size */ 130 smpl_tdownInc =135 downInc = 131 136 triangle_heights->data[fn] / 132 137 (upper_freqs->data[fn] - center_freqs->data[fn]); … … 176 181 uint_t fn; /* filter counter */ 177 182 183 smpl_t lastlinearCF; 184 178 185 /* buffers to compute filter frequencies */ 179 186 fvec_t *freqs = new_fvec (n_filters + 2); … … 183 190 freqs->data[fn] = lowestFrequency + fn * linearSpacing; 184 191 } 185 smpl_tlastlinearCF = freqs->data[fn - 1];192 lastlinearCF = freqs->data[fn - 1]; 186 193 187 194 /* second step: fill all the log filter frequencies */ -
src/spectral/mfcc.c
r89e9e71 rd4791e5 52 52 /* allocate space for mfcc object */ 53 53 aubio_mfcc_t *mfcc = AUBIO_NEW (aubio_mfcc_t); 54 smpl_t scaling; 54 55 55 56 uint_t i, j; … … 71 72 /* compute DCT transform dct_coeffs[i][j] as 72 73 cos ( j * (i+.5) * PI / n_filters ) */ 73 s mpl_t scaling = 1. / SQRT (n_filters / 2.);74 scaling = 1. / SQRT (n_filters / 2.); 74 75 for (i = 0; i < n_filters; i++) { 75 76 for (j = 0; j < n_coefs; j++) { -
src/spectral/ooura_fft8g.c
r89e9e71 rd4791e5 1 // 2modifications made for aubio:1 // modifications made for aubio: 2 2 // - replace all 'double' with 'smpl_t' 3 3 // - include "aubio_priv.h" (for config.h and types.h) 4 // - add missing prototypes 4 5 5 6 #include "aubio_priv.h" 7 8 void cdft(int n, int isgn, smpl_t *a, int *ip, smpl_t *w); 9 void rdft(int n, int isgn, smpl_t *a, int *ip, smpl_t *w); 10 void ddct(int n, int isgn, smpl_t *a, int *ip, smpl_t *w); 11 void ddst(int n, int isgn, smpl_t *a, int *ip, smpl_t *w); 12 void dfct(int n, smpl_t *a, smpl_t *t, int *ip, smpl_t *w); 13 void dfst(int n, smpl_t *a, smpl_t *t, int *ip, smpl_t *w); 14 void makewt(int nw, int *ip, smpl_t *w); 15 void makect(int nc, int *ip, smpl_t *c); 16 void bitrv2(int n, int *ip, smpl_t *a); 17 void bitrv2conj(int n, int *ip, smpl_t *a); 18 void cftfsub(int n, smpl_t *a, smpl_t *w); 19 void cftbsub(int n, smpl_t *a, smpl_t *w); 20 void cft1st(int n, smpl_t *a, smpl_t *w); 21 void cftmdl(int n, int l, smpl_t *a, smpl_t *w); 22 void rftfsub(int n, smpl_t *a, int nc, smpl_t *c); 23 void rftbsub(int n, smpl_t *a, int nc, smpl_t *c); 24 void dctsub(int n, smpl_t *a, int nc, smpl_t *c); 25 void dstsub(int n, smpl_t *a, int nc, smpl_t *c); 6 26 7 27 /* -
src/spectral/phasevoc.c
r89e9e71 rd4791e5 120 120 const smpl_t * datanew, uint_t win_s, uint_t hop_s) 121 121 { 122 #if !HAVE_MEMCPY_HACKS 122 123 uint_t i; 123 124 for (i = 0; i < win_s - hop_s; i++) … … 127 128 for (i = 0; i < win_s - hop_s; i++) 128 129 dataold[i] = data[i + hop_s]; 130 #else 131 memcpy(data, dataold, (win_s - hop_s) * sizeof(smpl_t)); 132 data += win_s - hop_s; 133 memcpy(data, datanew, hop_s * sizeof(smpl_t)); 134 data -= win_s - hop_s; 135 data += hop_s; 136 memcpy(dataold, data, (win_s - hop_s) * sizeof(smpl_t)); 137 #endif 129 138 } 130 139 -
src/spectral/statistics.c
r89e9e71 rd4791e5 22 22 #include "cvec.h" 23 23 #include "spectral/specdesc.h" 24 25 void aubio_specdesc_centroid (aubio_specdesc_t * o, cvec_t * spec, 26 fvec_t * desc); 27 void aubio_specdesc_spread (aubio_specdesc_t * o, cvec_t * spec, 28 fvec_t * desc); 29 void aubio_specdesc_skewness (aubio_specdesc_t * o, cvec_t * spec, 30 fvec_t * desc); 31 void aubio_specdesc_kurtosis (aubio_specdesc_t * o, cvec_t * spec, 32 fvec_t * desc); 33 void aubio_specdesc_slope (aubio_specdesc_t * o, cvec_t * spec, 34 fvec_t * desc); 35 void aubio_specdesc_decrease (aubio_specdesc_t * o, cvec_t * spec, 36 fvec_t * desc); 37 void aubio_specdesc_rolloff (aubio_specdesc_t * o, cvec_t * spec, 38 fvec_t * desc); 39 40 41 smpl_t cvec_sum (cvec_t * s); 42 smpl_t cvec_mean (cvec_t * s); 43 smpl_t cvec_centroid (cvec_t * s); 44 smpl_t cvec_moment (cvec_t * s, uint_t moment); 24 45 25 46 smpl_t -
src/synth/wavetable.c
r89e9e71 rd4791e5 43 43 aubio_wavetable_t *new_aubio_wavetable(uint_t samplerate, uint_t blocksize) 44 44 { 45 uint_t i = 0; 45 46 aubio_wavetable_t *s = AUBIO_NEW(aubio_wavetable_t); 46 47 if ((sint_t)samplerate <= 0) { … … 48 49 goto beach; 49 50 } 50 uint_t i = 0;51 51 s->samplerate = samplerate; 52 52 s->blocksize = blocksize; … … 115 115 for (j = 0; j < output->length; j++) { 116 116 smpl_t inc = aubio_parameter_get_next_value( s->freq ); 117 smpl_t amp = aubio_parameter_get_next_value ( s->amp ); 117 118 inc *= (smpl_t)(s->wavetable_length) / (smpl_t) (s->samplerate); 118 119 pos += inc; … … 120 121 pos -= s->wavetable_length; 121 122 } 122 smpl_t amp = aubio_parameter_get_next_value ( s->amp );123 123 for (i = 0; i < output->height; i++) { 124 124 output->data[i][j] = amp * interp_2(s->wavetable, pos); -
src/tempo/beattracking.c
r89e9e71 rd4791e5 62 62 aubio_beattracking_t *p = AUBIO_NEW (aubio_beattracking_t); 63 63 uint_t i = 0; 64 p->hop_size = hop_size;65 p->samplerate = samplerate;66 64 /* default value for rayleigh weighting - sets preferred tempo to 120bpm */ 67 65 smpl_t rayparam = 60. * samplerate / 120. / hop_size; … … 73 71 uint_t step = winlen / 4; /* 1.5 seconds */ 74 72 73 p->hop_size = hop_size; 74 p->samplerate = samplerate; 75 75 p->lastbeat = 0; 76 76 p->counter = 0; -
src/tempo/tempo.c
r89e9e71 rd4791e5 28 28 #include "mathutils.h" 29 29 #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); 30 51 31 52 /* structure to store object state */ -
src/temporal/a_weighting.c
r89e9e71 rd4791e5 29 29 aubio_filter_set_a_weighting (aubio_filter_t * f, uint_t samplerate) 30 30 { 31 uint_t order; lsmp_t *a, *b; lvec_t *as, *bs; 31 32 aubio_filter_set_samplerate (f, samplerate); 32 lvec_t *bs = aubio_filter_get_feedforward (f);33 lvec_t *as = aubio_filter_get_feedback (f);34 lsmp_t *b = bs->data, *a = as->data;35 uint_torder = aubio_filter_get_order (f);33 bs = aubio_filter_get_feedforward (f); 34 as = aubio_filter_get_feedback (f); 35 b = bs->data, a = as->data; 36 order = aubio_filter_get_order (f); 36 37 37 38 if (order != 7) { -
src/temporal/biquad.c
r89e9e71 rd4791e5 23 23 #include "lvec.h" 24 24 #include "temporal/filter.h" 25 #include "temporal/biquad.h" 25 26 26 27 uint_t -
src/temporal/c_weighting.c
r89e9e71 rd4791e5 29 29 aubio_filter_set_c_weighting (aubio_filter_t * f, uint_t samplerate) 30 30 { 31 uint_t order; lsmp_t *a, *b; lvec_t *as, *bs; 31 32 aubio_filter_set_samplerate (f, samplerate); 32 lvec_t *bs = aubio_filter_get_feedforward (f);33 lvec_t *as = aubio_filter_get_feedback (f);34 lsmp_t *b = bs->data, *a = as->data;35 uint_torder = aubio_filter_get_order (f);33 bs = aubio_filter_get_feedforward (f); 34 as = aubio_filter_get_feedback (f); 35 b = bs->data, a = as->data; 36 order = aubio_filter_get_order (f); 36 37 37 38 if ( order != 5 ) {
Note: See TracChangeset
for help on using the changeset viewer.