Be the first to rate this file! 24 Downloads (last 30 days) File Size: 1.94 KB File ID: #23179

melfilter

by Pierce

 

04 Mar 2009 (Updated 15 Mar 2010)

generates a mel filter bank for a given frequency vector

| Watch this File

File Information
Description

% melfilter Create a mel frequency filterbank
%
% [Filter,MelFrequencyVector] = melfilter(N,FrequencyVector,hWindow)
%
% Generates a filter bank matrix with N lineary spaced filter banks,
% in the Mel frequency domain, that are overlapped by 50%.
%
% `N` the number of filter banks to construct.
%
% `FrequencyVector` a vector indicating the frequencies at which to
% evaluate the filter bank coeffiecents.
%
% `hWindow` a handle to the windowing function that determines the shape
% of the filterbank. The default is hWindow = @triang
%
% `Filter` is sparse matrix of size [N numel(FrequencyVector)].
%
% `MelFrequencyVector` is a vector containing the Mel frequency values
%
% Example
% N = 50;
% Fs = 10000;
% x = sin(2*pi*110*(0:(1/Fs):5));
% [Pxx,F] = periodogram(x,[],512,Fs);
%
% Filter = melfilter(N,F);
% Filter = melfilter(N,F,@rectwin);
% [Filter,MF] = melfilter(N,F,@blackmanharris);
%
% FPxx = Filter*Pxx;
%
% See also
% melfilter melbankm mfcceps hz2mel
%

Required Products Signal Processing Toolbox
MATLAB release MATLAB 7.5 (R2007b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
27 Feb 2010 Gökhan Vural

Hi Pierce.
I wanna use this filter for a wav file.. Could you write an example to show how to use your code ?
ie. melfilter (X , Y); ..

15 Mar 2010 Pierce

Hi gokan,
I have just uploaded a new version with an example. it should be availble in a day or two.

Example of how to use code

File = 'yourfile.wav'
N = 50; % 50 mel filter banks
% Read file
[X,Fs] = wavread(File);
% Compute power spectrum
[Pxx,F] = periodogram(x,[],512,Fs);
figure;
plot(F,Pxx)
% Create Mel filter bank
[fbMel,MF] = melfilter(N,F);
mPxx = fbMel*Pxx;
figure; plot(MF,mPxxl);

MFCC = dct(log10(mPxx))
figure;
plot(1:N,MFCC)

hope this helps

Please login to add a comment or rating.
Updates
15 Mar 2010

Updates
1) A third optional input to allow different window shapes.
2) Mel frequency vector can be returned.
3) Example added to help section

Tag Activity for this File
Tag Applied By Date/Time
mfcc Pierce 04 Mar 2009 14:40:53
mel frequency Pierce 04 Mar 2009 14:40:53
mel filter bank Pierce 04 Mar 2009 14:40:53
mfcc Aurobinda Routray 21 Jul 2010 05:40:35

Contact us at files@mathworks.com