Changeset 7a46bf6 for src/mfcc.h
- Timestamp:
- Sep 10, 2007, 7:29:32 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:
- 787f1f3, ef1c3b7
- Parents:
- 7c6c806d (diff), 45134c5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mfcc.h
r7c6c806d r7a46bf6 1 1 /* 2 Copyright (C) 2006 Amaury Hazan 3 Ported to aubio from LibXtract 4 http://libxtract.sourceforge.net/ 5 2 Copyright (C) 2007 Amaury Hazan <ahazan@iua.upf.edu> 3 and Paul Brossier <piem@piem.org> 6 4 7 5 This program is free software; you can redistribute it and/or modify … … 21 19 */ 22 20 21 /* part of this mfcc implementation were inspired from LibXtract 22 http://libxtract.sourceforge.net/ 23 */ 24 23 25 #ifndef MFCC_H 24 26 #define MFCC_H … … 28 30 #endif 29 31 32 #include "sample.h" 30 33 #include "filterbank.h" 31 34 32 //libXtract constants and enums 33 // TODO: remove them 35 typedef struct aubio_mfcc_t_ aubio_mfcc_t; 34 36 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 */ 37 /** create mfcc object 59 38 60 /** \brief Enumeration of feature initialisation functions */ 61 enum xtract_feature_init_ { 62 XTRACT_INIT_MFCC = 100, 63 XTRACT_INIT_BARK 64 }; 39 \param win_s size of analysis buffer (and length the FFT transform) 40 \param samplerate 41 \param n_coefs: number of desired coefs 42 \param lowfreq: lowest frequency to use in filterbank 43 \param highfreq highest frequency to use in filterbank 44 \param channels number of channels 65 45 66 /** \brief Enumeration of feature types */ 67 enum xtract_feature_types_ { 68 XTRACT_SCALAR, 69 XTRACT_VECTOR, 70 XTRACT_DELTA 71 }; 46 */ 47 aubio_mfcc_t * new_aubio_mfcc (uint_t win_s, uint_t samplerate, uint_t n_filters, uint_t n_coefs, smpl_t lowfreq, smpl_t highfreq, uint_t channels); 48 /** delete mfcc object 72 49 73 /** \brief Enumeration of mfcc types */ 74 enum xtract_mfcc_types_ { 75 XTRACT_EQUAL_GAIN, 76 XTRACT_EQUAL_AREA 77 }; 50 \param mf mfcc object as returned by new_aubio_mfcc 78 51 79 /** \brief Enumeration of return codes */ 80 enum xtract_return_codes_ { 81 XTRACT_SUCCESS, 82 XTRACT_MALLOC_FAILED, 83 XTRACT_BAD_ARGV, 84 XTRACT_BAD_VECTOR_SIZE, 85 XTRACT_NO_RESULT, 86 XTRACT_FEATURE_NOT_IMPLEMENTED 87 }; 52 */ 53 void del_aubio_mfcc(aubio_mfcc_t *mf); 54 /** mfcc object processing 88 55 89 /** \brief Enumeration of spectrum types */ 90 enum xtract_spectrum_ { 91 XTRACT_MAGNITUDE_SPECTRUM, 92 XTRACT_LOG_MAGNITUDE_SPECTRUM, 93 XTRACT_POWER_SPECTRUM, 94 XTRACT_LOG_POWER_SPECTRUM 95 }; 56 \param mf mfcc object as returned by new_aubio_mfcc 57 \param in input spectrum (win_s long) 58 \param out output mel coefficients buffer (n_filters/2 +1 long) 96 59 97 /** \brief Enumeration of data types*/ 98 typedef enum type_ { 99 XTRACT_FLOAT, 100 XTRACT_FLOATARRAY, 101 XTRACT_INT, 102 XTRACT_MEL_FILTER 103 } xtract_type_t; 60 */ 61 void aubio_mfcc_do(aubio_mfcc_t * mf, cvec_t *in, fvec_t *out); 104 62 105 /** \brief Enumeration of units*/ 106 typedef enum unit_ { 107 /* NONE, ANY */ 108 XTRACT_HERTZ = 2, 109 XTRACT_ANY_AMPLITUDE_HERTZ, 110 XTRACT_DBFS, 111 XTRACT_DBFS_HERTZ, 112 XTRACT_PERCENT, 113 XTRACT_SONE 114 } xtract_unit_t; 63 /** intermediate dct involved in aubio_mfcc_do 115 64 116 /** \brief Boolean */ 117 typedef enum { 118 XTRACT_FALSE, 119 XTRACT_TRUE 120 } xtract_bool_t; 65 \param mf mfcc object as returned by new_aubio_mfcc 66 \param in input spectrum (n_filters long) 67 \param out output mel coefficients buffer (n_filters/2 +1 long) 121 68 122 /** \brief Enumeration of vector format types*/ 123 typedef enum xtract_vector_ { 124 /* N/2 magnitude/log-magnitude/power/log-power coeffs and N/2 frequencies */ 125 XTRACT_SPECTRAL, 126 /* N spectral amplitudes */ 127 XTRACT_SPECTRAL_MAGNITUDES, 128 /* N/2 magnitude/log-magnitude/power/log-power peak coeffs and N/2 129 * frequencies */ 130 XTRACT_SPECTRAL_PEAKS, 131 /* N spectral peak amplitudes */ 132 XTRACT_SPECTRAL_PEAKS_MAGNITUDES, 133 /* N spectral peak frequencies */ 134 XTRACT_SPECTRAL_PEAKS_FREQUENCIES, 135 /* N/2 magnitude/log-magnitude/power/log-power harmonic peak coeffs and N/2 136 * frequencies */ 137 XTRACT_SPECTRAL_HARMONICS, 138 /* N spectral harmonic amplitudes */ 139 XTRACT_SPECTRAL_HARMONICS_MAGNITUDES, 140 /* N spectral harmonic frequencies */ 141 XTRACT_SPECTRAL_HARMONICS_FREQUENCIES, 142 XTRACT_ARBITRARY_SERIES, 143 XTRACT_AUDIO_SAMPLES, 144 XTRACT_MEL_COEFFS, 145 XTRACT_BARK_COEFFS, 146 XTRACT_NO_DATA 147 } xtract_vector_t; 148 149 150 151 152 // Computation 153 154 /** \brief Extract Mel Frequency Cepstral Coefficients based on a method described by Rabiner 155 * 156 * \param *data: a pointer to the first element in an array of spectral magnitudes, e.g. the first half of the array pointed to by *resul from xtract_spectrum() 157 * \param N: the number of array elements to be considered 158 * \param *argv: a pointer to a data structure of type xtract_mel_filter, containing n_filters coefficient tables to make up a mel-spaced filterbank 159 * \param *result: a pointer to an array containing the resultant MFCC 160 * 161 * The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc 162 */ 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); 166 167 /** \brief Extract the Discrete Cosine transform of a time domain signal 168 * \param *data: a pointer to the first element in an array of floats representing an audio vector 169 * \param N: the number of array elements to be considered 170 * \param *argv: a pointer to NULL 171 * \param *result: a pointer to an array containing resultant dct coefficients 172 */ 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); 69 */ 70 void aubio_dct_do(aubio_mfcc_t * mf, fvec_t *in, fvec_t *out); 174 71 175 72 #ifdef __cplusplus … … 177 74 #endif 178 75 179 #endif 76 #endif // MFCC_H
Note: See TracChangeset
for help on using the changeset viewer.