File Exchange

image thumbnail

Triangular Filterbank

version 1.1 (2.59 KB) by

Frequency domain triangular filterbank with uniform spacing on arbitrarily warped frequency scale.



View License

Implements triangular filterbank given in [1]. Returns matrix of M triangular filters (one per row), each K coefficients long. The triangular filters are between limits given in R (Hz) and are uniformly spaced on a warped scale defined by forward (h2w) and backward (w2h) warping functions. For example, h2w and w2h can be hz2mel and mel2hz functions, respectively, in which case trifbank returns a mel filterbank, i.e., a filterbank of triangular filters uniformly spaced on the mel scale. Other forward and backward warping functions can be specified to arrive at arbitrary warped triangular filterbanks.

[1] Huang, X., Acero, A., Hon, H., 2001. Spoken Language Processing: A guide to theory, algorithm, and system development. Prentice Hall, Upper Saddle River, NJ, USA (pp. 314-315).

Comments and Ratings (5)

Tom Anderson

Just a comment for Yibo Yang, if you look at the graphs above you will see that there are 50% overlaps in the mel-scale. That's standard for MFCCs.

Yibo Yang

Quick question Kamil: how can I tweak the trifbank code so that I can generate triangular filters with, say, 50% overlaps in the mel scale?
Thanks for your work!

hello, thank you for the source code ... I did not understand why you used K = nfft/2+1; and f_max = 0.5*fs; ????

Kamil Wojcicki

Kamil Wojcicki (view profile)

If all you want is a warping other than the mel scale, then the function is written to support that, i.e., no need to change trifbank.m. I would just pass different warping / unwarping functions to it:

- in MATLAB type in: help trifbank

- then try the example given there ( it will poduce a mel filterbank ), e.g.:

   fs = 16000; % sampling frequency (Hz)
   nfft = 2^12; % fft size (number of frequency bins)
   K = nfft/2+1; % length of each filter
   M = 23; % number of filters

   hz2mel = @(hz)(1127*log(1+hz/700)); % Hertz to mel warping
   mel2hz = @(mel)(700*exp(mel/1127)-700); % mel to Hertz warping

   % Design mel filterbank of M filters each K coefficients long,
   % filters are uniformly spaced on the mel scale between 0 and Fs/2
   [ H1, freq ] = trifbank( M, K, [0 fs/2], fs, hz2mel, mel2hz );

   hfig = figure('Position', [25 100 800 600], 'PaperPositionMode', ...
                 'auto', 'Visible', 'on', 'color', 'w'); hold on;

   plot( freq, H1 );
   xlabel( 'Frequency (Hz)' ); ylabel( 'Weight' ); set( gca, 'box', 'off');

- in the above code, the warping function are defined in following variables:

   hz2mel = @(hz)(1127*log(1+hz/700)); % Hertz to mel warping
   mel2hz = @(mel)(700*exp(mel/1127)-700); % mel to Hertz warping

- to use different warping functions you first have to define these, e.g., if you want uniformly spaced filters on Hz scale use:

   hz2warp = @(hz)( hz );
   warp2hz = @(warp)( warp );

- and make sure you then update the trifbank call with the new function handles:

   [ H1, freq ] = trifbank( M, K, [0 fs/2], fs, hz2warp, warp2hz );

can you help me how to implement any arbitray warping function using trifbank?. I want to implement vocal tract length normalization.

thanks in advance,



Trifbank now returns filter cutoff / center frequencies. In-file comments have been updated.

MATLAB Release
MATLAB 7.10 (R2010a)


Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video