Changes in / [c1656cf:7873363]
- Files:
-
- 59 added
- 42 deleted
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified Makefile.am ¶
rc1656cf r7873363 36 36 uninstall-hook: uninstall-pkgconfig 37 37 38 lcov: all 39 mkdir -p $(top_builddir)/lcov 40 lcov --directory $(top_builddir) --output-file $(top_builddir)/lcov/aubio.info --compat-libtool --zerocounters 41 cd tests/python && ./run_all_tests -v || echo "some tests failed" 42 lcov --directory $(top_builddir) --output-file $(top_builddir)/lcov/aubio.info --compat-libtool --capture 43 genhtml --output-directory $(top_builddir)/lcov $(top_builddir)/lcov/aubio.info -
TabularUnified configure.ac ¶
rc1656cf r7873363 35 35 dnl Enable debugging (no) 36 36 AC_ARG_ENABLE(debug, 37 [ --enable-debug[[=value]] compile with debug [[default=no]]],37 AC_HELP_STRING([--enable-debug],[compile in debug mode [[default=no]]]), 38 38 with_debug="yes", 39 39 with_debug="no") … … 46 46 dnl Enable full warnings (yes) 47 47 AC_ARG_ENABLE(warnings, 48 [ --enable-warnings[[=value]] compile with all gcc warnings [[default=yes]]],48 AC_HELP_STRING([--enable-warnings],[compile with all gcc warnings [[default=yes]]]), 49 49 with_warnme="no", 50 50 with_warnme="yes") … … 67 67 fi 68 68 69 dnl fail on compilation warnings 69 70 AC_ARG_ENABLE(errorfail, 70 [ --enable-errorfail[[=value]] fail on compilation warnings [[default=no]]],71 AC_HELP_STRING([--enable-errorfail],[fail on compilation warnings [[default=no]]]), 71 72 AUBIO_CFLAGS="$AUBIO_CFLAGS -Werror -Wmissing-prototypes -Wmissing-declarations -Wno-unused-parameter", 72 with_warnme="no") 73 with_errorfail="no") 74 75 dnl add gcov/lcov profiling and coverage flags 76 AC_ARG_ENABLE(lcov, 77 AC_HELP_STRING([--enable-lcov],[compile with gcov/lcov profiling flags [[default=no]]]), 78 AUBIO_CFLAGS="$AUBIO_CFLAGS -fprofile-arcs -ftest-coverage", 79 with_lcov="no") 73 80 74 81 dnl Check for libtool … … 241 248 ext/Makefile 242 249 examples/Makefile 243 examples/tests/Makefile 250 tests/Makefile 251 tests/src/Makefile 244 252 sounds/Makefile 245 253 swig/Makefile -
TabularUnified examples/Makefile.am ¶
rc1656cf r7873363 1 if COMPILE_TESTS2 SUBDIRS = tests3 endif4 5 1 # global flags 6 2 AM_CFLAGS = -DAUBIO_PREFIX=\"$(prefix)\" -I$(top_srcdir)/src -I$(top_srcdir)/ext @AUBIO_CFLAGS@ @LASH_CFLAGS@ @FFTWLIB_CFLAGS@ -
TabularUnified examples/aubioonset.c ¶
rc1656cf r7873363 72 72 if (isonset && output_filename == NULL) { 73 73 if(frames >= 4) { 74 outmsg("%f\n",(frames- 4)*overlap_size/(float)samplerate);75 } else if (frames < 4) {74 outmsg("%f\n",(frames-frames_delay)*overlap_size/(float)samplerate); 75 } else if (frames < frames_delay) { 76 76 outmsg("%f\n",0.); 77 77 } … … 80 80 81 81 int main(int argc, char **argv) { 82 frames_delay = 4; 82 83 examples_common_init(argc,argv); 83 84 examples_common_process(aubio_process,process_print); -
TabularUnified examples/utils.c ¶
rc1656cf r7873363 22 22 void save_data (void); 23 23 void restore_data(lash_config_t * lash_config); 24 void flush_process(aubio_process_func_t process_func, aubio_print_func_t print); 24 25 pthread_t lash_thread; 25 26 #endif /* LASH_SUPPORT */ … … 33 34 int usejack = 0; 34 35 int usedoubled = 1; 36 int frames_delay = 0; 35 37 36 38 … … 60 62 int isonset = 0; 61 63 aubio_pickpeak_t * parms; 64 62 65 63 66 /* pitch objects */ … … 171 174 else if (strcmp(optarg,"kl") == 0) 172 175 type_onset = aubio_onset_kl; 176 else if (strcmp(optarg,"specflux") == 0) 177 type_onset = aubio_onset_specflux; 173 178 else { 174 179 errmsg("unknown onset type.\n"); … … 300 305 fftgrain = new_cvec(buffer_size, channels); 301 306 302 303 307 if (usepitch) { 304 308 pitchdet = new_aubio_pitchdetection(buffer_size*4, … … 313 317 /* phase vocoder */ 314 318 pv = new_aubio_pvoc(buffer_size, overlap_size, channels); 315 316 319 /* onsets */ 317 320 parms = new_aubio_peakpicker(threshold); … … 347 350 del_fvec(onset); 348 351 del_fvec(woodblock); 349 350 352 aubio_cleanup(); 351 353 } … … 397 399 398 400 debug("Processed %d frames of %d samples.\n", frames, buffer_size); 401 402 flush_process(process_func, print); 399 403 del_aubio_sndfile(file); 400 404 … … 405 409 } 406 410 411 void flush_process(aubio_process_func_t process_func, aubio_print_func_t print){ 412 uint i,j; 413 for (i = 0; i < channels; i++) { 414 for (j = 0; j < obuf->length; j++) { 415 fvec_write_sample(obuf,0.,i,j); 416 } 417 } 418 for (i = 0; (signed)i < frames_delay; i++) { 419 process_func(ibuf->data, obuf->data, overlap_size); 420 print(); 421 } 422 } 407 423 408 424 -
TabularUnified examples/utils.h ¶
rc1656cf r7873363 42 42 extern int usejack; 43 43 extern int usedoubled; 44 extern int frames_delay; 44 45 extern unsigned int median; 45 46 extern const char * output_filename; … … 98 99 extern aubio_pickpeak_t * parms; 99 100 101 100 102 /* pitch objects */ 101 103 extern smpl_t pitch; -
TabularUnified python/aubio/aubioclass.py ¶
rc1656cf r7873363 43 43 else: 44 44 self.file = new_aubio_sndfile_ro(filename) 45 if self.file == None: raise(ValueError, "failed opening file") 45 46 def __del__(self): 46 del_aubio_sndfile(self.file)47 if self.file != None: del_aubio_sndfile(self.file) 47 48 def info(self): 48 49 aubio_sndfile_info(self.file) … … 73 74 aubio_onsetdetection(self.od,tc(),tf()) 74 75 def __del__(self): 75 aubio_onsetdetection_free(self.od)76 del_aubio_onsetdetection(self.od) 76 77 77 78 class peakpick: -
TabularUnified python/aubio/task/utils.py ¶
rc1656cf r7873363 17 17 elif nvalue == 'mkl' : 18 18 return aubio_onset_mkl 19 elif nvalue == 'specflux' : 20 return aubio_onset_specflux 19 21 elif nvalue == 'dual' : 20 22 return 'dual' 21 23 else: 22 24 import sys 23 print "unknown onset detection function selected "25 print "unknown onset detection function selected: %s" % nvalue 24 26 sys.exit(1) 25 27 -
TabularUnified src/Makefile.am ¶
rc1656cf r7873363 6 6 fft.h \ 7 7 sample.h \ 8 fvec.h \ 9 cvec.h \ 8 10 hist.h \ 9 11 scale.h \ … … 37 39 fft.c \ 38 40 fft.h \ 39 sample.c \ 40 sample.h \ 41 fvec.c \ 42 fvec.h \ 43 cvec.c \ 44 cvec.h \ 41 45 hist.c \ 42 46 hist.h \ -
TabularUnified src/aubio.h ¶
rc1656cf r7873363 1 1 /* 2 2 Copyright (C) 2003 Paul Brossier <piem@altern.org> 3 3 4 5 6 7 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 8 9 10 11 12 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 13 14 15 16 17 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 18 18 */ 19 19 … … 22 22 * \section whatis Introduction 23 23 * 24 * 25 * 24 * Aubio is a library for audio labelling: it provides functions for pitch 25 * estimation, onset detection, beat tracking, and other annotation tasks. 26 26 * 27 27 * \verbinclude README … … 29 29 * \section bugs bugs and todo 30 30 * 31 * 32 * 31 * This software is under development. It needs debugging and 32 * optimisations. 33 33 * 34 34 * See <a href='bug.html'>bugs</a> and <a href='todo.html'>todo</a> lists. -
TabularUnified src/aubio_priv.h ¶
rc1656cf r7873363 1 1 /* 2 Copyright (C) 2003Paul Brossier2 Copyright (C) 2003-2007 Paul Brossier 3 3 4 5 6 7 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 8 9 10 11 12 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 13 14 15 16 17 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 18 18 */ 19 19 … … 71 71 72 72 /* Memory management */ 73 #define AUBIO_MALLOC(_n) 74 #define AUBIO_REALLOC(_p,_n) 75 #define AUBIO_NEW(_t) 76 #define AUBIO_ARRAY(_t,_n) 77 #define AUBIO_MEMCPY(_dst,_src,_n) 78 #define AUBIO_MEMSET(_dst,_src,_t) 79 #define AUBIO_FREE(_p) free(_p)73 #define AUBIO_MALLOC(_n) malloc(_n) 74 #define AUBIO_REALLOC(_p,_n) realloc(_p,_n) 75 #define AUBIO_NEW(_t) (_t*)malloc(sizeof(_t)) 76 #define AUBIO_ARRAY(_t,_n) (_t*)malloc((_n)*sizeof(_t)) 77 #define AUBIO_MEMCPY(_dst,_src,_n) memcpy(_dst,_src,_n) 78 #define AUBIO_MEMSET(_dst,_src,_t) memset(_dst,_src,_t) 79 #define AUBIO_FREE(_p) free(_p) 80 80 81 81 -
TabularUnified src/fft.c ¶
rc1656cf r7873363 19 19 20 20 #include "aubio_priv.h" 21 #include "sample.h" 21 #include "fvec.h" 22 #include "cvec.h" 22 23 #include "mathutils.h" 23 24 #include "fft.h" 24 25 25 26 #if FFTW3F_SUPPORT 26 #define fftw_malloc 27 #define fftw_free 28 #define fftw_execute 29 #define fftw_plan_dft_r2c_1d 30 #define fftw_plan_dft_c2r_1d 31 #define fftw_plan_r2r_1d fftwf_plan_r2r_1d32 #define fftw_plan 33 #define fftw_destroy_plan 27 #define fftw_malloc fftwf_malloc 28 #define fftw_free fftwf_free 29 #define fftw_execute fftwf_execute 30 #define fftw_plan_dft_r2c_1d fftwf_plan_dft_r2c_1d 31 #define fftw_plan_dft_c2r_1d fftwf_plan_dft_c2r_1d 32 #define fftw_plan_r2r_1d fftwf_plan_r2r_1d 33 #define fftw_plan fftwf_plan 34 #define fftw_destroy_plan fftwf_destroy_plan 34 35 #endif 35 36 … … 41 42 42 43 struct _aubio_fft_t { 43 uint_t fft_size; 44 uint_t channels; 45 real_t *in, *out; 46 fft_data_t *specdata; 47 fftw_plan pfw, pbw; 44 uint_t winsize; 45 uint_t channels; 46 uint_t fft_size; 47 real_t *in, *out; 48 fftw_plan pfw, pbw; 49 fft_data_t * specdata; /* complex spectral data */ 50 fvec_t * compspec; 48 51 }; 49 52 50 static void aubio_fft_getspectrum(fft_data_t * spectrum, smpl_t *norm, smpl_t * phas, uint_t size); 51 52 aubio_fft_t * new_aubio_fft(uint_t size) { 53 aubio_fft_t * s = AUBIO_NEW(aubio_fft_t);54 55 s->in = AUBIO_ARRAY(real_t,size);56 s->out = AUBIO_ARRAY(real_t,size);57 s->specdata = (fft_data_t*)fftw_malloc(sizeof(fft_data_t)*size);58 53 aubio_fft_t * new_aubio_fft(uint_t winsize, uint_t channels) { 54 aubio_fft_t * s = AUBIO_NEW(aubio_fft_t); 55 s->winsize = winsize; 56 s->channels = channels; 57 /* allocate memory */ 58 s->in = AUBIO_ARRAY(real_t,winsize); 59 s->out = AUBIO_ARRAY(real_t,winsize); 60 s->compspec = new_fvec(winsize,channels); 61 /* create plans */ 59 62 #ifdef HAVE_COMPLEX_H 60 s->pfw = fftw_plan_dft_r2c_1d(size, s->in, s->specdata, FFTW_ESTIMATE); 61 s->pbw = fftw_plan_dft_c2r_1d(size, s->specdata, s->out, FFTW_ESTIMATE); 63 s->fft_size = winsize/2 + 1; 64 s->specdata = (fft_data_t*)fftw_malloc(sizeof(fft_data_t)*s->fft_size); 65 s->pfw = fftw_plan_dft_r2c_1d(winsize, s->in, s->specdata, FFTW_ESTIMATE); 66 s->pbw = fftw_plan_dft_c2r_1d(winsize, s->specdata, s->out, FFTW_ESTIMATE); 62 67 #else 63 s->pfw = fftw_plan_r2r_1d(size, s->in, s->specdata, FFTW_R2HC, FFTW_ESTIMATE); 64 s->pbw = fftw_plan_r2r_1d(size, s->specdata, s->out, FFTW_HC2R, FFTW_ESTIMATE); 68 s->fft_size = winsize; 69 s->specdata = (fft_data_t*)fftw_malloc(sizeof(fft_data_t)*s->fft_size); 70 s->pfw = fftw_plan_r2r_1d(winsize, s->in, s->specdata, FFTW_R2HC, FFTW_ESTIMATE); 71 s->pbw = fftw_plan_r2r_1d(winsize, s->specdata, s->out, FFTW_HC2R, FFTW_ESTIMATE); 65 72 #endif 66 73 return s; 67 74 } 68 75 69 76 void del_aubio_fft(aubio_fft_t * s) { 70 /* destroy data */ 71 fftw_destroy_plan(s->pfw); 72 fftw_destroy_plan(s->pbw); 73 fftw_free(s->specdata); 74 AUBIO_FREE(s->out); 75 AUBIO_FREE(s->in ); 76 AUBIO_FREE(s); 77 /* destroy data */ 78 del_fvec(s->compspec); 79 fftw_destroy_plan(s->pfw); 80 fftw_destroy_plan(s->pbw); 81 fftw_free(s->specdata); 82 AUBIO_FREE(s->out); 83 AUBIO_FREE(s->in ); 84 AUBIO_FREE(s); 77 85 } 78 86 79 void aubio_fft_do(const aubio_fft_t * s, 80 const smpl_t * data, fft_data_t * spectrum, 81 const uint_t size) { 82 uint_t i; 83 for (i=0;i<size;i++) s->in[i] = data[i]; 84 fftw_execute(s->pfw); 85 for (i=0;i<size;i++) spectrum[i] = s->specdata[i]; 87 void aubio_fft_do(aubio_fft_t * s, fvec_t * input, cvec_t * spectrum) { 88 aubio_fft_do_complex(s, input, s->compspec); 89 aubio_fft_get_spectrum(s->compspec, spectrum); 86 90 } 87 91 88 void aubio_fft_rdo(const aubio_fft_t * s, 89 const fft_data_t * spectrum, 90 smpl_t * data, 91 const uint_t size) { 92 uint_t i; 93 const smpl_t renorm = 1./(smpl_t)size; 94 for (i=0;i<size;i++) s->specdata[i] = spectrum[i]; 95 fftw_execute(s->pbw); 96 for (i=0;i<size;i++) data[i] = s->out[i]*renorm; 92 void aubio_fft_rdo(aubio_fft_t * s, cvec_t * spectrum, fvec_t * output) { 93 aubio_fft_get_realimag(spectrum, s->compspec); 94 aubio_fft_rdo_complex(s, s->compspec, output); 97 95 } 98 96 97 void aubio_fft_do_complex(aubio_fft_t * s, fvec_t * input, fvec_t * compspec) { 98 uint_t i, j; 99 for (i = 0; i < s->channels; i++) { 100 for (j=0; j < s->winsize; j++) { 101 s->in[j] = input->data[i][j]; 102 } 103 fftw_execute(s->pfw); 99 104 #ifdef HAVE_COMPLEX_H 100 101 void aubio_fft_getnorm(smpl_t * norm, fft_data_t * spectrum, uint_t size) { 102 uint_t i; 103 for (i=0;i<size/2+1;i++) norm[i] = ABSC(spectrum[i]); 104 //for (i=0;i<size/2+1;i++) AUBIO_DBG("%f\n", norm[i]); 105 } 106 107 void aubio_fft_getphas(smpl_t * phas, fft_data_t * spectrum, uint_t size) { 108 uint_t i; 109 for (i=0;i<size/2+1;i++) phas[i] = ARGC(spectrum[i]); 110 //for (i=0;i<size/2+1;i++) AUBIO_DBG("%f\n", phas[i]); 111 } 112 113 void aubio_fft_getspectrum(fft_data_t * spectrum, smpl_t *norm, smpl_t * phas, uint_t size) { 114 uint_t j; 115 for (j=0; j<size/2+1; j++) { 116 spectrum[j] = CEXPC(I*phas[j]); 117 spectrum[j] *= norm[j]; 105 compspec->data[i][0] = REAL(s->specdata[0]); 106 for (j = 1; j < s->fft_size -1 ; j++) { 107 compspec->data[i][j] = REAL(s->specdata[j]); 108 compspec->data[i][compspec->length - j] = IMAG(s->specdata[j]); 109 } 110 compspec->data[i][s->fft_size-1] = REAL(s->specdata[s->fft_size-1]); 111 #else 112 for (j = 0; j < s->fft_size; j++) { 113 compspec->data[i][j] = s->specdata[j]; 114 } 115 #endif 118 116 } 119 117 } 120 118 119 void aubio_fft_rdo_complex(aubio_fft_t * s, fvec_t * compspec, fvec_t * output) { 120 uint_t i, j; 121 const smpl_t renorm = 1./(smpl_t)s->winsize; 122 for (i = 0; i < compspec->channels; i++) { 123 #ifdef HAVE_COMPLEX_H 124 s->specdata[0] = compspec->data[i][0]; 125 for (j=1; j < s->fft_size - 1; j++) { 126 s->specdata[j] = compspec->data[i][j] + 127 I * compspec->data[i][compspec->length - j]; 128 } 129 s->specdata[s->fft_size - 1] = compspec->data[i][s->fft_size - 1]; 121 130 #else 122 123 void aubio_fft_getnorm(smpl_t * norm, fft_data_t * spectrum, uint_t size) { 124 uint_t i; 125 norm[0] = -spectrum[0]; 126 for (i=1;i<size/2+1;i++) norm[i] = SQRT(SQR(spectrum[i]) + SQR(spectrum[size-i])); 127 //for (i=0;i<size/2+1;i++) AUBIO_DBG("%f\n", norm[i]); 128 } 129 130 void aubio_fft_getphas(smpl_t * phas, fft_data_t * spectrum, uint_t size) { 131 uint_t i; 132 phas[0] = PI; 133 for (i=1;i<size/2+1;i++) phas[i] = atan2f(spectrum[size-i] , spectrum[i]); 134 //for (i=0;i<size/2+1;i++) AUBIO_DBG("%f\n", phas[i]); 135 } 136 137 void aubio_fft_getspectrum(fft_data_t * spectrum, smpl_t *norm, smpl_t * phas, uint_t size) { 138 uint_t j; 139 for (j=0; j<size/2+1; j++) { 140 spectrum[j] = norm[j]*COS(phas[j]); 141 } 142 for (j=1; j<size/2+1; j++) { 143 spectrum[size-j] = norm[j]*SIN(phas[j]); 131 for (j=0; j < s->fft_size; j++) { 132 s->specdata[j] = compspec->data[i][j]; 133 } 134 #endif 135 fftw_execute(s->pbw); 136 for (j = 0; j < output->length; j++) { 137 output->data[i][j] = s->out[j]*renorm; 138 } 144 139 } 145 140 } 146 141 147 #endif 148 149 /* new interface aubio_mfft */ 150 struct _aubio_mfft_t { 151 aubio_fft_t * fft; /* fftw interface */ 152 fft_data_t ** spec; /* complex spectral data */ 153 uint_t winsize; 154 uint_t channels; 155 }; 156 157 aubio_mfft_t * new_aubio_mfft(uint_t winsize, uint_t channels){ 158 uint_t i; 159 aubio_mfft_t * fft = AUBIO_NEW(aubio_mfft_t); 160 fft->winsize = winsize; 161 fft->channels = channels; 162 fft->fft = new_aubio_fft(winsize); 163 fft->spec = AUBIO_ARRAY(fft_data_t*,channels); 164 for (i=0; i < channels; i++) 165 fft->spec[i] = AUBIO_ARRAY(fft_data_t,winsize); 166 return fft; 142 void aubio_fft_get_spectrum(fvec_t * compspec, cvec_t * spectrum) { 143 aubio_fft_get_phas(compspec, spectrum); 144 aubio_fft_get_norm(compspec, spectrum); 167 145 } 168 146 169 /* execute stft */ 170 void aubio_mfft_do (aubio_mfft_t * fft,fvec_t * in,cvec_t * fftgrain){ 171 uint_t i=0; 172 /* execute stft */ 173 for (i=0; i < fft->channels; i++) { 174 aubio_fft_do (fft->fft,in->data[i],fft->spec[i],fft->winsize); 175 /* put norm and phase into fftgrain */ 176 aubio_fft_getnorm(fftgrain->norm[i], fft->spec[i], fft->winsize); 177 aubio_fft_getphas(fftgrain->phas[i], fft->spec[i], fft->winsize); 178 } 147 void aubio_fft_get_realimag(cvec_t * spectrum, fvec_t * compspec) { 148 aubio_fft_get_imag(spectrum, compspec); 149 aubio_fft_get_real(spectrum, compspec); 179 150 } 180 151 181 /* execute inverse fourier transform */ 182 void aubio_mfft_rdo(aubio_mfft_t * fft,cvec_t * fftgrain, fvec_t * out){ 183 uint_t i=0; 184 for (i=0; i < fft->channels; i++) { 185 aubio_fft_getspectrum(fft->spec[i],fftgrain->norm[i],fftgrain->phas[i],fft->winsize); 186 aubio_fft_rdo(fft->fft,fft->spec[i],out->data[i],fft->winsize); 187 } 152 void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum) { 153 uint_t i, j; 154 for (i = 0; i < spectrum->channels; i++) { 155 spectrum->phas[i][0] = 0.; 156 for (j=1; j < spectrum->length - 1; j++) { 157 spectrum->phas[i][j] = atan2f(compspec->data[i][compspec->length-j], 158 compspec->data[i][j]); 159 } 160 spectrum->phas[i][spectrum->length-1] = 0.; 161 } 188 162 } 189 163 190 void del_aubio_mfft(aubio_mfft_t * fft) { 191 uint_t i; 192 for (i=0; i < fft->channels; i++) 193 AUBIO_FREE(fft->spec[i]); 194 AUBIO_FREE(fft->spec); 195 del_aubio_fft(fft->fft); 196 AUBIO_FREE(fft); 164 void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum) { 165 uint_t i, j = 0; 166 for (i = 0; i < spectrum->channels; i++) { 167 spectrum->norm[i][0] = compspec->data[i][0]; 168 for (j=1; j < spectrum->length - 1; j++) { 169 spectrum->norm[i][j] = SQRT(SQR(compspec->data[i][j]) 170 + SQR(compspec->data[i][compspec->length - j]) ); 171 } 172 spectrum->norm[i][spectrum->length-1] = compspec->data[i][compspec->length/2]; 173 } 197 174 } 175 176 void aubio_fft_get_imag(cvec_t * spectrum, fvec_t * compspec) { 177 uint_t i, j; 178 for (i = 0; i < compspec->channels; i++) { 179 for (j = 1; j < compspec->length / 2 + 1; j++) { 180 compspec->data[i][compspec->length - j] = 181 spectrum->norm[i][j]*SIN(spectrum->phas[i][j]); 182 } 183 } 184 } 185 186 void aubio_fft_get_real(cvec_t * spectrum, fvec_t * compspec) { 187 uint_t i, j; 188 for (i = 0; i < compspec->channels; i++) { 189 for (j = 0; j< compspec->length / 2 + 1; j++) { 190 compspec->data[i][j] = 191 spectrum->norm[i][j]*COS(spectrum->phas[i][j]); 192 } 193 } 194 } -
TabularUnified src/fft.h ¶
rc1656cf r7873363 1 1 /* 2 2 Copyright (C) 2003 Paul Brossier 3 3 4 5 6 7 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 8 9 10 11 12 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 13 14 15 16 17 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 18 18 */ 19 19 … … 67 67 68 68 \param size length of the FFT 69 \param channels number of channels 69 70 70 71 */ 71 aubio_fft_t * new_aubio_fft(uint_t size );72 aubio_fft_t * new_aubio_fft(uint_t size, uint_t channels); 72 73 /** delete FFT object 73 74 … … 76 77 */ 77 78 void del_aubio_fft(aubio_fft_t * s); 79 78 80 /** compute forward FFT 79 81 80 82 \param s fft object as returned by new_aubio_fft 81 \param datainput signal83 \param input input signal 82 84 \param spectrum output spectrum 83 \param size length of the input vector84 85 85 86 */ 86 void aubio_fft_do (const aubio_fft_t *s, const smpl_t * data, 87 fft_data_t * spectrum, const uint_t size); 87 void aubio_fft_do (aubio_fft_t *s, fvec_t * input, cvec_t * spectrum); 88 88 /** compute backward (inverse) FFT 89 89 90 90 \param s fft object as returned by new_aubio_fft 91 91 \param spectrum input spectrum 92 \param data output signal 93 \param size length of the input vector 92 \param output output signal 94 93 95 94 */ 96 void aubio_fft_rdo(const aubio_fft_t *s, const fft_data_t * spectrum, 97 smpl_t * data, const uint_t size); 98 /** compute norm vector from input spectrum 95 void aubio_fft_rdo (aubio_fft_t *s, cvec_t * spectrum, fvec_t * output); 99 96 100 \param norm magnitude vector output 101 \param spectrum spectral data input 102 \param size size of the vectors 97 /** compute forward FFT 98 99 \param s fft object as returned by new_aubio_fft 100 \param input real input signal 101 \param compspec complex output fft real/imag 103 102 104 103 */ 105 void aubio_fft_ getnorm(smpl_t * norm, fft_data_t * spectrum, uint_t size);106 /** compute phase vector from input spectrum107 108 \param phase phase vector output109 \param spectrum spectral data input110 \param size size of the vectors104 void aubio_fft_do_complex (aubio_fft_t *s, fvec_t * input, fvec_t * compspec); 105 /** compute backward (inverse) FFT from real/imag 106 107 \param s fft object as returned by new_aubio_fft 108 \param compspec real/imag input fft array 109 \param output real output array 111 110 112 111 */ 113 void aubio_fft_ getphas(smpl_t * phase, fft_data_t * spectrum, uint_t size);112 void aubio_fft_rdo_complex (aubio_fft_t *s, fvec_t * compspec, fvec_t * output); 114 113 115 /** FFT object (using cvec)114 /** convert real/imag spectrum to norm/phas spectrum 116 115 117 This object works similarly as aubio_fft_t, except the spectral data is118 stored in a cvec_t as two vectors, magnitude and phase.116 \param compspec real/imag input fft array 117 \param spectrum cvec norm/phas output array 119 118 120 119 */ 121 typedef struct _aubio_mfft_t aubio_mfft_t; 120 void aubio_fft_get_spectrum(fvec_t * compspec, cvec_t * spectrum); 121 /** convert real/imag spectrum to norm/phas spectrum 122 122 123 /** create new FFT computation object 124 125 \param winsize length of the FFT 126 \param channels number of channels 123 \param compspec real/imag input fft array 124 \param spectrum cvec norm/phas output array 127 125 128 126 */ 129 aubio_mfft_t * new_aubio_mfft(uint_t winsize, uint_t channels); 130 /** compute forward FFT 127 void aubio_fft_get_realimag(cvec_t * spectrum, fvec_t * compspec); 131 128 132 \param fft fft object as returned by new_aubio_mfft 133 \param in input signal 134 \param fftgrain output spectrum 129 /** compute phas spectrum from real/imag parts 130 131 \param compspec real/imag input fft array 132 \param spectrum cvec norm/phas output array 135 133 136 134 */ 137 void aubio_ mfft_do (aubio_mfft_t * fft,fvec_t * in,cvec_t * fftgrain);138 /** compute backward (inverse) FFT135 void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum); 136 /** compute imaginary part from the norm/phas cvec 139 137 140 \param fft fft object as returned by new_aubio_mfft 141 \param fftgrain input spectrum (cvec) 142 \param out output signal 138 \param spectrum norm/phas input array 139 \param compspec real/imag output fft array 143 140 144 141 */ 145 void aubio_mfft_rdo(aubio_mfft_t * fft,cvec_t * fftgrain, fvec_t * out); 146 /** delete FFT object 142 void aubio_fft_get_imag(cvec_t * spectrum, fvec_t * compspec); 147 143 148 \param fft fft object as returned by new_aubio_mfft 144 /** compute norm component from real/imag parts 145 146 \param compspec real/imag input fft array 147 \param spectrum cvec norm/phas output array 149 148 150 149 */ 151 void del_aubio_mfft(aubio_mfft_t * fft); 150 void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum); 151 /** compute real part from norm/phas components 152 152 153 \param spectrum norm/phas input array 154 \param compspec real/imag output fft array 155 156 */ 157 void aubio_fft_get_real(cvec_t * spectrum, fvec_t * compspec); 153 158 154 159 #ifdef __cplusplus … … 156 161 #endif 157 162 158 #endif 163 #endif // FFT_H_ -
TabularUnified src/filterbank.c ¶
rc1656cf r7873363 27 27 #include "stdio.h" 28 28 29 #define USE_EQUAL_GAIN 130 29 #define VERY_SMALL_NUMBER 2e-42 31 30 -
TabularUnified src/hist.c ¶
rc1656cf r7873363 1 1 /* 2 2 Copyright (C) 2003 Paul Brossier 3 3 4 5 6 7 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 8 9 10 11 12 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 13 14 15 16 17 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 */ 18 18 19 19 #include "aubio_priv.h" … … 28 28 29 29 struct _aubio_hist_t { 30 /*bug: move to a fvec */ 31 smpl_t ** hist; 32 uint_t nelems; 33 uint_t channels; 34 smpl_t * cent; 35 aubio_scale_t *scaler; 30 fvec_t * hist; 31 uint_t nelems; 32 uint_t channels; 33 fvec_t * cent; 34 aubio_scale_t *scaler; 36 35 }; 37 36 … … 40 39 */ 41 40 aubio_hist_t * new_aubio_hist (smpl_t ilow, smpl_t ihig, uint_t nelems, uint_t channels){ 42 aubio_hist_t * s = AUBIO_NEW(aubio_hist_t); 43 smpl_t step = (ihig-ilow)/(smpl_t)(nelems); 44 smpl_t accum = step; 45 uint_t i; 46 s->channels = channels; 47 s->nelems = nelems; 48 s->hist = AUBIO_ARRAY(smpl_t*, channels); 49 for (i=0; i< s->channels; i++) { 50 s->hist[i] = AUBIO_ARRAY(smpl_t, nelems); 51 } 52 s->cent = AUBIO_ARRAY(smpl_t, nelems); 53 54 /* use scale to map ilow/ihig -> 0/nelems */ 55 s->scaler = new_aubio_scale(ilow,ihig,0,nelems); 56 /* calculate centers now once */ 57 s->cent[0] = ilow + 0.5 * step; 58 for (i=1; i < s->nelems; i++, accum+=step ) 59 s->cent[i] = s->cent[0] + accum; 60 61 return s; 41 aubio_hist_t * s = AUBIO_NEW(aubio_hist_t); 42 smpl_t step = (ihig-ilow)/(smpl_t)(nelems); 43 smpl_t accum = step; 44 uint_t i; 45 s->channels = channels; 46 s->nelems = nelems; 47 s->hist = new_fvec(nelems, channels); 48 s->cent = new_fvec(nelems, 1); 49 50 /* use scale to map ilow/ihig -> 0/nelems */ 51 s->scaler = new_aubio_scale(ilow,ihig,0,nelems); 52 /* calculate centers now once */ 53 s->cent->data[0][0] = ilow + 0.5 * step; 54 for (i=1; i < s->nelems; i++, accum+=step ) 55 s->cent->data[0][i] = s->cent->data[0][0] + accum; 56 57 return s; 62 58 } 63 59 64 60 void del_aubio_hist(aubio_hist_t *s) { 65 uint_t i; 66 for (i=0; i< s->channels; i++) { 67 AUBIO_FREE(s->hist[i]); 68 } 69 AUBIO_FREE(s->hist); 70 AUBIO_FREE(s->cent); 71 del_aubio_scale(s->scaler); 72 AUBIO_FREE(s); 61 del_fvec(s->hist); 62 del_fvec(s->cent); 63 del_aubio_scale(s->scaler); 64 AUBIO_FREE(s); 73 65 } 74 66 … … 76 68 * do it 77 69 */ 78 void aubio_hist_do (aubio_hist_t *s, fvec_t *input) 79 { 80 uint_t i,j; 81 sint_t tmp = 0; 82 aubio_scale_do(s->scaler, input); 83 /* reset data */ 84 for (i=0; i < s->channels; i++) 85 for (j=0; j < s->nelems; j++) 86 s->hist[i][j] = 0; 87 /* run accum */ 88 for (i=0; i < input->channels; i++) 89 for (j=0; j < input->length; j++) 90 { 91 tmp = (sint_t)FLOOR(input->data[i][j]); 92 if ((tmp >= 0) && (tmp < (sint_t)s->nelems)) 93 s->hist[i][tmp] += 1; 94 } 70 void aubio_hist_do (aubio_hist_t *s, fvec_t *input) { 71 uint_t i,j; 72 sint_t tmp = 0; 73 aubio_scale_do(s->scaler, input); 74 /* reset data */ 75 for (i=0; i < s->channels; i++) 76 for (j=0; j < s->nelems; j++) 77 s->hist->data[i][j] = 0; 78 /* run accum */ 79 for (i=0; i < input->channels; i++) 80 for (j=0; j < input->length; j++) 81 { 82 tmp = (sint_t)FLOOR(input->data[i][j]); 83 if ((tmp >= 0) && (tmp < (sint_t)s->nelems)) 84 s->hist->data[i][tmp] += 1; 85 } 95 86 } 96 87 97 void aubio_hist_do_notnull (aubio_hist_t *s, fvec_t *input) 98 { 99 uint_t i,j; 100 sint_t tmp = 0; 101 aubio_scale_do(s->scaler, input); 102 /* reset data */ 103 for (i=0; i < s->channels; i++) 104 for (j=0; j < s->nelems; j++) 105 s->hist[i][j] = 0; 106 /* run accum */ 107 for (i=0; i < input->channels; i++) 108 for (j=0; j < input->length; j++) 109 { 110 if (input->data[i][j] != 0) { 111 tmp = (sint_t)FLOOR(input->data[i][j]); 112 if ((tmp >= 0) && (tmp < (sint_t)s->nelems)) 113 s->hist[i][tmp] += 1; 114 } 115 } 88 void aubio_hist_do_notnull (aubio_hist_t *s, fvec_t *input) { 89 uint_t i,j; 90 sint_t tmp = 0; 91 aubio_scale_do(s->scaler, input); 92 /* reset data */ 93 for (i=0; i < s->channels; i++) 94 for (j=0; j < s->nelems; j++) 95 s->hist->data[i][j] = 0; 96 /* run accum */ 97 for (i=0; i < input->channels; i++) 98 for (j=0; j < input->length; j++) { 99 if (input->data[i][j] != 0) { 100 tmp = (sint_t)FLOOR(input->data[i][j]); 101 if ((tmp >= 0) && (tmp < (sint_t)s->nelems)) 102 s->hist->data[i][tmp] += 1; 103 } 104 } 116 105 } 117 106 118 107 119 void aubio_hist_dyn_notnull (aubio_hist_t *s, fvec_t *input) 120 { 121 uint_t i,j; 122 sint_t tmp = 0; 123 smpl_t ilow = vec_min(input); 124 smpl_t ihig = vec_max(input); 125 smpl_t step = (ihig-ilow)/(smpl_t)(s->nelems); 126 127 /* readapt */ 128 aubio_scale_set(s->scaler, ilow, ihig, 0, s->nelems); 108 void aubio_hist_dyn_notnull (aubio_hist_t *s, fvec_t *input) { 109 uint_t i,j; 110 sint_t tmp = 0; 111 smpl_t ilow = vec_min(input); 112 smpl_t ihig = vec_max(input); 113 smpl_t step = (ihig-ilow)/(smpl_t)(s->nelems); 129 114 130 /* recalculate centers */ 131 s->cent[0] = ilow + 0.5f * step; 132 for (i=1; i < s->nelems; i++) 133 s->cent[i] = s->cent[0] + i * step; 115 /* readapt */ 116 aubio_scale_set(s->scaler, ilow, ihig, 0, s->nelems); 134 117 135 /* scale */ 136 aubio_scale_do(s->scaler, input); 118 /* recalculate centers */ 119 s->cent->data[0][0] = ilow + 0.5f * step; 120 for (i=1; i < s->nelems; i++) 121 s->cent->data[0][i] = s->cent->data[0][0] + i * step; 137 122 138 /* reset data */ 139 for (i=0; i < s->channels; i++) 140 for (j=0; j < s->nelems; j++) 141 s->hist[i][j] = 0; 142 /* run accum */ 143 for (i=0; i < input->channels; i++) 144 for (j=0; j < input->length; j++) 145 { 146 if (input->data[i][j] != 0) { 147 tmp = (sint_t)FLOOR(input->data[i][j]); 148 if ((tmp >= 0) && (tmp < (sint_t)s->nelems)) 149 s->hist[i][tmp] += 1; 150 } 151 } 123 /* scale */ 124 aubio_scale_do(s->scaler, input); 125 126 /* reset data */ 127 for (i=0; i < s->channels; i++) 128 for (j=0; j < s->nelems; j++) 129 s->hist->data[i][j] = 0; 130 /* run accum */ 131 for (i=0; i < input->channels; i++) 132 for (j=0; j < input->length; j++) { 133 if (input->data[i][j] != 0) { 134 tmp = (sint_t)FLOOR(input->data[i][j]); 135 if ((tmp >= 0) && (tmp < (sint_t)s->nelems)) 136 s->hist->data[i][tmp] += 1; 137 } 138 } 152 139 } 153 140 154 void aubio_hist_weigth (aubio_hist_t *s) 155 { 156 uint_t i,j; 157 for (i=0; i < s->channels; i++) 158 for (j=0; j < s->nelems; j++) { 159 s->hist[i][j] *= s->cent[j]; 160 } 141 void aubio_hist_weight (aubio_hist_t *s) { 142 uint_t i,j; 143 for (i=0; i < s->channels; i++) 144 for (j=0; j < s->nelems; j++) { 145 s->hist->data[i][j] *= s->cent->data[0][j]; 146 } 161 147 } 162 148 163 smpl_t aubio_hist_mean (aubio_hist_t *s) 164 { 165 uint_t i,j; 166 smpl_t tmp = 0.0f; 167 for (i=0; i < s->channels; i++) 168 for (j=0; j < s->nelems; j++) 169 tmp += s->hist[i][j]; 170 return tmp/(smpl_t)(s->nelems); 149 smpl_t aubio_hist_mean (aubio_hist_t *s) { 150 uint_t i,j; 151 smpl_t tmp = 0.0f; 152 for (i=0; i < s->channels; i++) 153 for (j=0; j < s->nelems; j++) 154 tmp += s->hist->data[i][j]; 155 return tmp/(smpl_t)(s->nelems); 171 156 } 172 157 -
TabularUnified src/hist.h ¶
rc1656cf r7873363 1 1 /* 2 2 Copyright (C) 2003 Paul Brossier 3 3 4 5 6 7 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 8 9 10 11 12 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 13 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 */ 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 18 */ 18 19 19 20 /** @file … … 34 35 typedef struct _aubio_hist_t aubio_hist_t; 35 36 36 /** histogram creation 37 /** histogram creation 37 38 * \param flow minimum input 38 39 * \param fhig maximum input 39 40 * \param nelems number of histogram columns 40 * \param channels number of channels 41 * \param channels number of channels 41 42 */ 42 43 aubio_hist_t * new_aubio_hist(smpl_t flow, smpl_t fhig, uint_t nelems, uint_t channels); … … 48 49 void aubio_hist_do_notnull(aubio_hist_t *s, fvec_t * input); 49 50 /** compute the mean of the histogram */ 50 smpl_t aubio_hist_mean(aubio_hist_t *s); 51 smpl_t aubio_hist_mean(aubio_hist_t *s); 51 52 /** weight the histogram */ 52 void aubio_hist_weig th(aubio_hist_t *s);53 void aubio_hist_weight(aubio_hist_t *s); 53 54 /** compute dynamic histogram for non-null elements */ 54 55 void aubio_hist_dyn_notnull (aubio_hist_t *s, fvec_t *input); -
TabularUnified src/mathutils.c ¶
rc1656cf r7873363 227 227 /* pre part of the buffer does not exist */ 228 228 } else { 229 for (k=0;k<length-pos+post +1;k++)229 for (k=0;k<length-pos+post;k++) 230 230 medar[k] = vec->data[0][k+pos-post]; 231 for (k=length-pos+post +1;k<win_length;k++)231 for (k=length-pos+post;k<win_length;k++) 232 232 medar[k] = 0.; /* 0-padding at the end */ 233 233 } -
TabularUnified src/mfcc.c ¶
rc1656cf r7873363 40 40 aubio_filterbank_t * fb; /** filter bank */ 41 41 fvec_t * in_dct; /** input buffer for dct * [fb->n_filters] */ 42 aubio_ mfft_t * fft_dct; /** fft object for dct */42 aubio_fft_t * fft_dct; /** fft object for dct */ 43 43 cvec_t * fftgrain_dct; /** output buffer for dct */ 44 44 }; … … 65 65 66 66 /** allocating space for fft object (used for dct) */ 67 mfcc->fft_dct=new_aubio_ mfft(n_filters, 1);67 mfcc->fft_dct=new_aubio_fft(n_filters, 1); 68 68 69 69 /** allocating buffers */ … … 78 78 /** deleting filterbank */ 79 79 del_aubio_filterbank(mf->fb); 80 /** deleting mfft object */81 del_aubio_ mfft(mf->fft_dct);80 /** deleting fft object */ 81 del_aubio_fft(mf->fft_dct); 82 82 /** deleting buffers */ 83 83 del_fvec(mf->in_dct); … … 113 113 uint_t i; 114 114 //compute mag spectrum 115 aubio_ mfft_do (mf->fft_dct, in, mf->fftgrain_dct);115 aubio_fft_do (mf->fft_dct, in, mf->fftgrain_dct); 116 116 //extract real part of fft grain 117 117 for(i=0; i<mf->n_coefs ;i++){ -
TabularUnified src/onsetdetection.c ¶
rc1656cf r7873363 31 31 /** Pointer to aubio_onsetdetection_<type> function */ 32 32 void (*funcpointer)(aubio_onsetdetection_t *o, 33 cvec_t * fftgrain, fvec_t * onset);33 cvec_t * fftgrain, fvec_t * onset); 34 34 smpl_t threshold; /**< minimum norm threshold for phase and specdiff */ 35 35 fvec_t *oldmag; /**< previous norm vector */ … … 44 44 /* Energy based onset detection function */ 45 45 void aubio_onsetdetection_energy (aubio_onsetdetection_t *o UNUSED, 46 47 48 49 50 51 52 53 46 cvec_t * fftgrain, fvec_t * onset) { 47 uint_t i,j; 48 for (i=0;i<fftgrain->channels;i++) { 49 onset->data[i][0] = 0.; 50 for (j=0;j<fftgrain->length;j++) { 51 onset->data[i][0] += SQR(fftgrain->norm[i][j]); 52 } 53 } 54 54 } 55 55 … … 57 57 void aubio_onsetdetection_hfc(aubio_onsetdetection_t *o UNUSED, 58 58 cvec_t * fftgrain, fvec_t * onset){ 59 60 61 62 63 64 65 59 uint_t i,j; 60 for (i=0;i<fftgrain->channels;i++) { 61 onset->data[i][0] = 0.; 62 for (j=0;j<fftgrain->length;j++) { 63 onset->data[i][0] += (j+1)*fftgrain->norm[i][j]; 64 } 65 } 66 66 } 67 67 … … 69 69 /* Complex Domain Method onset detection function */ 70 70 void aubio_onsetdetection_complex (aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset) { 71 72 73 for (i=0;i<fftgrain->channels; i++){74 75 for (j=0;j<nbins; j++){76 o->dev1->data[i][j]= aubio_unwrap2pi(77 78 79 71 uint_t i, j; 72 uint_t nbins = fftgrain->length; 73 for (i=0;i<fftgrain->channels; i++) { 74 onset->data[i][0] = 0.; 75 for (j=0;j<nbins; j++) { 76 o->dev1->data[i][j] = aubio_unwrap2pi( 77 fftgrain->phas[i][j] 78 -2.0*o->theta1->data[i][j]+ 79 o->theta2->data[i][j]); 80 80 #ifdef HAVE_COMPLEX_H 81 82 83 onset->data[i][0]+= //(fftgrain->norm[i][j]);84 85 86 81 o->meas[j] = fftgrain->norm[i][j]*CEXPC(I*o->dev1->data[i][j]); 82 /* sum on all bins */ 83 onset->data[i][0] += //(fftgrain->norm[i][j]); 84 SQRT(SQR( REAL(o->oldmag->data[i][j]-o->meas[j]) ) 85 + SQR( IMAG(o->oldmag->data[i][j]-o->meas[j]) ) 86 ); 87 87 #else 88 89 90 91 onset->data[i][0]+= //(fftgrain->norm[i][j]);92 93 94 88 o->meas[j] = (fftgrain->norm[i][j])*COS(o->dev1->data[i][j]); 89 o->meas[(nbins-1)*2-j] = (fftgrain->norm[i][j])*SIN(o->dev1->data[i][j]); 90 /* sum on all bins */ 91 onset->data[i][0] += //(fftgrain->norm[i][j]); 92 SQRT(SQR( (o->oldmag->data[i][j]-o->meas[j]) ) 93 + SQR( (-o->meas[(nbins-1)*2-j]) ) 94 ); 95 95 #endif 96 97 98 99 100 101 102 96 /* swap old phase data (need to remember 2 frames behind)*/ 97 o->theta2->data[i][j] = o->theta1->data[i][j]; 98 o->theta1->data[i][j] = fftgrain->phas[i][j]; 99 /* swap old magnitude data (1 frame is enough) */ 100 o->oldmag->data[i][j] = fftgrain->norm[i][j]; 101 } 102 } 103 103 } 104 104 … … 106 106 /* Phase Based Method onset detection function */ 107 107 void aubio_onsetdetection_phase(aubio_onsetdetection_t *o, 108 109 110 111 for (i=0;i<fftgrain->channels; i++){112 113 114 for ( j=0;j<nbins; j++ ){115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 aubio_hist_weigth(o->histog);132 133 onset->data[i][0] = aubio_hist_mean(o->histog); 134 135 108 cvec_t * fftgrain, fvec_t * onset){ 109 uint_t i, j; 110 uint_t nbins = fftgrain->length; 111 for (i=0;i<fftgrain->channels; i++) { 112 onset->data[i][0] = 0.0f; 113 o->dev1->data[i][0]=0.; 114 for ( j=0;j<nbins; j++ ) { 115 o->dev1->data[i][j] = 116 aubio_unwrap2pi( 117 fftgrain->phas[i][j] 118 -2.0*o->theta1->data[i][j] 119 +o->theta2->data[i][j]); 120 if ( o->threshold < fftgrain->norm[i][j] ) 121 o->dev1->data[i][j] = ABS(o->dev1->data[i][j]); 122 else 123 o->dev1->data[i][j] = 0.0f; 124 /* keep a track of the past frames */ 125 o->theta2->data[i][j] = o->theta1->data[i][j]; 126 o->theta1->data[i][j] = fftgrain->phas[i][j]; 127 } 128 /* apply o->histogram */ 129 aubio_hist_dyn_notnull(o->histog,o->dev1); 130 /* weight it */ 131 aubio_hist_weight(o->histog); 132 /* its mean is the result */ 133 onset->data[i][0] = aubio_hist_mean(o->histog); 134 //onset->data[i][0] = vec_mean(o->dev1); 135 } 136 136 } 137 137 138 138 /* Spectral difference method onset detection function */ 139 139 void aubio_onsetdetection_specdiff(aubio_onsetdetection_t *o, 140 141 142 143 for (i=0;i<fftgrain->channels; i++){144 145 for (j=0;j<nbins; j++){146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 aubio_hist_weigth(o->histog);161 162 onset->data[i][0] = aubio_hist_mean(o->histog); 163 164 140 cvec_t * fftgrain, fvec_t * onset){ 141 uint_t i, j; 142 uint_t nbins = fftgrain->length; 143 for (i=0;i<fftgrain->channels; i++) { 144 onset->data[i][0] = 0.0f; 145 for (j=0;j<nbins; j++) { 146 o->dev1->data[i][j] = SQRT( 147 ABS(SQR( fftgrain->norm[i][j]) 148 - SQR(o->oldmag->data[i][j]))); 149 if (o->threshold < fftgrain->norm[i][j] ) 150 o->dev1->data[i][j] = ABS(o->dev1->data[i][j]); 151 else 152 o->dev1->data[i][j] = 0.0f; 153 o->oldmag->data[i][j] = fftgrain->norm[i][j]; 154 } 155 156 /* apply o->histogram (act somewhat as a low pass on the 157 * overall function)*/ 158 aubio_hist_dyn_notnull(o->histog,o->dev1); 159 /* weight it */ 160 aubio_hist_weight(o->histog); 161 /* its mean is the result */ 162 onset->data[i][0] = aubio_hist_mean(o->histog); 163 164 } 165 165 } 166 166 … … 169 169 * negative (1.+) and infinite values (+1.e-10) */ 170 170 void aubio_onsetdetection_kl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset){ 171 172 173 174 175 176 177 178 179 180 171 uint_t i,j; 172 for (i=0;i<fftgrain->channels;i++) { 173 onset->data[i][0] = 0.; 174 for (j=0;j<fftgrain->length;j++) { 175 onset->data[i][0] += fftgrain->norm[i][j] 176 *LOG(1.+fftgrain->norm[i][j]/(o->oldmag->data[i][j]+1.e-10)); 177 o->oldmag->data[i][j] = fftgrain->norm[i][j]; 178 } 179 if (isnan(onset->data[i][0])) onset->data[i][0] = 0.; 180 } 181 181 } 182 182 … … 185 185 * negative (1.+) and infinite values (+1.e-10) */ 186 186 void aubio_onsetdetection_mkl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset){ 187 uint_t i,j; 188 for (i=0;i<fftgrain->channels;i++) { 189 onset->data[i][0] = 0.; 190 for (j=0;j<fftgrain->length;j++) { 191 onset->data[i][0] += LOG(1.+fftgrain->norm[i][j]/(o->oldmag->data[i][j]+1.e-10)); 192 o->oldmag->data[i][j] = fftgrain->norm[i][j]; 193 } 194 if (isnan(onset->data[i][0])) onset->data[i][0] = 0.; 195 } 187 uint_t i,j; 188 for (i=0;i<fftgrain->channels;i++) { 189 onset->data[i][0] = 0.; 190 for (j=0;j<fftgrain->length;j++) { 191 onset->data[i][0] += LOG(1.+fftgrain->norm[i][j]/(o->oldmag->data[i][j]+1.e-10)); 192 o->oldmag->data[i][j] = fftgrain->norm[i][j]; 193 } 194 if (isnan(onset->data[i][0])) onset->data[i][0] = 0.; 195 } 196 } 197 198 /* Spectral flux */ 199 void aubio_onsetdetection_specflux(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset){ 200 uint_t i, j; 201 for (i=0;i<fftgrain->channels;i++) { 202 onset->data[i][0] = 0.; 203 for (j=0;j<fftgrain->length;j++) { 204 if (fftgrain->norm[i][j] > o->oldmag->data[i][j]) 205 onset->data[i][0] += fftgrain->norm[i][j] - o->oldmag->data[i][j]; 206 o->oldmag->data[i][j] = fftgrain->norm[i][j]; 207 } 208 } 196 209 } 197 210 … … 199 212 void 200 213 aubio_onsetdetection(aubio_onsetdetection_t *o, cvec_t * fftgrain, 201 202 214 fvec_t * onset) { 215 o->funcpointer(o,fftgrain,onset); 203 216 } 204 217 … … 208 221 aubio_onsetdetection_t * 209 222 new_aubio_onsetdetection (aubio_onsetdetection_type type, 210 211 212 223 uint_t size, uint_t channels){ 224 aubio_onsetdetection_t * o = AUBIO_NEW(aubio_onsetdetection_t); 225 uint_t rsize = size/2+1; 213 226 uint_t i; 214 switch(type) { 215 /* for both energy and hfc, only fftgrain->norm is required */ 216 case aubio_onset_energy: 217 break; 218 case aubio_onset_hfc: 219 break; 220 /* the other approaches will need some more memory spaces */ 221 case aubio_onset_complex: 222 o->oldmag = new_fvec(rsize,channels); 223 /** bug: must be complex array */ 224 o->meas = AUBIO_ARRAY(fft_data_t,size+1); 225 for (i=0; i<size+1; i++) o->meas[i] = 0; 226 o->dev1 = new_fvec(rsize,channels); 227 o->theta1 = new_fvec(rsize,channels); 228 o->theta2 = new_fvec(rsize,channels); 229 break; 230 case aubio_onset_phase: 231 o->dev1 = new_fvec(rsize,channels); 232 o->theta1 = new_fvec(rsize,channels); 233 o->theta2 = new_fvec(rsize,channels); 234 o->histog = new_aubio_hist(0.0f, PI, 10, channels); 235 o->threshold = 0.1; 236 break; 237 case aubio_onset_specdiff: 238 o->oldmag = new_fvec(rsize,channels); 239 o->dev1 = new_fvec(rsize,channels); 240 o->histog = new_aubio_hist(0.0f, PI, 10, channels); 241 o->threshold = 0.1; 242 break; 243 case aubio_onset_kl: 244 o->oldmag = new_fvec(rsize,channels); 245 break; 246 case aubio_onset_mkl: 247 o->oldmag = new_fvec(rsize,channels); 248 break; 249 default: 250 break; 251 } 252 253 /* this switch could be in its own function to change between 254 * detections on the fly. this would need getting rid of the switch 255 * above and always allocate all the structure */ 256 257 switch(type) { 258 case aubio_onset_energy: 259 o->funcpointer = aubio_onsetdetection_energy; 260 break; 261 case aubio_onset_hfc: 262 o->funcpointer = aubio_onsetdetection_hfc; 263 break; 264 case aubio_onset_complex: 265 o->funcpointer = aubio_onsetdetection_complex; 266 break; 267 case aubio_onset_phase: 268 o->funcpointer = aubio_onsetdetection_phase; 269 break; 270 case aubio_onset_specdiff: 271 o->funcpointer = aubio_onsetdetection_specdiff; 272 break; 273 case aubio_onset_kl: 274 o->funcpointer = aubio_onsetdetection_kl; 275 break; 276 case aubio_onset_mkl: 277 o->funcpointer = aubio_onsetdetection_mkl; 278 break; 279 default: 280 break; 281 } 282 o->type = type; 283 return o; 284 } 285 286 void aubio_onsetdetection_free (aubio_onsetdetection_t *o){ 287 del_aubio_onsetdetection(o); 227 switch(type) { 228 /* for both energy and hfc, only fftgrain->norm is required */ 229 case aubio_onset_energy: 230 break; 231 case aubio_onset_hfc: 232 break; 233 /* the other approaches will need some more memory spaces */ 234 case aubio_onset_complex: 235 o->oldmag = new_fvec(rsize,channels); 236 /** bug: must be complex array */ 237 o->meas = AUBIO_ARRAY(fft_data_t,size+1); 238 for (i=0; i<size+1; i++) o->meas[i] = 0; 239 o->dev1 = new_fvec(rsize,channels); 240 o->theta1 = new_fvec(rsize,channels); 241 o->theta2 = new_fvec(rsize,channels); 242 break; 243 case aubio_onset_phase: 244 o->dev1 = new_fvec(rsize,channels); 245 o->theta1 = new_fvec(rsize,channels); 246 o->theta2 = new_fvec(rsize,channels); 247 o->histog = new_aubio_hist(0.0f, PI, 10, channels); 248 o->threshold = 0.1; 249 break; 250 case aubio_onset_specdiff: 251 o->oldmag = new_fvec(rsize,channels); 252 o->dev1 = new_fvec(rsize,channels); 253 o->histog = new_aubio_hist(0.0f, PI, 10, channels); 254 o->threshold = 0.1; 255 break; 256 case aubio_onset_kl: 257 case aubio_onset_mkl: 258 case aubio_onset_specflux: 259 o->oldmag = new_fvec(rsize,channels); 260 break; 261 default: 262 break; 263 } 264 265 /* this switch could be in its own function to change between 266 * detections on the fly. this would need getting rid of the switch 267 * above and always allocate all the structure */ 268 269 switch(type) { 270 case aubio_onset_energy: 271 o->funcpointer = aubio_onsetdetection_energy; 272 break; 273 case aubio_onset_hfc: 274 o->funcpointer = aubio_onsetdetection_hfc; 275 break; 276 case aubio_onset_complex: 277 o->funcpointer = aubio_onsetdetection_complex; 278 break; 279 case aubio_onset_phase: 280 o->funcpointer = aubio_onsetdetection_phase; 281 break; 282 case aubio_onset_specdiff: 283 o->funcpointer = aubio_onsetdetection_specdiff; 284 break; 285 case aubio_onset_kl: 286 o->funcpointer = aubio_onsetdetection_kl; 287 break; 288 case aubio_onset_mkl: 289 o->funcpointer = aubio_onsetdetection_mkl; 290 break; 291 case aubio_onset_specflux: 292 o->funcpointer = aubio_onsetdetection_specflux; 293 break; 294 default: 295 break; 296 } 297 o->type = type; 298 return o; 288 299 } 289 300 290 301 void del_aubio_onsetdetection (aubio_onsetdetection_t *o){ 291 292 switch(o->type) { 293 /* for both energy and hfc, only fftgrain->norm is required */ 294 case aubio_onset_energy: 295 break; 296 case aubio_onset_hfc: 297 break; 298 /* the other approaches will need some more memory spaces */ 299 case aubio_onset_complex: 300 AUBIO_FREE(o->meas); 301 del_fvec(o->oldmag); 302 del_fvec(o->dev1); 303 del_fvec(o->theta1); 304 del_fvec(o->theta2); 305 break; 306 case aubio_onset_phase: 307 del_fvec(o->dev1); 308 del_fvec(o->theta1); 309 del_fvec(o->theta2); 310 del_aubio_hist(o->histog); 311 break; 312 case aubio_onset_specdiff: 313 del_fvec(o->oldmag); 314 del_fvec(o->dev1); 315 del_aubio_hist(o->histog); 316 break; 317 case aubio_onset_kl: 318 del_fvec(o->oldmag); 319 break; 320 case aubio_onset_mkl: 321 del_fvec(o->oldmag); 322 break; 323 default: 324 break; 325 } 326 AUBIO_FREE(o); 327 328 } 302 switch(o->type) { 303 /* for both energy and hfc, only fftgrain->norm is required */ 304 case aubio_onset_energy: 305 break; 306 case aubio_onset_hfc: 307 break; 308 /* the other approaches will need some more memory spaces */ 309 case aubio_onset_complex: 310 AUBIO_FREE(o->meas); 311 del_fvec(o->oldmag); 312 del_fvec(o->dev1); 313 del_fvec(o->theta1); 314 del_fvec(o->theta2); 315 break; 316 case aubio_onset_phase: 317 del_fvec(o->dev1); 318 del_fvec(o->theta1); 319 del_fvec(o->theta2); 320 del_aubio_hist(o->histog); 321 break; 322 case aubio_onset_specdiff: 323 del_fvec(o->oldmag); 324 del_fvec(o->dev1); 325 del_aubio_hist(o->histog); 326 break; 327 case aubio_onset_kl: 328 del_fvec(o->oldmag); 329 break; 330 case aubio_onset_mkl: 331 del_fvec(o->oldmag); 332 break; 333 default: 334 break; 335 } 336 AUBIO_FREE(o); 337 } -
TabularUnified src/onsetdetection.h ¶
rc1656cf r7873363 47 47 aubio_onset_phase, /**< phase fast */ 48 48 aubio_onset_kl, /**< Kullback Liebler */ 49 aubio_onset_mkl /**< modified Kullback Liebler */ 49 aubio_onset_mkl, /**< modified Kullback Liebler */ 50 aubio_onset_specflux, /**< spectral flux */ 50 51 } aubio_onsetdetection_type; 51 52 … … 137 138 */ 138 139 void aubio_onsetdetection_mkl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset); 140 /** Spectral Flux 141 142 Simon Dixon, Onset Detection Revisited, in ``Proceedings of the 9th 143 International Conference on Digital Audio Effects'' (DAFx-06), Montreal, 144 Canada, 2006. 145 146 \param o onset detection object as returned by new_aubio_onsetdetection() 147 \param fftgrain input spectral frame 148 \param onset output onset detection function 149 150 */ 151 void aubio_onsetdetection_specflux(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset); 139 152 /** execute onset detection function on a spectral frame 140 153 … … 161 174 */ 162 175 void del_aubio_onsetdetection(aubio_onsetdetection_t *o); 163 /** deletion of an onset detection object (obsolete)164 165 \param o onset detection object as returned by new_aubio_onsetdetection()166 167 */168 void aubio_onsetdetection_free(aubio_onsetdetection_t *o);169 170 176 171 177 #ifdef __cplusplus -
TabularUnified src/phasevoc.c ¶
rc1656cf r7873363 19 19 20 20 #include "aubio_priv.h" 21 #include "sample.h" 21 #include "fvec.h" 22 #include "cvec.h" 22 23 #include "fft.h" 23 24 #include "mathutils.h" … … 26 27 /** phasevocoder internal object */ 27 28 struct _aubio_pvoc_t { 28 /** grain length */ 29 uint_t win_s; 30 /** overlap step */ 31 uint_t hop_s; 32 /** number of channels */ 33 uint_t channels; 34 /** spectral data */ 35 aubio_mfft_t * fft; 36 /**cur output grain [win_s] */ 37 fvec_t * synth; 38 /**last input frame [win_s-hop_s] */ 39 fvec_t * synthold; 40 /**current input grain [win_s] */ 41 fvec_t * data; 42 /**last input frame [win_s-hop_s] */ 43 fvec_t * dataold; 44 /** grain window [win_s] */ 45 float * w; 29 uint_t win_s; /** grain length */ 30 uint_t hop_s; /** overlap step */ 31 uint_t channels; /** number of channels */ 32 aubio_fft_t * fft; /** fft object */ 33 fvec_t * synth; /** cur output grain [win_s] */ 34 fvec_t * synthold; /** last input frame [win_s-hop_s] */ 35 fvec_t * data; /** current input grain [win_s] */ 36 fvec_t * dataold; /** last input frame [win_s-hop_s] */ 37 smpl_t * w; /** grain window [win_s] */ 46 38 }; 47 39 48 40 49 41 /** returns data and dataold slided by hop_s */ 50 static void aubio_pvoc_swapbuffers( 51 smpl_t * data, 52 smpl_t * dataold, 53 const smpl_t * datanew, 54 uint_t win_s, uint_t hop_s); 42 static void aubio_pvoc_swapbuffers(smpl_t * data, smpl_t * dataold, const 43 smpl_t * datanew, uint_t win_s, uint_t hop_s); 44 55 45 /** do additive synthesis from 'old' and 'cur' */ 56 static void aubio_pvoc_addsynth( 57 const smpl_t * synth, 58 smpl_t * synthold, 59 smpl_t * synthnew, 60 uint_t win_s, uint_t hop_s); 61 46 static void aubio_pvoc_addsynth(const smpl_t * synth, smpl_t * synthold, 47 smpl_t * synthnew, uint_t win_s, uint_t hop_s); 62 48 63 49 void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t * datanew, cvec_t *fftgrain) { 64 65 66 67 68 69 70 71 72 73 74 75 aubio_mfft_do (pv->fft,pv->data,fftgrain);50 uint_t i,j; 51 for (i=0; i<pv->channels; i++) { 52 /* slide */ 53 aubio_pvoc_swapbuffers(pv->data->data[i],pv->dataold->data[i], 54 datanew->data[i],pv->win_s,pv->hop_s); 55 /* windowing */ 56 for (j=0; j<pv->win_s; j++) pv->data->data[i][j] *= pv->w[j]; 57 } 58 /* shift */ 59 vec_shift(pv->data); 60 /* calculate fft */ 61 aubio_fft_do (pv->fft,pv->data,fftgrain); 76 62 } 77 63 78 64 void aubio_pvoc_rdo(aubio_pvoc_t *pv,cvec_t * fftgrain, fvec_t * synthnew) { 79 uint_t i,j; 80 /* calculate rfft */ 81 aubio_mfft_rdo(pv->fft,fftgrain,pv->synth); 82 /* unshift */ 83 vec_shift(pv->synth); 84 for (i=0; i<pv->channels; i++) { 85 for (j=0; j<pv->win_s; j++) pv->synth->data[i][j] *= pv->w[j]; 86 aubio_pvoc_addsynth(pv->synth->data[i],pv->synthold->data[i], 87 synthnew->data[i],pv->win_s,pv->hop_s); 88 } 65 uint_t i; 66 /* calculate rfft */ 67 aubio_fft_rdo(pv->fft,fftgrain,pv->synth); 68 /* unshift */ 69 vec_shift(pv->synth); 70 for (i=0; i<pv->channels; i++) { 71 aubio_pvoc_addsynth(pv->synth->data[i],pv->synthold->data[i], 72 synthnew->data[i],pv->win_s,pv->hop_s); 73 } 89 74 } 90 75 91 76 aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s, uint_t channels) { 92 77 aubio_pvoc_t * pv = AUBIO_NEW(aubio_pvoc_t); 93 78 94 95 96 97 98 79 if (win_s < 2*hop_s) { 80 AUBIO_ERR("Hop size bigger than half the window size!\n"); 81 AUBIO_ERR("Resetting hop size to half the window size.\n"); 82 hop_s = win_s / 2; 83 } 99 84 100 if (hop_s < 1) { 101 AUBIO_ERR("Hop size is smaller than 1!\n"); 102 AUBIO_ERR("Resetting hop size to half the window size.\n"); 103 hop_s = win_s / 2; 104 } 105 106 pv->fft = new_aubio_mfft(win_s,channels); 85 if (hop_s < 1) { 86 AUBIO_ERR("Hop size is smaller than 1!\n"); 87 AUBIO_ERR("Resetting hop size to half the window size.\n"); 88 hop_s = win_s / 2; 89 } 107 90 108 /* remember old */ 109 pv->data = new_fvec (win_s, channels); 110 pv->synth = new_fvec (win_s, channels); 91 pv->fft = new_aubio_fft(win_s,channels); 111 92 112 /* new input output */ 113 pv->dataold = new_fvec (win_s-hop_s, channels); 114 pv->synthold = new_fvec (win_s-hop_s, channels); 115 pv->w = AUBIO_ARRAY(smpl_t,win_s); 116 aubio_window(pv->w,win_s,aubio_win_hanningz); 93 /* remember old */ 94 pv->data = new_fvec (win_s, channels); 95 pv->synth = new_fvec (win_s, channels); 117 96 118 pv->channels = channels; 119 pv->hop_s = hop_s; 120 pv->win_s = win_s; 97 /* new input output */ 98 pv->dataold = new_fvec (win_s-hop_s, channels); 99 pv->synthold = new_fvec (win_s-hop_s, channels); 100 pv->w = AUBIO_ARRAY(smpl_t,win_s); 101 aubio_window(pv->w,win_s,aubio_win_hanningz); 121 102 122 return pv; 103 pv->channels = channels; 104 pv->hop_s = hop_s; 105 pv->win_s = win_s; 106 107 return pv; 123 108 } 124 109 125 110 void del_aubio_pvoc(aubio_pvoc_t *pv) { 126 127 128 129 130 del_aubio_mfft(pv->fft);131 132 111 del_fvec(pv->data); 112 del_fvec(pv->synth); 113 del_fvec(pv->dataold); 114 del_fvec(pv->synthold); 115 del_aubio_fft(pv->fft); 116 AUBIO_FREE(pv->w); 117 AUBIO_FREE(pv); 133 118 } 134 119 135 120 static void aubio_pvoc_swapbuffers(smpl_t * data, smpl_t * dataold, 136 121 const smpl_t * datanew, uint_t win_s, uint_t hop_s) 137 122 { 138 139 140 141 142 143 144 123 uint_t i; 124 for (i=0;i<win_s-hop_s;i++) 125 data[i] = dataold[i]; 126 for (i=0;i<hop_s;i++) 127 data[win_s-hop_s+i] = datanew[i]; 128 for (i=0;i<win_s-hop_s;i++) 129 dataold[i] = data[i+hop_s]; 145 130 } 146 131 … … 148 133 smpl_t * synthnew, uint_t win_s, uint_t hop_s) 149 134 { 150 151 152 153 for (i=0;i<hop_s;i++) 154 155 156 for (i=0;i<win_s-2*hop_s;i++) 157 158 159 for (i=win_s-hop_s;i<win_s;i++) 160 161 162 for (i=0;i<win_s-hop_s;i++) 163 135 uint_t i; 136 smpl_t scale = 2*hop_s/(win_s+.0); 137 /* add new synth to old one and put result in synthnew */ 138 for (i=0;i<hop_s;i++) 139 synthnew[i] = synthold[i]+synth[i]*scale; 140 /* shift synthold */ 141 for (i=0;i<win_s-2*hop_s;i++) 142 synthold[i] = synthold[i+hop_s]; 143 /* erase last frame in synthold */ 144 for (i=win_s-hop_s;i<win_s;i++) 145 synthold[i-hop_s]=0.; 146 /* additive synth */ 147 for (i=0;i<win_s-hop_s;i++) 148 synthold[i] += synth[i+hop_s]*scale; 164 149 } 165 150 -
TabularUnified src/pitchdetection.c ¶
rc1656cf r7873363 15 15 along with this program; if not, write to the Free Software 16 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 */17 */ 18 18 19 19 #include "aubio_priv.h" … … 29 29 #include "pitchdetection.h" 30 30 31 typedef smpl_t (*aubio_pitchdetection_func_t)(aubio_pitchdetection_t *p, 32 fvec_t * ibuf); 33 typedef smpl_t (*aubio_pitchdetection_conv_t)(smpl_t value,uint_t srate,uint_t bufsize); 31 typedef smpl_t (*aubio_pitchdetection_func_t) 32 (aubio_pitchdetection_t *p, fvec_t * ibuf); 33 typedef smpl_t (*aubio_pitchdetection_conv_t) 34 (smpl_t value, uint_t srate, uint_t bufsize); 35 34 36 void aubio_pitchdetection_slideblock(aubio_pitchdetection_t *p, fvec_t *ibuf); 35 37 36 smpl_t aubio_pitchdetection_mcomb (aubio_pitchdetection_t *p, fvec_t *ibuf);37 smpl_t aubio_pitchdetection_yin (aubio_pitchdetection_t *p, fvec_t *ibuf);38 smpl_t aubio_pitchdetection_schmitt (aubio_pitchdetection_t *p, fvec_t *ibuf);39 smpl_t aubio_pitchdetection_fcomb (aubio_pitchdetection_t *p, fvec_t *ibuf);40 smpl_t aubio_pitchdetection_yinfft (aubio_pitchdetection_t *p, fvec_t *ibuf);38 smpl_t aubio_pitchdetection_mcomb (aubio_pitchdetection_t *p, fvec_t *ibuf); 39 smpl_t aubio_pitchdetection_yin (aubio_pitchdetection_t *p, fvec_t *ibuf); 40 smpl_t aubio_pitchdetection_schmitt (aubio_pitchdetection_t *p, fvec_t *ibuf); 41 smpl_t aubio_pitchdetection_fcomb (aubio_pitchdetection_t *p, fvec_t *ibuf); 42 smpl_t aubio_pitchdetection_yinfft (aubio_pitchdetection_t *p, fvec_t *ibuf); 41 43 42 44 /** generic pitch detection structure */ … … 64 66 smpl_t freqconvbin(smpl_t f,uint_t srate,uint_t bufsize); 65 67 smpl_t freqconvbin(smpl_t f,uint_t srate,uint_t bufsize){ 66 68 return aubio_freqtobin(f,srate,bufsize); 67 69 } 68 70 69 71 smpl_t freqconvmidi(smpl_t f,uint_t srate,uint_t bufsize); 70 72 smpl_t freqconvmidi(smpl_t f,uint_t srate UNUSED,uint_t bufsize UNUSED){ 71 73 return aubio_freqtomidi(f); 72 74 } 73 75 74 76 smpl_t freqconvpass(smpl_t f,uint_t srate,uint_t bufsize); 75 77 smpl_t freqconvpass(smpl_t f,uint_t srate UNUSED,uint_t bufsize UNUSED){ 76 78 return f; 77 79 } 78 80 79 81 aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize, 80 81 82 83 84 82 uint_t hopsize, 83 uint_t channels, 84 uint_t samplerate, 85 aubio_pitchdetection_type type, 86 aubio_pitchdetection_mode mode) 85 87 { 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 88 aubio_pitchdetection_t *p = AUBIO_NEW(aubio_pitchdetection_t); 89 p->srate = samplerate; 90 p->type = type; 91 p->mode = mode; 92 p->bufsize = bufsize; 93 switch(p->type) { 94 case aubio_pitch_yin: 95 p->buf = new_fvec(bufsize,channels); 96 p->yin = new_fvec(bufsize/2,channels); 97 p->callback = aubio_pitchdetection_yin; 98 p->yinthres = 0.15; 99 break; 100 case aubio_pitch_mcomb: 101 p->pv = new_aubio_pvoc(bufsize, hopsize, channels); 102 p->fftgrain = new_cvec(bufsize, channels); 103 p->mcomb = new_aubio_pitchmcomb(bufsize,hopsize,channels,samplerate); 104 p->filter = new_aubio_cdsgn_filter(samplerate); 105 p->callback = aubio_pitchdetection_mcomb; 106 break; 107 case aubio_pitch_fcomb: 108 p->buf = new_fvec(bufsize,channels); 109 p->fcomb = new_aubio_pitchfcomb(bufsize,hopsize,samplerate); 110 p->callback = aubio_pitchdetection_fcomb; 111 break; 112 case aubio_pitch_schmitt: 113 p->buf = new_fvec(bufsize,channels); 114 p->schmitt = new_aubio_pitchschmitt(bufsize,samplerate); 115 p->callback = aubio_pitchdetection_schmitt; 116 break; 117 case aubio_pitch_yinfft: 118 p->buf = new_fvec(bufsize,channels); 119 p->yinfft = new_aubio_pitchyinfft(bufsize); 120 p->callback = aubio_pitchdetection_yinfft; 121 p->yinthres = 0.85; 122 break; 123 default: 124 break; 125 } 126 switch(p->mode) { 127 case aubio_pitchm_freq: 128 p->freqconv = freqconvpass; 129 break; 130 case aubio_pitchm_midi: 131 p->freqconv = freqconvmidi; 132 break; 133 case aubio_pitchm_cent: 134 /* bug: not implemented */ 135 p->freqconv = freqconvmidi; 136 break; 137 case aubio_pitchm_bin: 138 p->freqconv = freqconvbin; 139 break; 140 default: 141 break; 142 } 143 return p; 142 144 } 143 145 144 146 void del_aubio_pitchdetection(aubio_pitchdetection_t * p) { 145 switch(p->type) { 146 case aubio_pitch_yin: 147 del_fvec(p->yin); 148 del_fvec(p->buf); 149 break; 150 case aubio_pitch_mcomb: 151 del_aubio_pvoc(p->pv); 152 del_cvec(p->fftgrain); 153 del_aubio_pitchmcomb(p->mcomb); 154 break; 155 case aubio_pitch_schmitt: 156 del_fvec(p->buf); 157 del_aubio_pitchschmitt(p->schmitt); 158 break; 159 case aubio_pitch_fcomb: 160 del_fvec(p->buf); 161 del_aubio_pitchfcomb(p->fcomb); 162 break; 163 case aubio_pitch_yinfft: 164 del_fvec(p->buf); 165 del_aubio_pitchyinfft(p->yinfft); 166 break; 167 default: 168 break; 169 } 170 AUBIO_FREE(p); 147 switch(p->type) { 148 case aubio_pitch_yin: 149 del_fvec(p->yin); 150 del_fvec(p->buf); 151 break; 152 case aubio_pitch_mcomb: 153 del_aubio_pvoc(p->pv); 154 del_cvec(p->fftgrain); 155 del_aubio_filter(p->filter); 156 del_aubio_pitchmcomb(p->mcomb); 157 break; 158 case aubio_pitch_schmitt: 159 del_fvec(p->buf); 160 del_aubio_pitchschmitt(p->schmitt); 161 break; 162 case aubio_pitch_fcomb: 163 del_fvec(p->buf); 164 del_aubio_pitchfcomb(p->fcomb); 165 break; 166 case aubio_pitch_yinfft: 167 del_fvec(p->buf); 168 del_aubio_pitchyinfft(p->yinfft); 169 break; 170 default: 171 break; 172 } 173 AUBIO_FREE(p); 171 174 } 172 175 173 176 void aubio_pitchdetection_slideblock(aubio_pitchdetection_t *p, fvec_t *ibuf){ 174 uint_t i,j = 0, overlap_size = 0; 175 overlap_size = p->buf->length-ibuf->length; 176 for (i=0;i<p->buf->channels;i++){ 177 for (j=0;j<overlap_size;j++){ 178 p->buf->data[i][j] = 179 p->buf->data[i][j+ibuf->length]; 180 } 181 } 182 for (i=0;i<ibuf->channels;i++){ 183 for (j=0;j<ibuf->length;j++){ 184 p->buf->data[i][j+overlap_size] = 185 ibuf->data[i][j]; 186 } 187 } 177 uint_t i,j = 0, overlap_size = 0; 178 overlap_size = p->buf->length-ibuf->length; 179 for (i=0;i<p->buf->channels;i++){ 180 for (j=0;j<overlap_size;j++){ 181 p->buf->data[i][j] = p->buf->data[i][j+ibuf->length]; 182 } 183 } 184 for (i=0;i<ibuf->channels;i++){ 185 for (j=0;j<ibuf->length;j++){ 186 p->buf->data[i][j+overlap_size] = ibuf->data[i][j]; 187 } 188 } 188 189 } 189 190 190 191 void aubio_pitchdetection_set_yinthresh(aubio_pitchdetection_t *p, smpl_t thres) { 191 192 p->yinthres = thres; 192 193 } 193 194 194 195 smpl_t aubio_pitchdetection(aubio_pitchdetection_t *p, fvec_t * ibuf) { 195 196 return p->freqconv(p->callback(p,ibuf),p->srate,p->bufsize); 196 197 } 197 198 198 199 smpl_t aubio_pitchdetection_mcomb(aubio_pitchdetection_t *p, fvec_t *ibuf) { 199 200 201 202 203 204 205 206 207 208 209 200 smpl_t pitch = 0.; 201 aubio_filter_do(p->filter,ibuf); 202 aubio_pvoc_do(p->pv,ibuf,p->fftgrain); 203 pitch = aubio_pitchmcomb_detect(p->mcomb,p->fftgrain); 204 /** \bug should move the >0 check within aubio_bintofreq */ 205 if (pitch>0.) { 206 pitch = aubio_bintofreq(pitch,p->srate,p->bufsize); 207 } else { 208 pitch = 0.; 209 } 210 return pitch; 210 211 } 211 212 212 213 smpl_t aubio_pitchdetection_yin(aubio_pitchdetection_t *p, fvec_t *ibuf) { 213 214 215 216 217 218 219 220 221 214 smpl_t pitch = 0.; 215 aubio_pitchdetection_slideblock(p,ibuf); 216 pitch = aubio_pitchyin_getpitchfast(p->buf,p->yin, p->yinthres); 217 if (pitch>0) { 218 pitch = p->srate/(pitch+0.); 219 } else { 220 pitch = 0.; 221 } 222 return pitch; 222 223 } 223 224 224 225 225 226 smpl_t aubio_pitchdetection_yinfft(aubio_pitchdetection_t *p, fvec_t *ibuf){ 226 227 228 229 230 231 232 233 234 227 smpl_t pitch = 0.; 228 aubio_pitchdetection_slideblock(p,ibuf); 229 pitch = aubio_pitchyinfft_detect(p->yinfft,p->buf,p->yinthres); 230 if (pitch>0) { 231 pitch = p->srate/(pitch+0.); 232 } else { 233 pitch = 0.; 234 } 235 return pitch; 235 236 } 236 237 237 238 smpl_t aubio_pitchdetection_fcomb(aubio_pitchdetection_t *p, fvec_t *ibuf){ 238 239 239 aubio_pitchdetection_slideblock(p,ibuf); 240 return aubio_pitchfcomb_detect(p->fcomb,p->buf); 240 241 } 241 242 242 243 smpl_t aubio_pitchdetection_schmitt(aubio_pitchdetection_t *p, fvec_t *ibuf){ 243 244 245 } 244 aubio_pitchdetection_slideblock(p,ibuf); 245 return aubio_pitchschmitt_detect(p->schmitt,p->buf); 246 } -
TabularUnified src/pitchdetection.h ¶
rc1656cf r7873363 15 15 along with this program; if not, write to the Free Software 16 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 */17 */ 18 18 19 19 #ifndef PITCHAUTOTCORR_H … … 26 26 /** \file 27 27 28 Generic method for pitch detection 28 Generic method for pitch detection 29 29 30 30 This file creates the objects required for the computation of the selected … … 35 35 /** pitch detection algorithm */ 36 36 typedef enum { 37 38 39 40 41 37 aubio_pitch_yin, /**< YIN algorithm */ 38 aubio_pitch_mcomb, /**< Multi-comb filter */ 39 aubio_pitch_schmitt, /**< Schmitt trigger */ 40 aubio_pitch_fcomb, /**< Fast comb filter */ 41 aubio_pitch_yinfft /**< Spectral YIN */ 42 42 } aubio_pitchdetection_type; 43 43 44 44 /** pitch detection output mode */ 45 45 typedef enum { 46 47 48 49 46 aubio_pitchm_freq, /**< Frequency (Hz) */ 47 aubio_pitchm_midi, /**< MIDI note (0.,127) */ 48 aubio_pitchm_cent, /**< Cent */ 49 aubio_pitchm_bin /**< Frequency bin (0,bufsize) */ 50 50 } aubio_pitchdetection_mode; 51 51 … … 54 54 55 55 /** execute pitch detection on an input signal frame 56 56 57 57 \param p pitch detection object as returned by new_aubio_pitchdetection 58 \param ibuf input signal of length hopsize 59 58 \param ibuf input signal of length hopsize 59 60 60 */ 61 61 smpl_t aubio_pitchdetection(aubio_pitchdetection_t * p, fvec_t * ibuf); 62 62 63 63 /** change yin or yinfft tolerance threshold 64 64 65 65 default is 0.15 for yin and 0.85 for yinfft 66 66 67 67 */ 68 68 void aubio_pitchdetection_set_yinthresh(aubio_pitchdetection_t *p, smpl_t thres); 69 69 70 70 /** deletion of the pitch detection object 71 71 72 72 \param p pitch detection object as returned by new_aubio_pitchdetection 73 73 74 74 */ 75 75 void del_aubio_pitchdetection(aubio_pitchdetection_t * p); 76 76 77 77 /** creation of the pitch detection object 78 79 \param bufsize size of the input buffer to analyse 80 \param hopsize step size between two consecutive analysis instant 78 79 \param bufsize size of the input buffer to analyse 80 \param hopsize step size between two consecutive analysis instant 81 81 \param channels number of channels to analyse 82 \param samplerate sampling rate of the signal 82 \param samplerate sampling rate of the signal 83 83 \param type set pitch detection algorithm 84 84 \param mode set pitch units for output 85 85 86 86 */ 87 aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize, 88 uint_t hopsize,89 90 91 92 87 aubio_pitchdetection_t * new_aubio_pitchdetection(uint_t bufsize, 88 uint_t hopsize, 89 uint_t channels, 90 uint_t samplerate, 91 aubio_pitchdetection_type type, 92 aubio_pitchdetection_mode mode); 93 93 94 94 #ifdef __cplusplus … … 96 96 #endif 97 97 98 #endif /*PITCHDETECTION_H*/ 98 #endif /*PITCHDETECTION_H*/ -
TabularUnified src/pitchfcomb.c ¶
rc1656cf r7873363 32 32 33 33 struct _aubio_pitchfcomb_t { 34 35 36 37 38 39 40 41 aubio_mfft_t * fft;42 34 uint_t fftSize; 35 uint_t stepSize; 36 uint_t rate; 37 fvec_t * winput; 38 fvec_t * win; 39 cvec_t * fftOut; 40 fvec_t * fftLastPhase; 41 aubio_fft_t * fft; 42 //aubio_pvoc_t * pvoc; 43 43 }; 44 44 … … 48 48 p->rate = samplerate; 49 49 p->fftSize = bufsize; 50 p->stepSize = hopsize; 50 p->stepSize = hopsize; 51 51 p->winput = new_fvec(bufsize,1); 52 52 p->fftOut = new_cvec(bufsize,1); 53 53 p->fftLastPhase = new_fvec(bufsize,1); 54 p->fft = new_aubio_ mfft(bufsize, 1);54 p->fft = new_aubio_fft(bufsize, 1); 55 55 p->win = new_fvec(bufsize,1); 56 56 aubio_window(p->win->data[0], bufsize, aubio_win_hanning); … … 72 72 73 73 for (k=0; k < input->length; k++){ 74 74 p->winput->data[0][k] = p->win->data[0][k] * input->data[0][k]; 75 75 } 76 aubio_ mfft_do(p->fft,p->winput,p->fftOut);76 aubio_fft_do(p->fft,p->winput,p->fftOut); 77 77 78 78 for (k=0; k<=p->fftSize/2; k++) { … … 104 104 } 105 105 } 106 106 107 107 k = 0; 108 108 for (l=1; l<MAX_PEAKS && peaks[l].freq > 0.0; l++) { … … 110 110 for (harmonic=5; harmonic>1; harmonic--) { 111 111 if (peaks[0].freq / peaks[l].freq < harmonic+.02 && 112 112 peaks[0].freq / peaks[l].freq > harmonic-.02) { 113 113 if (harmonic > (sint_t)maxharm && 114 114 peaks[0].db < peaks[l].db/2) { 115 115 maxharm = harmonic; 116 116 k = l; 117 117 } 118 118 } … … 130 130 del_fvec(p->win); 131 131 del_fvec(p->winput); 132 del_aubio_ mfft(p->fft);132 del_aubio_fft(p->fft); 133 133 AUBIO_FREE(p); 134 134 } -
TabularUnified src/pitchmcomb.c ¶
rc1656cf r7873363 97 97 for (j=0; j< newmag->length; j++) 98 98 newmag->data[i][j]=fftgrain->norm[i][j]; 99 /* detect only if local energy > 10. */ 99 /* detect only if local energy > 10. */ 100 100 //if (vec_local_energy(newmag)>10.) { 101 101 //hfc = vec_local_hfc(newmag); //not used … … 106 106 j = (uint_t)FLOOR(p->candidates[p->goodcandidate]->ebin+.5); 107 107 instfreq = aubio_unwrap2pi(fftgrain->phas[0][j] 108 108 - p->theta->data[0][j] - j*p->phasediff); 109 109 instfreq *= p->phasefreq; 110 110 /* store phase for next run */ … … 119 119 } 120 120 121 uint_t aubio_pitch_cands(aubio_pitchmcomb_t * p, cvec_t * fftgrain, 121 uint_t aubio_pitch_cands(aubio_pitchmcomb_t * p, cvec_t * fftgrain, 122 122 smpl_t * cands) { 123 123 uint_t i=0,j; 124 124 uint_t k; 125 125 fvec_t * newmag = (fvec_t *)p->newmag; 126 aubio_spectralcandidate_t ** scands = 126 aubio_spectralcandidate_t ** scands = 127 127 (aubio_spectralcandidate_t **)(p->candidates); 128 128 //smpl_t hfc; //fe=instfreq(theta1,theta,ops); //theta1=theta; … … 130 130 for (j=0; j< newmag->length; j++) 131 131 newmag->data[i][j]=fftgrain->norm[i][j]; 132 /* detect only if local energy > 10. */ 133 if (vec_local_energy(newmag)>10.) 132 /* detect only if local energy > 10. */ 133 if (vec_local_energy(newmag)>10.) { 134 134 /* hfc = vec_local_hfc(newmag); do not use */ 135 135 aubio_pitchmcomb_spectral_pp(p, newmag); 136 136 aubio_pitchmcomb_combdet(p,newmag); 137 137 aubio_pitchmcomb_sort_cand_freq(scands,p->ncand); 138 /* store ncand comb energies in cands[1:ncand] */ 139 for (k = 0; k<p->ncand; k++) 138 /* store ncand comb energies in cands[1:ncand] */ 139 for (k = 0; k<p->ncand; k++) 140 140 cands[k] = p->candidates[k]->ene; 141 /* store ncand[end] freq in cands[end] */ 141 /* store ncand[end] freq in cands[end] */ 142 142 cands[p->ncand] = p->candidates[p->ncand-1]->ebin; 143 143 return 1; … … 156 156 /* copy newmag to mag (scracth) */ 157 157 for (j=0;j<length;j++) { 158 mag->data[i][j] = newmag->data[i][j]; 158 mag->data[i][j] = newmag->data[i][j]; 159 159 } 160 160 vec_dc_removal(mag); /* dc removal */ … … 169 169 /* return bin and ebin */ 170 170 count = aubio_pitchmcomb_quadpick(peaks,mag); 171 for (j=0;j<count;j++) 171 for (j=0;j<count;j++) 172 172 peaks[j].mag = newmag->data[i][peaks[j].bin]; 173 173 /* reset non peaks */ … … 181 181 void aubio_pitchmcomb_combdet(aubio_pitchmcomb_t * p, fvec_t * newmag) { 182 182 aubio_spectralpeak_t * peaks = (aubio_spectralpeak_t *)p->peaks; 183 aubio_spectralcandidate_t ** candidate = 183 aubio_spectralcandidate_t ** candidate = 184 184 (aubio_spectralcandidate_t **)p->candidates; 185 185 … … 192 192 uint_t l; 193 193 uint_t d; 194 uint_t curlen ;194 uint_t curlen = 0; 195 195 196 196 smpl_t delta2; … … 214 214 candidate[l]->ebin=scaler*peaks[root_peak].ebin; 215 215 /* if less than N peaks available, curlen < N */ 216 curlen = (uint_t)FLOOR(length/(candidate[l]->ebin)); 216 if (candidate[l]->ebin != 0.) 217 curlen = (uint_t)FLOOR(length/(candidate[l]->ebin)); 217 218 curlen = (N < curlen )? N : curlen; 218 219 /* fill candidate[l]->ecomb[k] with (k+1)*candidate[l]->ebin */ … … 224 225 for (k=0;k<curlen;k++) { 225 226 xx = 100000.; 226 /** get the candidate->ecomb the closer to peaks.ebin 227 /** get the candidate->ecomb the closer to peaks.ebin 227 228 * (to cope with the inharmonicity)*/ 228 for (d=0;d<count;d++) { 229 for (d=0;d<count;d++) { 229 230 delta2 = ABS(candidate[l]->ecomb[k]-peaks[d].ebin); 230 231 if (delta2 <= xx) { … … 233 234 } 234 235 } 235 /* for a Q factor of 17, maintaining "constant Q filtering", 236 /* for a Q factor of 17, maintaining "constant Q filtering", 236 237 * and sum energy and length over non null combs */ 237 238 if ( 17. * xx < candidate[l]->ecomb[k] ) { … … 261 262 * exact peak positions are retrieved by quadratic interpolation 262 263 * 263 * \bug peak-picking too picky, sometimes counts too many peaks ? 264 * \bug peak-picking too picky, sometimes counts too many peaks ? 264 265 */ 265 266 uint_t aubio_pitchmcomb_quadpick(aubio_spectralpeak_t * spectral_peaks, fvec_t * X){ 266 267 uint_t i, j, ispeak, count = 0; 267 268 for (i=0;i<X->channels;i++) 268 for (j=1;j<X->length-1;j++) 269 for (j=1;j<X->length-1;j++) { 269 270 ispeak = vec_peakpick(X,j); 270 271 if (ispeak) { … … 290 291 291 292 void aubio_pitchmcomb_sort_peak(aubio_spectralpeak_t * peaks, uint_t nbins) { 292 qsort(peaks, nbins, sizeof(aubio_spectralpeak_t), 293 qsort(peaks, nbins, sizeof(aubio_spectralpeak_t), 293 294 aubio_pitchmcomb_sort_peak_comp); 294 295 } … … 326 327 aubio_pitchmcomb_t * p = AUBIO_NEW(aubio_pitchmcomb_t); 327 328 /* bug: should check if size / 8 > post+pre+1 */ 328 uint_t i ;329 uint_t i, j; 329 330 uint_t spec_size; 330 331 p->spec_partition = 4; … … 353 354 /* array of spectral peaks */ 354 355 p->peaks = AUBIO_ARRAY(aubio_spectralpeak_t,spec_size); 356 for (i = 0; i < spec_size; i++) { 357 p->peaks[i].bin = 0.; 358 p->peaks[i].ebin = 0.; 359 p->peaks[i].mag = 0.; 360 } 355 361 /* array of pointers to spectral candidates */ 356 362 p->candidates = AUBIO_ARRAY(aubio_spectralcandidate_t *,p->ncand); … … 358 364 p->candidates[i] = AUBIO_NEW(aubio_spectralcandidate_t); 359 365 p->candidates[i]->ecomb = AUBIO_ARRAY(smpl_t, spec_size); 366 for (j=0; j < spec_size; j++) { 367 p->candidates[i]->ecomb[j] = 0.; 368 } 369 p->candidates[i]->ene = 0.; 370 p->candidates[i]->ebin = 0.; 371 p->candidates[i]->len = 0.; 360 372 } 361 373 return p; … … 367 379 del_fvec(p->newmag); 368 380 del_fvec(p->scratch); 381 del_fvec(p->theta); 369 382 del_fvec(p->scratch2); 370 383 AUBIO_FREE(p->peaks); 371 384 for (i=0;i<p->ncand;i++) { 385 AUBIO_FREE(p->candidates[i]->ecomb); 372 386 AUBIO_FREE(p->candidates[i]); 373 387 } -
TabularUnified src/pitchyin.c ¶
rc1656cf r7873363 33 33 /* outputs the difference function */ 34 34 void aubio_pitchyin_diff(fvec_t * input, fvec_t * yin){ 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 35 uint_t c,j,tau; 36 smpl_t tmp; 37 for (c=0;c<input->channels;c++) 38 { 39 for (tau=0;tau<yin->length;tau++) 40 { 41 yin->data[c][tau] = 0.; 42 } 43 for (tau=1;tau<yin->length;tau++) 44 { 45 for (j=0;j<yin->length;j++) 46 { 47 tmp = input->data[c][j] - input->data[c][j+tau]; 48 yin->data[c][tau] += SQR(tmp); 49 } 50 } 51 } 52 52 } 53 53 54 54 /* cumulative mean normalized difference function */ 55 55 void aubio_pitchyin_getcum(fvec_t * yin) { 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 56 uint_t c,tau; 57 smpl_t tmp; 58 for (c=0;c<yin->channels;c++) 59 { 60 tmp = 0.; 61 yin->data[c][0] = 1.; 62 //AUBIO_DBG("%f\t",yin->data[c][0]); 63 for (tau=1;tau<yin->length;tau++) 64 { 65 tmp += yin->data[c][tau]; 66 yin->data[c][tau] *= tau/tmp; 67 //AUBIO_DBG("%f\t",yin->data[c][tau]); 68 } 69 //AUBIO_DBG("\n"); 70 } 71 71 } 72 72 73 73 uint_t aubio_pitchyin_getpitch(fvec_t * yin) { 74 75 76 77 78 79 80 81 82 83 84 85 86 74 uint_t c=0,tau=1; 75 do 76 { 77 if(yin->data[c][tau] < 0.1) { 78 while (yin->data[c][tau+1] < yin->data[c][tau]) { 79 tau++; 80 } 81 return tau; 82 } 83 tau++; 84 } while (tau<yin->length); 85 //AUBIO_DBG("No pitch found"); 86 return 0; 87 87 } 88 88 … … 90 90 /* all the above in one */ 91 91 smpl_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t * yin, smpl_t tol){ 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 92 uint_t c=0,j,tau = 0; 93 sint_t period; 94 smpl_t tmp = 0., tmp2 = 0.; 95 yin->data[c][0] = 1.; 96 for (tau=1;tau<yin->length;tau++) 97 { 98 yin->data[c][tau] = 0.; 99 for (j=0;j<yin->length;j++) 100 { 101 tmp = input->data[c][j] - input->data[c][j+tau]; 102 yin->data[c][tau] += SQR(tmp); 103 } 104 tmp2 += yin->data[c][tau]; 105 yin->data[c][tau] *= tau/tmp2; 106 period = tau-3; 107 if(tau > 4 && (yin->data[c][period] < tol) && 108 (yin->data[c][period] < yin->data[c][period+1])) { 109 return vec_quadint_min(yin,period,1); 110 } 111 } 112 return vec_quadint_min(yin,vec_min_elem(yin),1); 113 //return 0; 114 114 } 115 115 -
TabularUnified src/pitchyinfft.c ¶
rc1656cf r7873363 31 31 fvec_t * weight; /**< spectral weighting window (psychoacoustic model) */ 32 32 cvec_t * fftout; /**< Fourier transform output */ 33 aubio_ mfft_t * fft; /**< fft object to compute square difference function */33 aubio_fft_t * fft; /**< fft object to compute square difference function */ 34 34 fvec_t * yinfft; /**< Yin function */ 35 35 }; 36 36 37 37 static const smpl_t freqs[] = {0., 20., 25., 31.5, 40., 50., 63., 80., 100., 38 39 40 38 125., 160., 200., 250., 315., 400., 500., 630., 800., 1000., 1250., 39 1600., 2000., 2500., 3150., 4000., 5000., 6300., 8000., 9000., 10000., 40 12500., 15000., 20000., 25100}; 41 41 42 42 static const smpl_t weight[] = {-75.8, -70.1, -60.8, -52.1, -44.2, -37.5, 43 44 45 43 -31.3, -25.6, -20.9, -16.5, -12.6, -9.6, -7.0, -4.7, -3.0, -1.8, -0.8, 44 -0.2, -0.0, 0.5, 1.6, 3.2, 5.4, 7.8, 8.1, 5.3, -2.4, -11.1, -12.8, 45 -12.2, -7.4, -17.8, -17.8, -17.8}; 46 46 47 47 aubio_pitchyinfft_t * new_aubio_pitchyinfft (uint_t bufsize) 48 48 { 49 49 aubio_pitchyinfft_t * p = AUBIO_NEW(aubio_pitchyinfft_t); 50 p->winput 51 p->fft = new_aubio_mfft(bufsize, 1);52 p->fftout 53 p->sqrmag 54 p->res 55 p->yinfft 56 p->win 50 p->winput = new_fvec(bufsize,1); 51 p->fft = new_aubio_fft(bufsize, 1); 52 p->fftout = new_cvec(bufsize,1); 53 p->sqrmag = new_fvec(bufsize,1); 54 p->res = new_cvec(bufsize,1); 55 p->yinfft = new_fvec(bufsize/2+1,1); 56 p->win = new_fvec(bufsize,1); 57 57 aubio_window(p->win->data[0], bufsize, aubio_win_hanningz); 58 58 p->weight = new_fvec(bufsize/2+1,1); 59 59 { 60 61 62 63 64 65 66 67 68 69 70 71 if (f0 == f1) { // just in case 72 73 74 75 76 p->weight->data[0][i] = (a1-a0)/(f1-f0)*freq + 77 78 79 80 81 82 83 84 85 60 uint_t i = 0, j = 1; 61 smpl_t freq = 0, a0 = 0, a1 = 0, f0 = 0, f1 = 0; 62 for (i=0; i<p->weight->length; i++) { 63 freq = (smpl_t)i/(smpl_t)bufsize*(smpl_t)44100.; 64 while (freq > freqs[j]) { 65 j +=1; 66 } 67 a0 = weight[j-1]; 68 f0 = freqs[j-1]; 69 a1 = weight[j]; 70 f1 = freqs[j]; 71 if (f0 == f1) { // just in case 72 p->weight->data[0][i] = a0; 73 } else if (f0 == 0) { // y = ax+b 74 p->weight->data[0][i] = (a1-a0)/f1*freq + a0; 75 } else { 76 p->weight->data[0][i] = (a1-a0)/(f1-f0)*freq + 77 (a0 - (a1 - a0)/(f1/f0 - 1.)); 78 } 79 while (freq > freqs[j]) { 80 j +=1; 81 } 82 //AUBIO_DBG("%f\n",p->weight->data[0][i]); 83 p->weight->data[0][i] = DB2LIN(p->weight->data[0][i]); 84 //p->weight->data[0][i] = SQRT(DB2LIN(p->weight->data[0][i])); 85 } 86 86 } 87 87 return p; … … 95 95 fvec_t * yin = (fvec_t *)p->yinfft; 96 96 for (l=0; l < input->length; l++){ 97 97 p->winput->data[0][l] = p->win->data[0][l] * input->data[0][l]; 98 98 } 99 aubio_ mfft_do(p->fft,p->winput,p->fftout);99 aubio_fft_do(p->fft,p->winput,p->fftout); 100 100 for (l=0; l < p->fftout->length; l++){ 101 102 p->sqrmag->data[0][l] *= p->weight->data[0][l]; 101 p->sqrmag->data[0][l] = SQR(p->fftout->norm[0][l]); 102 p->sqrmag->data[0][l] *= p->weight->data[0][l]; 103 103 } 104 104 for (l=1; l < p->fftout->length; l++){ 105 p->sqrmag->data[0][(p->fftout->length-1)*2-l] = 106 107 108 105 p->sqrmag->data[0][(p->fftout->length-1)*2-l] = 106 SQR(p->fftout->norm[0][l]); 107 p->sqrmag->data[0][(p->fftout->length-1)*2-l] *= 108 p->weight->data[0][l]; 109 109 } 110 110 for (l=0; l < p->sqrmag->length/2+1; l++) { 111 111 sum += p->sqrmag->data[0][l]; 112 112 } 113 113 sum *= 2.; 114 aubio_ mfft_do(p->fft,p->sqrmag,res);115 yin->data[0][0] = 1.; 114 aubio_fft_do(p->fft,p->sqrmag,res); 115 yin->data[0][0] = 1.; 116 116 for (tau=1; tau < yin->length; tau++) { 117 118 res->norm[0][tau]*COS(res->phas[0][tau]); 119 120 117 yin->data[0][tau] = sum - 118 res->norm[0][tau]*COS(res->phas[0][tau]); 119 tmp += yin->data[0][tau]; 120 yin->data[0][tau] *= tau/tmp; 121 121 } 122 tau = vec_min_elem(yin); 122 tau = vec_min_elem(yin); 123 123 if (yin->data[0][tau] < tol) { 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 124 /* no interpolation */ 125 //return tau; 126 /* 3 point quadratic interpolation */ 127 //return vec_quadint_min(yin,tau,1); 128 /* additional check for (unlikely) octave doubling in higher frequencies */ 129 if (tau>35) { 130 return vec_quadint_min(yin,tau,1); 131 } else { 132 /* should compare the minimum value of each interpolated peaks */ 133 halfperiod = FLOOR(tau/2+.5); 134 if (yin->data[0][halfperiod] < tol) 135 return vec_quadint_min(yin,halfperiod,1); 136 else 137 return vec_quadint_min(yin,tau,1); 138 } 139 139 } else 140 return 0;140 return 0.; 141 141 } 142 142 143 143 void del_aubio_pitchyinfft(aubio_pitchyinfft_t *p){ 144 145 del_aubio_mfft(p->fft);146 147 148 149 150 151 152 144 del_fvec(p->win); 145 del_aubio_fft(p->fft); 146 del_fvec(p->yinfft); 147 del_fvec(p->sqrmag); 148 del_cvec(p->res); 149 del_cvec(p->fftout); 150 del_fvec(p->winput); 151 del_fvec(p->weight); 152 AUBIO_FREE(p); 153 153 } -
TabularUnified src/sample.h ¶
rc1656cf r7873363 1 1 /* 2 Copyright (C) 2003 Paul Brossier2 Copyright (C) 2003-2007 Paul Brossier <piem@piem.org> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 21 21 #define _SAMPLE_H 22 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /** \file 28 29 Real and complex buffers 30 31 This file specifies fvec_t and cvec_t buffers types, which are used 32 throughout aubio to store real and complex data. Complex values are stored in 33 terms of phase and norm. 34 35 */ 36 37 /** Sample buffer type */ 38 typedef struct _fvec_t fvec_t; 39 /** Spectrum buffer type */ 40 typedef struct _cvec_t cvec_t; 41 /** Buffer for real values */ 42 struct _fvec_t { 43 uint_t length; /**< length of buffer */ 44 uint_t channels; /**< number of channels */ 45 smpl_t **data; /**< data array of size [length] * [channels] */ 46 }; 47 /** Buffer for complex data */ 48 struct _cvec_t { 49 uint_t length; /**< length of buffer = (requested length)/2 + 1 */ 50 uint_t channels; /**< number of channels */ 51 smpl_t **norm; /**< norm array of size [length] * [channels] */ 52 smpl_t **phas; /**< phase array of size [length] * [channels] */ 53 }; 54 /** fvec_t buffer creation function 55 56 \param length the length of the buffer to create 57 \param channels the number of channels in the buffer 58 59 */ 60 fvec_t * new_fvec(uint_t length, uint_t channels); 61 /** fvec_t buffer deletion function 62 63 \param s buffer to delete as returned by new_fvec() 64 65 */ 66 void del_fvec(fvec_t *s); 67 /** read sample value in a buffer 68 69 Note that this function is not used in the aubio library, since the same 70 result can be obtained using vec->data[channel][position]. Its purpose is to 71 access these values from wrappers, as created by swig. 72 73 \param s vector to read from 74 \param channel channel to read from 75 \param position sample position to read from 76 77 */ 78 smpl_t fvec_read_sample(fvec_t *s, uint_t channel, uint_t position); 79 /** write sample value in a buffer 80 81 Note that this function is not used in the aubio library, since the same 82 result can be obtained by assigning vec->data[channel][position]. Its purpose 83 is to access these values from wrappers, as created by swig. 84 85 \param s vector to write to 86 \param data value to write in s->data[channel][position] 87 \param channel channel to write to 88 \param position sample position to write to 89 90 */ 91 void fvec_write_sample(fvec_t *s, smpl_t data, uint_t channel, uint_t position); 92 /** read channel vector from a buffer 93 94 Note that this function is not used in the aubio library, since the same 95 result can be obtained with vec->data[channel]. Its purpose is to access 96 these values from wrappers, as created by swig. 97 98 \param s vector to read from 99 \param channel channel to read from 100 101 */ 102 smpl_t * fvec_get_channel(fvec_t *s, uint_t channel); 103 /** write channel vector into a buffer 104 105 Note that this function is not used in the aubio library, since the same 106 result can be obtained by assigning vec->data[channel]. Its purpose is to 107 access these values from wrappers, as created by swig. 108 109 \param s vector to write to 110 \param data vector of [length] values to write 111 \param channel channel to write to 112 113 */ 114 void fvec_put_channel(fvec_t *s, smpl_t * data, uint_t channel); 115 /** read data from a buffer 116 117 Note that this function is not used in the aubio library, since the same 118 result can be obtained with vec->data. Its purpose is to access these values 119 from wrappers, as created by swig. 120 121 \param s vector to read from 122 123 */ 124 smpl_t ** fvec_get_data(fvec_t *s); 125 126 /** cvec_t buffer creation function 127 128 This function creates a cvec_t structure holding two arrays of size 129 [length/2+1] * channels, corresponding to the norm and phase values of the 130 spectral frame. The length stored in the structure is the actual size of both 131 arrays, not the length of the complex and symetrical vector, specified as 132 creation argument. 133 134 \param length the length of the buffer to create 135 \param channels the number of channels in the buffer 136 137 */ 138 cvec_t * new_cvec(uint_t length, uint_t channels); 139 /** cvec_t buffer deletion function 140 141 \param s buffer to delete as returned by new_cvec() 142 143 */ 144 void del_cvec(cvec_t *s); 145 /** write norm value in a complex buffer 146 147 Note that this function is not used in the aubio library, since the same 148 result can be obtained by assigning vec->norm[channel][position]. Its purpose 149 is to access these values from wrappers, as created by swig. 150 151 \param s vector to write to 152 \param data norm value to write in s->norm[channel][position] 153 \param channel channel to write to 154 \param position sample position to write to 155 156 */ 157 void cvec_write_norm(cvec_t *s, smpl_t data, uint_t channel, uint_t position); 158 /** write phase value in a complex buffer 159 160 Note that this function is not used in the aubio library, since the same 161 result can be obtained by assigning vec->phas[channel][position]. Its purpose 162 is to access these values from wrappers, as created by swig. 163 164 \param s vector to write to 165 \param data phase value to write in s->phas[channel][position] 166 \param channel channel to write to 167 \param position sample position to write to 168 169 */ 170 void cvec_write_phas(cvec_t *s, smpl_t data, uint_t channel, uint_t position); 171 /** read norm value from a complex buffer 172 173 Note that this function is not used in the aubio library, since the same 174 result can be obtained with vec->norm[channel][position]. Its purpose is to 175 access these values from wrappers, as created by swig. 176 177 \param s vector to read from 178 \param channel channel to read from 179 \param position sample position to read from 180 181 */ 182 smpl_t cvec_read_norm(cvec_t *s, uint_t channel, uint_t position); 183 /** read phase value from a complex buffer 184 185 Note that this function is not used in the aubio library, since the same 186 result can be obtained with vec->phas[channel][position]. Its purpose is to 187 access these values from wrappers, as created by swig. 188 189 \param s vector to read from 190 \param channel channel to read from 191 \param position sample position to read from 192 193 */ 194 smpl_t cvec_read_phas(cvec_t *s, uint_t channel, uint_t position); 195 /** write norm channel in a complex buffer 196 197 Note that this function is not used in the aubio library, since the same 198 result can be obtained by assigning vec->norm[channel]. Its purpose is to 199 access these values from wrappers, as created by swig. 200 201 \param s vector to write to 202 \param data norm vector of [length] samples to write in s->norm[channel] 203 \param channel channel to write to 204 205 */ 206 void cvec_put_norm_channel(cvec_t *s, smpl_t * data, uint_t channel); 207 /** write phase channel in a complex buffer 208 209 Note that this function is not used in the aubio library, since the same 210 result can be obtained by assigning vec->phas[channel]. Its purpose is to 211 access these values from wrappers, as created by swig. 212 213 \param s vector to write to 214 \param data phase vector of [length] samples to write in s->phas[channel] 215 \param channel channel to write to 216 217 */ 218 void cvec_put_phas_channel(cvec_t *s, smpl_t * data, uint_t channel); 219 /** read norm channel from a complex buffer 220 221 Note that this function is not used in the aubio library, since the same 222 result can be obtained with vec->norm[channel]. Its purpose is to access 223 these values from wrappers, as created by swig. 224 225 \param s vector to read from 226 \param channel channel to read from 227 228 */ 229 smpl_t * cvec_get_norm_channel(cvec_t *s, uint_t channel); 230 /** write phase channel in a complex buffer 231 232 Note that this function is not used in the aubio library, since the same 233 result can be obtained with vec->phas[channel]. Its purpose is to access 234 these values from wrappers, as created by swig. 235 236 \param s vector to read from 237 \param channel channel to read from 238 239 */ 240 smpl_t * cvec_get_phas_channel(cvec_t *s, uint_t channel); 241 /** read norm data from a complex buffer 242 243 Note that this function is not used in the aubio library, since the same 244 result can be obtained with vec->norm. Its purpose is to access these values 245 from wrappers, as created by swig. 246 247 \param s vector to read from 248 249 */ 250 smpl_t ** cvec_get_norm(cvec_t *s); 251 /** read phase data from a complex buffer 252 253 Note that this function is not used in the aubio library, since the same 254 result can be obtained with vec->phas. Its purpose is to access these values 255 from wrappers, as created by swig. 256 257 \param s vector to read from 258 259 */ 260 smpl_t ** cvec_get_phas(cvec_t *s); 261 262 #ifdef __cplusplus 263 } 264 #endif 23 #include "fvec.h" 24 #include "cvec.h" 265 25 266 26 #endif /* _SAMPLE_H */ -
TabularUnified src/scale.c ¶
rc1656cf r7873363 1 1 /* 2 2 Copyright (C) 2003 Paul Brossier 3 3 4 5 6 7 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 8 9 10 11 12 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 13 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 17 18 */ 18 19 … … 22 23 23 24 struct _aubio_scale_t { 24 25 26 27 25 smpl_t ilow; 26 smpl_t ihig; 27 smpl_t olow; 28 smpl_t ohig; 28 29 29 30 31 32 33 34 35 30 smpl_t scaler; 31 smpl_t irange; 32 33 /* not implemented yet : type in/out data 34 bool inint; 35 bool outint; 36 */ 36 37 }; 37 38 38 aubio_scale_t * new_aubio_scale (smpl_t ilow, smpl_t ihig, smpl_t olow, smpl_t ohig ){ 39 aubio_scale_t * s = AUBIO_NEW(aubio_scale_t); 40 aubio_scale_set (s, ilow, ihig, olow, ohig); 41 return s; 39 aubio_scale_t * new_aubio_scale (smpl_t ilow, smpl_t ihig, 40 smpl_t olow, smpl_t ohig) { 41 aubio_scale_t * s = AUBIO_NEW(aubio_scale_t); 42 aubio_scale_set (s, ilow, ihig, olow, ohig); 43 return s; 42 44 } 43 45 44 46 void del_aubio_scale(aubio_scale_t *s) { 45 47 AUBIO_FREE(s); 46 48 } 47 49 48 void aubio_scale_set (aubio_scale_t *s, smpl_t ilow, smpl_t ihig, smpl_t olow, smpl_t ohig) 49 { 50 smpl_t inputrange = ihig - ilow; 51 smpl_t outputrange= ohig - olow; 52 s->ilow = ilow; 53 s->ihig = ihig; 54 s->olow = olow; 55 s->ohig = ohig; 56 if (inputrange == 0 ) 57 s->scaler = 0.0f; 58 else { 59 s->scaler = outputrange/inputrange; 60 if (inputrange < 0 ) 61 inputrange = inputrange * -1.0f; 62 } 50 void aubio_scale_set (aubio_scale_t *s, smpl_t ilow, smpl_t ihig, 51 smpl_t olow, smpl_t ohig) { 52 smpl_t inputrange = ihig - ilow; 53 smpl_t outputrange= ohig - olow; 54 s->ilow = ilow; 55 s->ihig = ihig; 56 s->olow = olow; 57 s->ohig = ohig; 58 if (inputrange == 0) { 59 s->scaler = 0.0f; 60 } else { 61 s->scaler = outputrange/inputrange; 62 if (inputrange < 0) { 63 inputrange = inputrange * -1.0f; 64 } 65 } 63 66 } 64 67 65 68 void aubio_scale_do (aubio_scale_t *s, fvec_t *input) 66 69 { 67 68 69 70 71 72 73 74 70 uint_t i, j; 71 for (i=0; i < input->channels; i++){ 72 for (j=0; j < input->length; j++){ 73 input->data[i][j] -= s->ilow; 74 input->data[i][j] *= s->scaler; 75 input->data[i][j] += s->olow; 76 } 77 } 75 78 } 76 79 -
TabularUnified src/scale.h ¶
rc1656cf r7873363 1 1 /* 2 2 Copyright (C) 2003 Paul Brossier 3 3 4 5 6 7 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 8 9 10 11 12 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 13 14 15 16 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, write to the Free Software 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 17 */ 18 18 … … 45 45 46 46 */ 47 aubio_scale_t * new_aubio_scale(smpl_t flow, smpl_t fhig, smpl_t ilow, smpl_t ihig ); 47 aubio_scale_t * new_aubio_scale(smpl_t flow, smpl_t fhig, 48 smpl_t ilow, smpl_t ihig); 48 49 /** delete a scale object 49 50 … … 68 69 69 70 */ 70 void aubio_scale_set (aubio_scale_t *s, smpl_t ilow, smpl_t ihig, smpl_t olow, smpl_t ohig); 71 void aubio_scale_set (aubio_scale_t *s, smpl_t ilow, smpl_t ihig, 72 smpl_t olow, smpl_t ohig); 71 73 72 74 #ifdef __cplusplus -
TabularUnified swig/aubio.i ¶
rc1656cf r7873363 72 72 73 73 /* fft */ 74 extern void aubio_fft_getnorm(smpl_t * norm, fft_data_t * spectrum, uint_t size); 75 extern void aubio_fft_getphas(smpl_t * phase, fft_data_t * spectrum, uint_t size); 76 77 extern aubio_mfft_t * new_aubio_mfft(uint_t winsize, uint_t channels); 78 extern void aubio_mfft_do (aubio_mfft_t * fft,fvec_t * in,cvec_t * fftgrain); 79 extern void aubio_mfft_rdo(aubio_mfft_t * fft,cvec_t * fftgrain, fvec_t * out); 80 extern void del_aubio_mfft(aubio_mfft_t * fft); 81 74 extern aubio_fft_t * new_aubio_fft(uint_t size, uint_t channels); 75 extern void del_aubio_fft(aubio_fft_t * s); 76 extern void aubio_fft_do (aubio_fft_t *s, fvec_t * input, cvec_t * spectrum); 77 extern void aubio_fft_rdo (aubio_fft_t *s, cvec_t * spectrum, fvec_t * output); 78 extern void aubio_fft_do_complex (aubio_fft_t *s, fvec_t * input, fvec_t * compspec); 79 extern void aubio_fft_rdo_complex (aubio_fft_t *s, fvec_t * compspec, fvec_t * output); 80 extern void aubio_fft_get_spectrum(fvec_t * compspec, cvec_t * spectrum); 81 extern void aubio_fft_get_realimag(cvec_t * spectrum, fvec_t * compspec); 82 extern void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum); 83 extern void aubio_fft_get_imag(cvec_t * spectrum, fvec_t * compspec); 84 extern void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum); 85 extern void aubio_fft_get_real(cvec_t * spectrum, fvec_t * compspec); 82 86 83 87 /* filter */ … … 101 105 extern void aubio_hist_do(aubio_hist_t *s, fvec_t * input); 102 106 extern void aubio_hist_do_notnull(aubio_hist_t *s, fvec_t * input); 103 extern void aubio_hist_dyn_notnull (aubio_hist_t *s, fvec_t *input); 107 extern void aubio_hist_dyn_notnull(aubio_hist_t *s, fvec_t *input); 108 extern void aubio_hist_weight(aubio_hist_t *s); 109 extern smpl_t aubio_hist_mean(aubio_hist_t *s); 104 110 105 111 /* mathutils */ … … 161 167 void aubio_mfcc_do(aubio_mfcc_t *mf, cvec_t *in, fvec_t *out); 162 168 163 164 169 /* scale */ 165 170 extern aubio_scale_t * new_aubio_scale(smpl_t flow, smpl_t fhig, smpl_t ilow, smpl_t ihig ); … … 181 186 aubio_onset_phase, 182 187 aubio_onset_kl, 183 aubio_onset_mkl 188 aubio_onset_mkl, 189 aubio_onset_specflux, 184 190 } aubio_onsetdetection_type; 185 191 aubio_onsetdetection_t * new_aubio_onsetdetection(aubio_onsetdetection_type type, uint_t size, uint_t channels); 186 192 void aubio_onsetdetection(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset); 187 void aubio_onsetdetection_free(aubio_onsetdetection_t *o);193 void del_aubio_onsetdetection(aubio_onsetdetection_t *o); 188 194 189 195 /* should these still be exposed ? */
Note: See TracChangeset
for help on using the changeset viewer.