- Timestamp:
- Sep 6, 2007, 7:32:13 PM (17 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 7a46bf6, fdf39ba
- Parents:
- 71b1b4b
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Makefile.am
r71b1b4b r7c6c806d 22 22 onset.h \ 23 23 tempo.h \ 24 filter.h 24 filter.h \ 25 mfcc.h 25 26 26 27 nodist_pkginclude_HEADERS = config.h … … 71 72 filter.c \ 72 73 filter.h \ 74 mfcc.h \ 75 mfcc.c 73 76 74 77 AM_CFLAGS = @AUBIO_CFLAGS@ @FFTWLIB_CFLAGS@ @SAMPLERATE_CFLAGS@ -
src/filterbank.c
r71b1b4b r7c6c806d 21 21 */ 22 22 23 #include "aubio_priv.h" 23 24 #include "filterbank.h" 25 26 27 // Struct Declaration 28 29 /** \brief A structure to store a set of n_filters Mel filters */ 30 typedef struct aubio_mel_filter_ { 31 int n_filters; 32 smpl_t **filters; 33 }; 24 34 25 35 // Initialization -
src/filterbank.h
r71b1b4b r7c6c806d 23 23 #define AUBIOFILTERBANK_H 24 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 25 28 26 // Struct Declaration27 29 28 /** \brief A structure to store a set of n_filters Mel filters */ 29 typedef struct aubio_mel_filter_ { 30 int n_filters; 31 smpl_t **filters; 32 } aubio_mel_filter; 30 31 typedef struct aubio_mel_filter_ aubio_mel_filter; 33 32 34 33 // Initialization … … 38 37 * It is up to the caller to pass in a pointer to memory allocated for freq_bands arrays of length N. This function populates these arrays with magnitude coefficients representing the mel filterbank on a linear scale 39 38 */ 40 int aubio_mfcc_init(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, smpl_t ** fft_tables); 39 int aubio_mfcc_init(int N, smpl_t nyquist, int style, smpl_t freq_min, smpl_t freq_max, int freq_bands, smpl_t ** fft_tables); 40 41 #ifdef __cplusplus 42 } 43 #endif 41 44 42 45 #endif -
src/mfcc.c
r71b1b4b r7c6c806d 21 21 */ 22 22 23 #include "aubio_priv.h" 24 #include "sample.h" 25 #include "fft.h" 26 #include "mfcc.h" 27 #include "math.h" 23 28 24 #include "mffc.h" 29 /* 30 new_aubio_mfcc 31 aubio_mfcc_do 32 del_aubio_mfcc 33 */ 25 34 26 35 // Computation 36 // Added last two arguments to be able to pass from example 27 37 28 int aubio_mfcc_do(const float *data, const int N, const void *argv, float *result){ 38 39 40 int aubio_mfcc_do(const float *data, const int N, const void *argv, float *result, aubio_mfft_t * fft_dct, cvec_t * fftgrain_dct){ 29 41 30 42 aubio_mel_filter *f; … … 38 50 result[filter] += data[n] * f->filters[filter][n]; 39 51 } 40 result[filter] = log(result[filter] < XTRACT_LOG_LIMIT ? XTRACT_LOG_LIMIT : result[filter]);52 result[filter] = LOG(result[filter] < XTRACT_LOG_LIMIT ? XTRACT_LOG_LIMIT : result[filter]); 41 53 } 42 54 43 //TODO: check that zero padding 55 //TODO: check that zero padding 44 56 for(n = filter + 1; n < N; n++) result[n] = 0; 45 57 46 aubio_dct_do(result, f->n_filters, NULL, result );58 aubio_dct_do(result, f->n_filters, NULL, result, fft_dct, fftgrain_dct); 47 59 48 60 return XTRACT_SUCCESS; 49 61 } 50 62 51 int aubio_dct_do(const float *data, const int N, const void *argv, float *result){ 63 // Added last two arguments to be able to pass from example 64 65 int aubio_dct_do(const float *data, const int N, const void *argv, float *result, aubio_mfft_t * fft_dct, cvec_t * fftgrain_dct){ 52 66 53 67 … … 56 70 //TODO: fvec as input? Remove data length, N? 57 71 72 fvec_t * momo = new_fvec(20, 1); 73 momo->data = data; 74 58 75 //compute mag spectrum 59 aubio_ pvoc_do (pv,data, fftgrain);76 aubio_mfft_do (fft_dct, data, fftgrain_dct); 60 77 61 78 int i; 62 79 //extract real part of fft grain 63 80 for(i=0; i<N ;i++){ 64 result[i]= fftgrain ->norm[i]*cos(fftgrain->phase[i]);81 result[i]= fftgrain_dct->norm[0][i]*COS(fftgrain_dct->phas[0][i]); 65 82 } 66 67 /* 68 fftwf_plan plan; 69 70 plan = 71 fftwf_plan_r2r_1d(N, (float *) data, result, FFTW_REDFT00, FFTW_ESTIMATE); 72 73 fftwf_execute(plan); 74 fftwf_destroy_plan(plan);*/ 83 75 84 76 85 return XTRACT_SUCCESS; -
src/mfcc.h
r71b1b4b r7c6c806d 24 24 #define MFCC_H 25 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 26 30 #include "filterbank.h" 27 31 28 //libXtract enums32 //libXtract constants and enums 29 33 // TODO: remove them 34 35 #define XTRACT_SQ(a) ((a) * (a)) 36 #define XTRACT_MIN(a, b) ((a) < (b) ? (a) : (b)) 37 #define XTRACT_MAX(a, b) ((a) > (b) ? (a) : (b)) 38 #define XTRACT_NEEDS_FFTW printf("LibXtract must be compiled with fftw support to use this function.\n") 39 #define XTRACT_VERY_SMALL_NUMBER 2e-42 40 #define XTRACT_LOG_LIMIT XTRACT_VERY_SMALL_NUMBER 41 #define XTRACT_LOG_LIMIT_DB -96.0 42 #define XTRACT_DB_SCALE_OFFSET 96.0 43 #define XTRACT_VERY_BIG_NUMBER 2e42 44 #define XTRACT_SR_UPPER_LIMIT 192000.0 45 #define XTRACT_SR_LOWER_LIMIT 22050.0 46 #define XTRACT_SR_DEFAULT 44100.0 47 #define XTRACT_FUNDAMENTAL_DEFAULT 440.0 48 #define XTRACT_CHECK_nyquist if(!nyquist) nyquist = XTRACT_SR_DEFAULT / 2 49 #define XTRACT_CHECK_q if(!q) q = XTRACT_SR_DEFAULT / N 50 #define XTRACT_IS_ODD(x) (x % 2 != 0 ? 1 : 0) 51 #define XTRACT_SR_LIMIT SR_UPPER_LIMIT 52 #define XTRACT_FFT_BANDS_MIN 16 53 #define XTRACT_FFT_BANDS_MAX 65536 54 #define XTRACT_FFT_BANDS_DEF 1024 55 #define XTRACT_SPEC_BW_MIN 0.168 /* Minimum spectral bandwidth \ 56 (= SR_LOWER_LIMIT / FFT_BANDS_MAX*/ 57 #define XTRACT_SPEC_BW_MAX 12000.0 /* SR_UPPER_LIMIT / FFT_BANDS_MIN */ 58 #define XTRACT_SPEC_BW_DEF 43.066 /* SR_DEFAULT / FFT_BANDS_DEF */ 30 59 31 60 /** \brief Enumeration of feature initialisation functions */ … … 132 161 * The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc 133 162 */ 134 int aubio_mfcc_do(const float *data, const int N, const void *argv, float *result); 163 164 165 int aubio_mfcc_do(const float *data, const int N, const void *argv, float *result, aubio_mfft_t *fft_dct, cvec_t *fftgrain_dct); 135 166 136 167 /** \brief Extract the Discrete Cosine transform of a time domain signal … … 140 171 * \param *result: a pointer to an array containing resultant dct coefficients 141 172 */ 142 int aubio_dct_do(const float *data, const int N, const void *argv, float *result );173 int aubio_dct_do(const float *data, const int N, const void *argv, float *result, aubio_mfft_t *fft_dct, cvec_t *fftgrain_dct); 143 174 175 #ifdef __cplusplus 176 } 177 #endif 144 178 145 179 #endif
Note: See TracChangeset
for help on using the changeset viewer.