Tunable second-order parametric equalizer filter
The ParametricEQFilter object is a tunable, second-order parametric equalizer filter.
To apply the filter to each channel of the input:
H = dsp.ParametricEQFilter returns a second-order parametric equalizer filter that independently filters each channel of the input over time, using the default values for Bandwidth, CenterFrequency, and PeakGaindB. The center frequency and bandwidth are specified in Hz and are tunable. The peak gain (dip) is specified in dB and is also tunable. The bandwidth is measured at the arithmetic mean between the peak gain in absolute power units and one.
H = dsp.ParametricEQFilter('Specification', 'Quality factor and center frequency') specifies the quality factor (Q factor) of the filter. The Q factor is defined as the center frequency/bandwidth. A higher Q factor corresponds to a narrower peak/dip. The Q factor should be a scalar value greater than 0. The Q factor is tunable.
H = dsp.ParametricEQFilter('Specification', 'Coefficients') specifies the gain values for the bandwidth and center frequency. This removes the trigonometry calculations involved when the properties are tuned. The CenterFrequencyCoefficient should be a scalar between -1 and 1, with -1 corresponding to 0 Hz, and 1 corresponding to the Nyquist frequency. The BandwidthCoefficient should be a scalar between -1 and 1, with -1 corresponding to the largest bandwidth, and 1 corresponding to the smallest bandwidth. In this mode, the peak gain is specified in linear units rather than dB.
H = dsp.ParametricEQFilter('Name', Value, ...) returns a parametric equalizer filter with each specified property name set to the specified value. You can specify several name-value pair arguments in any order as ('Name1',Value1,...,'NameN',ValueN).
Design parameters or coefficients that specify the filter
Choose one of the following Specification values. Use the corresponding tunable properties to specify the filter:
The default value is Bandwidth and center frequency.
Using Coefficients specifies gain values for the bandwidth and center frequency. This approach does not require the trigonometric calculations of the other two approaches where design parameters are specified in Hz.
bandwidth of filter
Specify the filter's bandwidth as a finite positive numeric scalar, in Hz. This property is applicable if Specification is set to Bandwidth and center frequency. The default is 2205 Hz. This property is tunable.
Coefficient for bandwidth of filter
Specify the value that determines the filter's bandwidth as a finite numeric scalar between 0 and 1:
This property is only applicable if Specification is set to Coefficients. The default is 0.72654. This property is tunable.
Center frequency of filter peak or notch.
Specify the filter's center frequency for both peak and notch, as a finite positive numeric scalar, in Hz. This property is only applicable if Specification is set to Bandwidth and center frequency or Quality factor and center frequency. The default is 11,025 Hz. This property is tunable.
Coefficient for center frequency of filter
Specify the value that determines the filter's center frequency as a finite numeric scalar between -1 and 1:
This property is only applicable if Specification is set to Coefficients. The default is 0, which corresponds to SampleRate/4 Hz.
This property is tunable.
Peak or notch gain of filter in linear units
Specify the filter's peak or notch in linear units. A value greater than one boosts the signal. A value less than one attenuates the signal. The default is 2 (6.0206 dB). This property is tunable.
Peak or notch of filter in dB
Specify the filter's peak or notch in dB. A positive value boosts the signal. A negative value attenuates the signal. The default is 6.02036 dB. This property is tunable.
Q factor of peak or notch filter
Specify the Q factor for the peak or notch filter. The Q factor is defined as the center frequency divided by the bandwidth. A higher Q factor corresponds to a narrower peak or notch. This property is only applicable if Specification is set to Quality factor and center frequency. The default value is 5. This property is tunable.
Input sample rate
Specify the sample rate of the input as a finite numeric scalar, in Hz. The default is 44,100 Hz.
|clone||Create parametric equalizer filter object with same property values|
|getBandwidth||Convert quality factor or bandwidth coefficient to bandwidth in Hz|
|getCenterFrequency||Convert center frequency coefficient to frequency in Hz|
|getOctaveBandwidth||Measure bandwidth of parametric equalizer filter in octaves|
|getPeakGain||Convert peak or notch gain from dB to absolute units|
|getPeakGaindB||Convert peak or notch gain from absolute units to dB|
|getQualityFactor||Convert bandwidth to quality factor|
|isLocked||Locked status for input attributes and nontunable properties|
|release||Allow property value and input characteristics changes|
|reset||Reset states of ParametricEQFilter object|
|step||Filter input with ParametricEQFilter object|
|tf||Compute transfer function|
Create a ParametricEQFilter object where the center frequency and bandwidth of the equalizer filter are 5000 Hz and 500 Hz respectively. The sample rate for the filter is the default, 44,100 Hz.
h = dsp.ParametricEQFilter('CenterFrequency',5000,... 'Bandwidth',500);
Create objects to estimate and display the transfer function of the filter.
htf = dsp.TransferFunctionEstimator('FrequencyRange','onesided',... 'SpectralAverages',50); hplot = dsp.ArrayPlot('PlotType','Line','YLimits',[-15 15],... 'SampleIncrement',44100/1024);
Generate a random signal and filter the signal.
for i=1:1000 x = randn(1024,1); % Random signal y = step(h,x); % Filter signal H = step(htf,x,y); % Estimate transfer function magdB = 20*log10(abs(H));% Convert to dB step(hplot,magdB); % Display transfer function if (i==1) % Pause to display initial transfer function pause; end if (i==500) % Tune filter h.CenterFrequency = 10000; h.Bandwidth = 2000; h.PeakGaindB = -10; end end
The software displays the initial transfer function estimate.
To continue, press any key.
At i=500, the filter is tuned. The center frequency, bandwidth, and peak gain of the filter now have different values. The software displays the new transfer function.
The parametric equalizer is formed by a linear combination of a peak and a notch filter. See the Algorithm section of dsp.NotchPeakFilter for details.
Here is a graph of the two cases (boost and cut) of the magnitude squared of the transfer functions:
The transfer function can be written as:
G is the parametric equalizer gain, and GB is the bandwidth gain, that is, the gain level at which the bandwidth Δω is measured.
The dsp.NotchPeakFilter that does most of the work is implemented in a decoupled way so that the center frequency can be tuned independently from the bandwidth. Note that the Q factor is defined as center frequency/bandwidth.