octaveFilterBank

Octave and fractional-octave filter bank

Description

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:

  1. Create the octaveFilterBank object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects? (MATLAB).

Creation

Description

octFiltBank = octaveFilterBank returns an octave filter bank. The objects filters data independently across each input channel over time.

octFiltBank = octaveFilterBank(bandwidth) sets the Bandwidth property to bandwidth.

octFiltBank = octaveFilterBank(bandwidth,fs) sets the SampleRate property to fs.

octFiltBank = octaveFilterBank(___,Name,Value) sets each property Name to the specified Value. Unspecified properties have default values.

Example: 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 Hz.

Properties

expand all

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 (MATLAB).

Filter bandwidth in octaves, specified as '1 octave', '2/3 octave', '1/2 octave', '1/3 octave', '1/6 octave', '1/12 octave', '1/24 octave', or '1/48 octave'.

Tunable: No

Data Types: char | string

Input sample rate in Hz, specified as a positive scalar.

Tunable: Yes

Data Types: single | double

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 Bandwidth, RefererenceFrequency, and OctaveRatioBase properties. Filters that have a center frequency outside FrequencyRange are ignored.

Tunable: No

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

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.

Tunable: No

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Order of the octave filters, specified as an even integer. The filter order applies to each individual filter in the filter bank.

Tunable: No

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Octave ratio base, specified as 10 or 2. The 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.

Tunable: No

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Usage

Description

example

audioOut = octFiltBank(audioIn) applies the octave filter bank on the input and returns the filtered output.

Input Arguments

expand all

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.

Data Types: single | double

Output Arguments

expand all

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 audioIn is 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.

Data Types: single | double

Object Functions

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 obj, use this syntax:

release(obj)

expand all

coeffsGet filter coefficients
freqzCompute frequency response
fvtoolVisualize filter bank
getBandedgeFrequenciesGet filter bandedges
getCenterFrequenciesCenter frequencies of filters
getGroupDelaysGet group delays
infoGet filter information
stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

expand all

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]);

Use 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 log and NFFT to 2^16. Add a legend indicating the filter bank center frequencies.

fvtool(octFilBank,'NFFT',2^16);
set(gca,'XScale','log')
axis([.01 24 -20 1])

fc = getCenterFrequencies(octFilBank);
fcc = cell(size(fc));
for ii = find(fc<1000)
    fcc{ii} = sprintf('%.0f',round(fc(ii),2,'significant'));
end
for ii = find(fc>=1000)
    fcc{ii} = sprintf('%.1fk',fc(ii)/1000);
end
legend(fcc,'Location','eastoutside')

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

The 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 FrequencyRange, ReferenceFrequency, OctaveRatioBase, and 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)

Algorithms

The 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 Bandwidth, FrequencyRange, ReferenceFrequency, and OctaveRatioBase properties.

References

[1] Orfanidis, Sophocles J. Introduction to Signal Processing. Englewood Cliffs, NJ: Prentice Hall, 2010.

[2] 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.

Extended Capabilities

Introduced in R2019a