annotate dsp/mfcc/MFCC.h @ 298:255e431ae3d4

* Key detector: when returning key strengths, use the peak value of the three underlying chromagram correlations (from 36-bin chromagram) corresponding to each key, instead of the mean. Rationale: This is the same method as used when returning the key value, and it's nice to have the same results in both returned value and plot. The peak performed better than the sum with a simple test set of triads, so it seems reasonable to change the plot to match the key output rather than the other way around. * FFT: kiss_fftr returns only the non-conjugate bins, synthesise the rest rather than leaving them (perhaps dangerously) undefined. Fixes an uninitialised data error in chromagram that could cause garbage results from key detector. * Constant Q: remove precalculated values again, I reckon they're not proving such a good tradeoff.
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 05 Jun 2009 15:12:39 +0000
parents befe5aa6b450
children e5907ae6de17
rev   line source
c@251 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
c@250 2
c@251 3 /*
c@251 4 QM DSP Library
c@250 5
c@251 6 Centre for Digital Music, Queen Mary, University of London.
c@251 7 This file copyright 2005 Nicolas Chetry, copyright 2008 QMUL.
c@251 8 All rights reserved.
c@251 9 */
c@250 10
c@251 11 #ifndef MFCC_H
c@251 12 #define MFCC_H
c@251 13
c@251 14 #include "base/Window.h"
c@251 15
c@289 16 class FFTReal;
c@289 17
c@251 18 struct MFCCConfig {
c@251 19 int FS;
c@251 20 int fftsize;
c@251 21 int nceps;
c@255 22 double logpower;
c@251 23 bool want_c0;
c@257 24 WindowType window;
c@255 25 MFCCConfig(int _FS) :
c@257 26 FS(_FS), fftsize(2048), nceps(19),
c@257 27 logpower(1.0), want_c0(true), window(HammingWindow) { }
c@251 28 };
c@251 29
c@251 30 class MFCC
c@251 31 {
c@251 32 public:
c@251 33 MFCC(MFCCConfig config);
c@251 34 virtual ~MFCC();
c@251 35
c@255 36 /**
c@255 37 * Process time-domain input data. inframe must contain
c@255 38 * getfftlength() samples. outceps must contain space for nceps
c@255 39 * values, plus one if want_c0 is specified.
c@255 40 */
c@255 41 int process(const double *inframe, double *outceps);
c@255 42
c@255 43 /**
c@255 44 * Process time-domain input data. real and imag must contain
c@255 45 * getfftlength()/2+1 elements (i.e. the conjugate half of the FFT
c@255 46 * is not expected). outceps must contain space for nceps values,
c@255 47 * plus one if want_c0 is specified.
c@255 48 */
c@255 49 int process(const double *real, const double *imag, double *outceps);
c@251 50
c@251 51 int getfftlength() const { return fftSize; }
c@251 52
c@251 53 private:
c@251 54 /* Filter bank parameters */
c@251 55 double lowestFrequency;
c@251 56 int linearFilters;
c@251 57 double linearSpacing;
c@251 58 int logFilters;
c@251 59 double logSpacing;
c@251 60
c@251 61 /* FFT length */
c@251 62 int fftSize;
c@251 63
c@251 64 int totalFilters;
c@255 65 double logPower;
c@251 66
c@251 67 /* Misc. */
c@251 68 int samplingRate;
c@251 69 int nceps;
c@251 70
c@251 71 /* MFCC vector */
c@251 72 double *ceps;
c@251 73
c@251 74 double **mfccDCTMatrix;
c@251 75 double **mfccFilterWeights;
c@251 76
c@251 77 /* The analysis window */
c@251 78 Window<double> *window;
c@251 79
c@251 80 /* For the FFT */
c@255 81 double *realOut;
c@255 82 double *imagOut;
c@255 83 double *fftMag;
c@255 84 double *earMag;
c@289 85 FFTReal *fft;
c@255 86
c@251 87 /* Set if user want C0 */
c@251 88 int WANT_C0;
c@251 89 };
c@251 90
c@250 91
c@250 92 #endif
c@250 93