VolumeControlHP
Overview
Volume control with Fletcher-Munson loudness compensation using High Precision implementation
Discussion
Volume control subsystem with built in loudness compensation. The system has one multichannel input pin and one multichannel output pin. Input and output pins must have the same dimensions.
The system consists of a biquad_smoothed_module plus algorithms for dynamically adjusting the biquad coefficients. System has one interface variable: SYS.gain with a range of 0 to -90 dB. As gain is adjusted it is automatically translated to new target values for the biquad coefficients. The new coefficient values give 2 results: 1.) Lower overall system volume by gain dB. 2.) Boost system bass according to Fletcher Munson nonlinear model.
The center frequency for bass boost is specified by the constant SYS.centerFreq. The center frequency is set at instantiation time and by default equals 62.5 Hz. Theory of operation:
1.) At system creation a 5 coefficient biquad filter is created. The biquad frequency response is designed with a center frequency of SYS.centerFreq and a shape which closely fits Fletcher Munson difference curves.
2.) At system creation polynomial coefficients are calculated such that the polynomial: p(SYS.gain) will evaluate to the amount of bass boost in dB needed at SYS.centerFreq when overall system volume is cut by SYS.gain dB.
3.) When SYS.gain is changed p(SYS.gain) is evaluated. Two linear gains are then calculated: i.) passThruGain (=undb20(SYS.gain)) and ii.) b, which is equal to gain to be applied to the biquad. Desired system output = passThruGain*dataIn + b*(biquad output) (biquad output with dataIn for input).
4.) Intead of using a seperate biquad and mixer, we dyanmically vary biquad coefficients so its transfer function implements the combined mixer biquad system described above. We need the original biquad numerator coefficients for calculation each time SYS.gain is varied, thus we keep them in the constants: SYS.b0_LPF, SYS.b1_LPF, SYS.b2_LPF.
Type Definition
typedef struct _ModuleVolumeControlHP
{
ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure
FLOAT32 gain; // Gain through the volume control, in dB.
FLOAT32 centerFreq; // Center frequency of the low frequency resonance, in Hz.
FLOAT32 c2; // X^2 coefficient.
FLOAT32 c1; // X^1 coefficient.
FLOAT32 c0; // X^0 coefficient.
FLOAT32 b0_LPF; // First numerator coefficient.
FLOAT32 b1_LPF; // Second numerator coefficient.
FLOAT32 b2_LPF; // Third numerator coefficient.
FLOAT32 a1; // First denominator coefficient.
FLOAT32 a2; // Second denominator coefficient.
awe_modBiquadSmoothedHPInstance *mixerFilt; // 2nd order smoothly updating IIR filter with high precision implementation
} ModuleVolumeControlHPClass;
Variables
Properties
Name | Type | Usage | isHidden | Default value | Range | Units |
gain | float | parameter | 0 | 0 | -90:0.1:0 | dB |
centerFreq | float | const | 0 | 62.5 | 30:120 | Hz |
c2 | float | const | 0 | 0.001904 | Unrestricted | |
c1 | float | const | 0 | -0.09575 | Unrestricted | |
c0 | float | const | 0 | -0.2614 | Unrestricted | |
b0_LPF | float | const | 0 | 0.004074 | Unrestricted | |
b1_LPF | float | const | 0 | -6.224e-12 | Unrestricted | |
b2_LPF | float | const | 0 | -0.004074 | Unrestricted | |
a1 | float | const | 0 | -1.992 | Unrestricted | |
a2 | float | const | 0 | 0.9919 | Unrestricted |
Pins
Input Pins
Name: in
Description: Audio Input
Data type: float
Channel range: Unrestricted
Block size range: Unrestricted
Sample rate range: Unrestricted
Complex support: Real
Output Pins
Name: out
Description: Audio output
Data type: float
MATLAB Usage
File Name: volume_controlHP_module.m
SYS=volume_controlHP_module(NAME, CENTERFREQ)
Creates a volume control module with built-in loudness compensation.
This module can operate on multiple channels. This version uses high precision
implementation.
Arguments:
NAME - name of the module.
CENTERFREQ - frequency of the low frequency gain boost, in Hz. By
default, it equals 62.5 Hz.