This page includes MATLAB functions and scripts that I have written and used for experimenting with audio signal processing.
Biquadratic Filter Design
Usage: [b,a]=order2filter(type,fs,G,f0,Q)
Input:
Output:
Description:
Determines the numerator and denominator coefficients of three types of biquadratic filters based on desired values of gain, center or corner frequency, and Q factor. The three types are:
For each type, the function first determines the numerator and denominator coefficients of the corresponding analog filter based on well-known, straightforward formulas. For gain < 0 dB the function uses the corresponding positive gain and flips numerator and denominator to enforce symmetry. The function then computes the digital filter coefficients using the MATLAB function bilinear. For more information, click here.
The figures below show the frequency response curves for examples of the three filter types.
Source file for order2filter: order2filter.m
Usage: [b,a]=order2filter(type,fs,G,f0,Q)
Input:
- type - filter type - 'Bass' for bass shelf, 'Peak' for peak and 'Treble' for treble shelf
- fs - sampling frequency in Hz
- G - gain in dB
- f0 - center or corner frequency in Hz
- Q - Q factor (related to bandwidth)
Output:
- b - numerator coefficients
- a - denominator coefficients
Description:
Determines the numerator and denominator coefficients of three types of biquadratic filters based on desired values of gain, center or corner frequency, and Q factor. The three types are:
- 'Bass' - bass shelf filter with low-frequency gain G and corner frequency f0
- 'Peak' - peak filter with center-frequency gain G, center frequency f0
- 'Treble' - treble shelf filter with high-frequency gain G and corner frequency f0
For each type, the function first determines the numerator and denominator coefficients of the corresponding analog filter based on well-known, straightforward formulas. For gain < 0 dB the function uses the corresponding positive gain and flips numerator and denominator to enforce symmetry. The function then computes the digital filter coefficients using the MATLAB function bilinear. For more information, click here.
The figures below show the frequency response curves for examples of the three filter types.
Source file for order2filter: order2filter.m
Parametric Equalizer Script
This script uses MATLAB streaming audio tools to read an audio file, process the audio through a parametric equalizer and play the processed audio while displaying a plot of the magnitude of the equalizer frequency response. The script also provides a GUI with sliders to tune the equalizer parameters.
The script consists of an initialization section, a processing loop and a clean-up section as follows:
Initialization section
Processing loop
Clean-up
Source file for parametric equalizer: /uploads/3/4/7/2/34726384/rteq.m
This script uses MATLAB streaming audio tools to read an audio file, process the audio through a parametric equalizer and play the processed audio while displaying a plot of the magnitude of the equalizer frequency response. The script also provides a GUI with sliders to tune the equalizer parameters.
The script consists of an initialization section, a processing loop and a clean-up section as follows:
Initialization section
- Create an audio file reader object, a biquadratic filter object and an audio player object using functions from the MATLAB DSP system toolbox.
- Initialize the parameter tuning GUI and the frequency response display.
Processing loop
- Check for new tuning parameters and update filter parameters and frequency response display with new parameters.
- Read a block of audio, process it through the filter and play the filter output.
Clean-up
- Delete objects and close GUI and display.
Source file for parametric equalizer: /uploads/3/4/7/2/34726384/rteq.m