//compute mag spectrum
aubio_pvoc_do (pv,ibuf, fftgrain);
- //TODO: extract Magnitude buffer f_fvec from fftgrain cvec
-
- //compute mfccs
- aubio_mffc_do (magbuf, nframes, filterbank, outbuf);
+
+ //compute mfcics
+ aubio_mffc_do(fftgrain->norm, nframes, filterbank, outbuf);
int main(int argc, char **argv) {
examples_common_init(argc,argv);
+
+ //allocate and initialize mel filter bank
+ uint_t n_filters=20;
+ uint_t nyquist= samplerate / 2.;
+
+ uint_t banksize = (uint) ( sizeof(aubio_mel_filter));
+ aubio_mel_filter * mf = (aubio_mel_filter *)getbytes(banksize);
+
+ mfilterbank->n_filters = 20;
+ mfilterbank->filters = (smpl_t **)getbytes(mf->n_filters * sizeof(smpl_t *));
+ for(n = 0; n < mf->n_filters; n++)
+ mf->filters[n] = (smpl_t *)getbytes((buffer_size/2+1) * sizeof(smpl_t));
+
+ //populating the filter
+ new_aubio_mfcc(buffer_size, nyquist, XTRACT_EQUAL_GAIN, 80.0f, 18000.0f, mf->n_filters, mf->filters);
+
+ //process
examples_common_process(aubio_process,process_print);
examples_common_del();
debug("End of program.\n");
fflush(stderr);
+
+ //destroying filterbank
+ free(mf);
+
return 0;
}
#include "beattracking.h"
#include "onset.h"
#include "tempo.h"
+#include "mfcc.h"
#ifdef __cplusplus
} /* extern "C" */
// Initialization
-int aubio_mfcc_init(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, float **fft_tables){
+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){
int n, i, k, *fft_peak, M, next_peak;
- float norm, mel_freq_max, mel_freq_min, norm_fact, height, inc, val,
+ smpl_t norm, mel_freq_max, mel_freq_min, norm_fact, height, inc, val,
freq_bw_mel, *mel_peak, *height_norm, *lin_peak;
mel_peak = height_norm = lin_peak = NULL;
mel_freq_min = 1127 * log(1 + freq_min / 700);
freq_bw_mel = (mel_freq_max - mel_freq_min) / freq_bands;
- mel_peak = (float *)malloc((freq_bands + 2) * sizeof(float));
+ mel_peak = (smpl_t *)malloc((freq_bands + 2) * sizeof(smpl_t));
/* +2 for zeros at start and end */
- lin_peak = (float *)malloc((freq_bands + 2) * sizeof(float));
+ lin_peak = (smpl_t *)malloc((freq_bands + 2) * sizeof(smpl_t));
fft_peak = (int *)malloc((freq_bands + 2) * sizeof(int));
- height_norm = (float *)malloc(freq_bands * sizeof(float));
+ height_norm = (smpl_t *)malloc(freq_bands * sizeof(smpl_t));
if(mel_peak == NULL || height_norm == NULL ||
lin_peak == NULL || fft_peak == NULL)
return XTRACT_SUCCESS;
-}
\ No newline at end of file
+}
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
*/
#ifndef AUBIOFILTERBANK_H
-#include AUBIOFILTERBANK_H
+#define AUBIOFILTERBANK_H
-#define NYQUIST 22050.f
// Struct Declaration
/** \brief A structure to store a set of n_filters Mel filters */
typedef struct aubio_mel_filter_ {
int n_filters;
- float **filters;
+ smpl_t **filters;
} aubio_mel_filter;
// Initialization
*
* 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
*/
-int aubio_mfcc_init(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, float **fft_tables);
+int aubio_mfcc_init(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, smpl_t ** fft_tables);
-#endif
\ No newline at end of file
+#endif
#ifndef MFCC_H
#define MFCC_H
+#include "aubiofilterbank.h"
+
#define NYQUIST 22050.f
//libXtract enums
int aubio_dct_do(const float *data, const int N, const void *argv, float *result);
-#endif
\ No newline at end of file
+#endif