Home > ACA-Code > FeatureSpectralMfccs.m

FeatureSpectralMfccs

PURPOSE ^

computes the MFCCs from the magnitude spectrum (see Slaney)

SYNOPSIS ^

function [vmfcc] = FeatureSpectralMfccs(X, f_s)

DESCRIPTION ^

computes the MFCCs from the magnitude spectrum (see Slaney)
> called by ::ComputeFeature
>
> @param X: spectrogram (dimension FFTLength X Observations)
> @param f_s: sample rate of audio data (unused)
>
> @retval vmfcc mel frequency cepstral coefficients
 ======================================================================

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 %computes the MFCCs from the magnitude spectrum (see Slaney)
0002 %> called by ::ComputeFeature
0003 %>
0004 %> @param X: spectrogram (dimension FFTLength X Observations)
0005 %> @param f_s: sample rate of audio data (unused)
0006 %>
0007 %> @retval vmfcc mel frequency cepstral coefficients
0008 % ======================================================================
0009 function [vmfcc] = FeatureSpectralMfccs(X, f_s)
0010 
0011     iNumCoeffs = 13;
0012     
0013     % allocate memory
0014     vmfcc = zeros(iNumCoeffs, size(X, 2));
0015 
0016     % create filters
0017     H = ToolMfccFb(size(X, 1), f_s);
0018     
0019     % create transformation matrix
0020     T = GenerateDctMatrix_I (size(H, 1), iNumCoeffs);
0021  
0022     for n = 1:size(X,2)
0023         % compute the mel spectrum
0024         X_Mel = log10(H * X(:, n) + 1e-20);
0025 
0026         % calculate the mfccs
0027         vmfcc(:, n) = T * X_Mel;
0028     end
0029 end
0030 
0031 
0032 %> see function mfcc.m from Slaneys Auditory Toolbox
0033 function [T] = GenerateDctMatrix_I (iNumBands, iNumCepstralCoeffs)
0034     T = cos((0:(iNumCepstralCoeffs-1))' * ...
0035             (2*(0:(iNumBands-1))+1) * pi/2/iNumBands);
0036             
0037     T  = T/sqrt(iNumBands/2);
0038     T(1, :)  = T(1, :) * sqrt(2)/2;
0039 end

Generated on Fri 22-Apr-2022 20:59:51 by m2html © 2005