| 1 |
#ifndef _MFCC_h_ |
| 2 |
#define _MFCC_h_ |
| 3 |
/* MFCC.h |
| 4 |
* |
| 5 |
* Mel Frequency Cepstral Coefficients class. |
| 6 |
* |
| 7 |
* Copyright (C) 1993-2017 David Weenink |
| 8 |
* |
| 9 |
* This code is free software; you can redistribute it and/or modify |
| 10 |
* it under the terms of the GNU General Public License as published by |
| 11 |
* the Free Software Foundation; either version 2 of the License, or (at |
| 12 |
* your option) any later version. |
| 13 |
* |
| 14 |
* This code is distributed in the hope that it will be useful, but |
| 15 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 |
* General Public License for more details. |
| 18 |
* |
| 19 |
* You should have received a copy of the GNU General Public License |
| 20 |
* along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 21 |
*/ |
| 22 |
|
| 23 |
/* |
| 24 |
djmw 20010501 |
| 25 |
djmw 20020813 GPL header |
| 26 |
djmw 20120504 Latest modification. |
| 27 |
*/ |
| 28 |
|
| 29 |
#include "CC.h" |
| 30 |
#include "Sound.h" |
| 31 |
#include "TableOfReal.h" |
| 32 |
|
| 33 |
Thing_define (MFCC, CC) { |
| 34 |
void v1_info () |
| 35 |
override; |
| 36 |
}; |
| 37 |
|
| 38 |
/* |
| 39 |
Three slightly "different" definitions of MFCC |
| 40 |
1. Davis & Mermelstein |
| 41 |
MFCC [i] = SUM (j=1..N, f [j] * cos (i(j-1/2)pi/N)), i = 1..N-1 |
| 42 |
2. Vergin & O'Shaughnessy |
| 43 |
MFCC [i] = SUM (j=0..N-1, f [j] * cos (i(j+1/2)pi/N)), i = 0..N-1 |
| 44 |
3. HTK-book |
| 45 |
MFCC [i] = sqrt(2/n) SUM (j=1..N, f [j] * cos (i(j-1/2)pi/N)), i = 0..N-1 |
| 46 |
|
| 47 |
The f [j]'s are the MelSpectrogram values converted to dB. |
| 48 |
We follow the definition of Davis and Mermelstein: |
| 49 |
MFCC [i] = SUM (j=1..N, f [j] * cos (i(j-1/2)pi/N)), i=1..N-1, |
| 50 |
*/ |
| 51 |
|
| 52 |
/* |
| 53 |
Interpretation: |
| 54 |
Mel frequency cepstral coefficient vectors as a function of time. |
| 55 |
c0 represents the sum of the dB filter outputs. |
| 56 |
*/ |
| 57 |
|
| 58 |
autoMFCC MFCC_create (double tmin, double tmax, integer nt, double dt, double t1, integer maximumNumberOfCoefficients, double fmin_mel, double fmax_mel); |
| 59 |
|
| 60 |
void MFCC_lifter (MFCC me, integer lifter); |
| 61 |
/* |
| 62 |
Lifter the cepstral coefficients: |
| 63 |
c [i] *= (1 + lifter / 2 * sin (NUMpi * i / lifter)) |
| 64 |
*/ |
| 65 |
|
| 66 |
autoTableOfReal MFCC_to_TableOfReal (MFCC me, bool includeC0); |
| 67 |
|
| 68 |
autoSound MFCC_to_Sound (MFCC me); |
| 69 |
|
| 70 |
autoSound MFCCs_crossCorrelate (MFCC me, MFCC thee, enum kSounds_convolve_scaling scaling, enum kSounds_convolve_signalOutsideTimeDomain signalOutsideTimeDomain); |
| 71 |
|
| 72 |
autoSound MFCCs_convolve (MFCC me, MFCC thee, enum kSounds_convolve_scaling scaling, enum kSounds_convolve_signalOutsideTimeDomain signalOutsideTimeDomain); |
| 73 |
|
| 74 |
autoMatrix MFCC_to_Matrix_features (MFCC me, double windowLength, bool includeEnergy); |
| 75 |
|
| 76 |
#endif /* _MFCC_h_ */ |