comparison dsp/mfcc/MFCC.h @ 251:c3600d3cfe5c

* Add timbral (MFCC) feature option to segmenter
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 10 Jan 2008 16:41:33 +0000
parents a106e551e9a4
children a251fb0de594
comparison
equal deleted inserted replaced
250:a106e551e9a4 251:c3600d3cfe5c
1 #ifndef _LIB_MFCC_H 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 #define _LIB_MFCC_H
3 2
4 #define MFCC 6 3 /*
4 QM DSP Library
5 5
6 typedef struct mfcc_t { 6 Centre for Digital Music, Queen Mary, University of London.
7 7 This file copyright 2005 Nicolas Chetry, copyright 2008 QMUL.
8 /* Filter bank parameters */ 8 All rights reserved.
9 double lowestFrequency; 9 */
10 int linearFilters;
11 double linearSpacing;
12 int logFilters;
13 double logSpacing;
14
15 /* FFT length */
16 int fftSize;
17
18 /* Analysis window length*/
19 int windowSize;
20
21 int totalFilters;
22
23 /* Misc. */
24 int samplingRate;
25 int nceps;
26
27 /* MFCC vector */
28 double *ceps;
29
30 double **mfccDCTMatrix;
31 double **mfccFilterWeights;
32
33 /* The analysis window */
34 double *window;
35
36 /* For the FFT */
37 double* imagIn; // always zero
38 double* realOut;
39 double* imagOut;
40
41 /* Set if user want C0 */
42 int WANT_C0;
43
44 } mfcc_t;
45 10
46 extern mfcc_t* init_mfcc(int fftSize, int nceps , int samplingRate, int WANT_C0); 11 #ifndef MFCC_H
47 extern int do_mfcc(mfcc_t* mfcc_p, double* frame, int length); 12 #define MFCC_H
48 extern void close_mfcc(mfcc_t* mfcc_p); 13
14 #include "base/Window.h"
15
16 struct MFCCConfig {
17 int FS;
18 int fftsize;
19 int nceps;
20 bool want_c0;
21 };
22
23 class MFCC
24 {
25 public:
26 MFCC(MFCCConfig config);
27 virtual ~MFCC();
28
29 int process(int length, double *inframe, double *outceps);
30
31 int getfftlength() const { return fftSize; }
32
33 private:
34 /* Filter bank parameters */
35 double lowestFrequency;
36 int linearFilters;
37 double linearSpacing;
38 int logFilters;
39 double logSpacing;
40
41 /* FFT length */
42 int fftSize;
43
44 int totalFilters;
45
46 /* Misc. */
47 int samplingRate;
48 int nceps;
49
50 /* MFCC vector */
51 double *ceps;
52
53 double **mfccDCTMatrix;
54 double **mfccFilterWeights;
55
56 /* The analysis window */
57 Window<double> *window;
58
59 /* For the FFT */
60 double* imagIn; // always zero
61 double* realOut;
62 double* imagOut;
63
64 /* Set if user want C0 */
65 int WANT_C0;
66 };
67
49 68
50 #endif 69 #endif
51 70