Octave and fractional-octave filter bank
octaveFilterBank decomposes a signal into octave or fractional-octave
subbands. An octave band is a frequency band where the highest frequency is twice the lowest
frequency. Octave-band and fractional octave-band filters are commonly used to mimic how
humans perceive loudness.
To apply a bank of octave-band or fractional octave-band filters:
octaveFilterBankobject and set its properties.
Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?
octave filter bank. The objects filters data independently across each input channel over
octFiltBank = octaveFilterBank
octFiltBank = octaveFilterBank(
Bandwidth property to
octFiltBank = octaveFilterBank(
SampleRate property to
sets each property
octFiltBank = octaveFilterBank(___,
Name to the specified
Unspecified properties have default values.
octFiltBank = octaveFilterBank('1/2
octave','FrequencyRange',[62.5,12000]) creates a ½ octave-band filter bank,
octFiltBank, with bandpass filters placed between 62.5 Hz and 12,000
Unless otherwise indicated, properties are nontunable, which means you cannot change their
values after calling the object. Objects lock when you call them, and the
release function unlocks them.
If a property is tunable, you can change its value at any time.
For more information on changing property values, see System Design in MATLAB Using System Objects.
Bandwidth — Filter bandwidth (octave)
'1 octave' (default) |
'2/3 octave' |
'1/2 octave' |
'1/3 octave' |
'1/6 octave' |
'1/12 octave' |
'1/24 octave' |
Filter bandwidth in octaves, specified as
'1/24 octave', or
SampleRate — Input sample rate (Hz)
44100 (default) | positive scalar
Input sample rate in Hz, specified as a positive scalar.
FrequencyRange — Frequency range of filter bank (Hz)
[22 22050] (default) | two-element row vector of positive monotonically increasing values
Frequency range of the filter bank in Hz, specified as a two-element row vector of
positive monotonically increasing values. The filter bank center frequencies are placed
according to the
properties. Filters that have a center frequency outside
FrequencyRange are ignored.
ReferenceFrequency — Reference frequency (Hz)
1000 (default) | positive integer scalar
Reference frequency of the filter bank in Hz, specified as a positive integer scalar. The reference frequency defines one of the center frequencies. All other center frequencies are set relative to the reference frequency.
FilterOrder — Order of octave filters
2 (default) | even integer
Order of the octave filters, specified as an even integer. The filter order applies to each individual filter in the filter bank.
OctaveRatioBase — Octave ratio base
10 (default) |
Octave ratio base, specified as
octave ratio base determines the distribution of the center frequencies of the octave
filters. The ANSI S1.11 standard recommends base 10. Base 2 is popular for music
applications. Base 2 defines an octave as a factor of 2, and base 10 defines an octave
as a factor of 100.3.
audioIn — Audio input to octave filter bank
scalar | vector | matrix
Audio input to the octave filter bank, specified as a scalar, vector, or matrix. If specified as a matrix, the columns are treated as independent audio channels.
audioOut — Audio output from octave filter bank
matrix | 3-D array
Audio output from octave filter bank, returned as a scalar, vector, matrix, or 3-D
array. The shape of
audioOut depends on the shape of
audioIn and the number of filters in the filter bank. If
M is the number of filters, and
an L-by-N matrix, then
audioOut is returned as an
L-by-M-by-N array. If
N is 1, then
audioOut is a matrix.
To use an object function, specify the
System object™ as the first input argument. For
example, to release system resources of a System object named
|Get filter coefficients|
|Compute frequency response|
|Visualize filter bank|
|Get filter bandedges|
|Center frequencies of filters|
|Get group delays|
|Get filter information|
|Verify octave filter bank is ANSI S1.11-2004 compliant|
Apply Octave Filter Bank
Create a 1/3-octave filter bank for a signal sampled at 48 kHz. Set the frequency range to
[18 22000] Hz.
octFilBank = octaveFilterBank('1/3 octave',48000, ... 'FrequencyRange',[18 22000]);
fvtool to visualize the response of the filter bank. To get a high-resolution view on the lower frequencies, set the scale of the x-axis to
fvt = fvtool(octFilBank,'NFFT',2^16); set(fvt,'FrequencyScale','log') zoom(fvt,[.01 24 -20 1])
Display the filter bank center frequencies.
fc = getCenterFrequencies(octFilBank); cf = string(size(fc)); for ii = find(fc<1000) cf(ii) = sprintf("%.0f Hz",round(fc(ii),2,"significant")); end for ii = find(fc>=1000) cf(ii) = sprintf("%.1f kHz",fc(ii)/1000); end disp(cf)
Columns 1 through 7 "20 Hz" "25 Hz" "32 Hz" "40 Hz" "50 Hz" "63 Hz" "79 Hz" Columns 8 through 13 "100 Hz" "130 Hz" "160 Hz" "200 Hz" "250 Hz" "320 Hz" Columns 14 through 19 "400 Hz" "500 Hz" "630 Hz" "790 Hz" "1.0 kHz" "1.3 kHz" Columns 20 through 25 "1.6 kHz" "2.0 kHz" "2.5 kHz" "3.2 kHz" "4.0 kHz" "5.0 kHz" Columns 26 through 30 "6.3 kHz" "7.9 kHz" "10.0 kHz" "12.6 kHz" "15.8 kHz" Column 31 "20.0 kHz"
Process white Gaussian noise through the filter bank. Use a spectrum analyzer to view the spectrum of the filter outputs.
sa = dsp.SpectrumAnalyzer('SampleRate',16e3,... 'PlotAsTwoSidedSpectrum',false,... 'FrequencyScale','log',... 'SpectralAverages',100); for index = 1:500 x = randn(256,1); y = octFilBank(x); sa(y); end
Analysis and Synthesis
octaveFilterBank enables good reconstruction of a signal after analyzing or modifying its subbands.
Read in an audio file and listen to its contents.
[audioIn,fs] = audioread('RandomOscThree-24-96-stereo-13secs.aif'); sound(audioIn,fs)
Create a default
octaveFilterBank. The default frequency range of the filter bank is 22 to 22,050 Hz. Frequencies outside of this range are attenuated in the reconstructed signal.
octFiltBank = octaveFilterBank('SampleRate',fs);
Pass the audio signal through the octave filter bank. The number of outputs depends on the
Bandwidth properties of the octave filter bank. Each channel of the input is passed through a filter bank independently and is returned as a separate page in the output.
audioOut = octFiltBank(audioIn); [N,numFilters,numChannels] = size(audioOut)
N = 1265935
numFilters = 10
numChannels = 2
The octave filter bank introduces various group delays. To compensate for the group delay, remove the beginning delay from the individual filter outputs and zero-pad the ends of the signals so that they are all the same size. Use
getGroupDelays to get the group delays. Listen to the group delay-compensated reconstruction.
groupDelay = round(getGroupDelays(octFiltBank)); % round for simplicity audioPadded = [audioOut;zeros(max(groupDelay),numFilters,numChannels)]; for i = 1:numFilters audioOut(:,i,:) = audioPadded(groupDelay(i)+1:N+groupDelay(i),i,:); end
To reconstruct the original signal, sum the outputs of the filter banks for each channel. Use
squeeze to move the second channel from the third dimension to the second in the reconstructed signal.
reconstructedSignal = squeeze(sum(audioOut,2)); sound(reconstructedSignal,fs)
octaveFilterBank is implemented as a parallel structure of octave
filters. Individual octave filters are designed as described by
octaveFilter. By default, the octave filter bank center frequencies are placed as
specified by the ANSI S1.11-2004 standard. You can modify the filter placements using the
 Orfanidis, Sophocles J. Introduction to Signal Processing. Englewood Cliffs, NJ: Prentice Hall, 2010.
 Acoustical Society of America. American National Standard Specification for Octave-Band and Fractional-Octave-Band Analog and Digital Filters. ANSI S1.11-2004. Melville, NY: Acoustical Society of America, 2009.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
System Objects in MATLAB Code Generation (MATLAB Coder)