annotate dsp/mfcc/MFCC.h @ 255:9edaa3ce62e8

* Make MFCC able to accept already-FFT'd input, and simplify API a bit * Add log power value to MFCC, restore windowing, and avoid some heap allocs * In HMM, bail out of iteration if loglik hits NaN
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 18 Jan 2008 13:24:12 +0000
parents c3600d3cfe5c
children 8bb764969d50
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@251 16 struct MFCCConfig {
c@251 17 int FS;
c@251 18 int fftsize;
c@251 19 int nceps;
c@255 20 double logpower;
c@251 21 bool want_c0;
c@255 22 MFCCConfig(int _FS) :
c@255 23 FS(_FS), fftsize(2048), nceps(19), logpower(1.0), want_c0(true) { }
c@251 24 };
c@251 25
c@251 26 class MFCC
c@251 27 {
c@251 28 public:
c@251 29 MFCC(MFCCConfig config);
c@251 30 virtual ~MFCC();
c@251 31
c@255 32 /**
c@255 33 * Process time-domain input data. inframe must contain
c@255 34 * getfftlength() samples. outceps must contain space for nceps
c@255 35 * values, plus one if want_c0 is specified.
c@255 36 */
c@255 37 int process(const double *inframe, double *outceps);
c@255 38
c@255 39 /**
c@255 40 * Process time-domain input data. real and imag must contain
c@255 41 * getfftlength()/2+1 elements (i.e. the conjugate half of the FFT
c@255 42 * is not expected). outceps must contain space for nceps values,
c@255 43 * plus one if want_c0 is specified.
c@255 44 */
c@255 45 int process(const double *real, const double *imag, double *outceps);
c@251 46
c@251 47 int getfftlength() const { return fftSize; }
c@251 48
c@251 49 private:
c@251 50 /* Filter bank parameters */
c@251 51 double lowestFrequency;
c@251 52 int linearFilters;
c@251 53 double linearSpacing;
c@251 54 int logFilters;
c@251 55 double logSpacing;
c@251 56
c@251 57 /* FFT length */
c@251 58 int fftSize;
c@251 59
c@251 60 int totalFilters;
c@255 61 double logPower;
c@251 62
c@251 63 /* Misc. */
c@251 64 int samplingRate;
c@251 65 int nceps;
c@251 66
c@251 67 /* MFCC vector */
c@251 68 double *ceps;
c@251 69
c@251 70 double **mfccDCTMatrix;
c@251 71 double **mfccFilterWeights;
c@251 72
c@251 73 /* The analysis window */
c@251 74 Window<double> *window;
c@251 75
c@251 76 /* For the FFT */
c@255 77 double *imagIn; // always zero
c@255 78 double *realOut;
c@255 79 double *imagOut;
c@255 80 double *fftMag;
c@255 81 double *earMag;
c@255 82
c@251 83 /* Set if user want C0 */
c@251 84 int WANT_C0;
c@251 85 };
c@251 86
c@250 87
c@250 88 #endif
c@250 89