|
TR123e - EMCT Computing Final Project Version 1.0
Research Project Translation from gen~ to embedded Moog synth
|
Simplified Moog ladder filter with bilinear transform accuracy. More...
#include <BilinearTransformMoogLadderFilter.h>
Public Member Functions | |
| MoogLadderFilter (float rate) | |
| Construct simplified Moog ladder filter. | |
| void | setSampleRate (float rate) |
| Update sample rate and recalculate coefficients. | |
| void | setCutoff (float cutoffHz) |
| Set cutoff frequency with bilinear transform compensation. | |
| void | setResonance (float res) |
| Set resonance amount with classic Moog scaling. | |
| float | process (float input) |
| Process single audio sample through simplified ladder. | |
| MoogLadderFilter (float sampleRate) | |
| Construct Moog ladder filter with specified sample rate. | |
| void | setSampleRate (float rate) |
| Update sample rate and recalculate coefficients. | |
| void | setCutoff (float cutoffHz) |
| Set filter cutoff frequency with automatic coefficient update. | |
| void | setResonance (float resonanceAmount) |
| Set filter resonance amount with feedback calculation. | |
| float | process (float input) |
| Process single audio sample through filter. | |
Private Member Functions | |
| void | updateCoefficients () |
| Update filter coefficients when parameters change. | |
| void | updateCoefficients () |
| Update filter coefficients when parameters change. | |
Private Attributes | |
| float | sampleRate |
| Audio system sample rate. | |
| float | cutoff |
| Current cutoff frequency in Hz. | |
| float | resonance |
| Current resonance amount [0.0-1.0]. | |
| float | tuning |
| Bilinear transform tuning coefficient. | |
| float | feedback |
| Resonance feedback coefficient. | |
| float | y [4] = {0.0f} |
| Filter stage state variables [4 elements]. | |
| float | oldx = 0.0f |
| Previous input sample for difference equations. | |
| float | oldy = 0.0f |
| Previous output sample for feedback calculation. | |
Simplified Moog ladder filter with bilinear transform accuracy.
Educational implementation of Moog ladder filter using bilinear transform.
This class provides a straightforward implementation of the Moog ladder filter using bilinear transform frequency mapping and simplified cascade topology. The design prioritizes computational efficiency and implementation clarity while maintaining the essential musical characteristics of the Moog sound.
@key_features
@computational_characteristics
This class provides a clear, straightforward implementation of the classic Moog ladder filter using bilinear transform methodology. The design emphasizes educational value and implementation clarity while maintaining the essential sonic characteristics that define the Moog sound.
@design_principles
@filter_characteristics
@mathematical_implementation
@usage_example
| MoogLadderFilter::MoogLadderFilter | ( | float | rate | ) |
Construct simplified Moog ladder filter.
Initialize simplified Moog ladder filter.
| rate | Sample rate for bilinear transform calculations |
Initializes filter with default parameters and computes initial coefficients using bilinear transform frequency mapping.
| MoogLadderFilter::MoogLadderFilter | ( | float | sampleRate | ) |
Construct Moog ladder filter with specified sample rate.
| sampleRate | Audio processing sample rate for coefficient calculation |
Initializes the filter with default parameters suitable for immediate use and calculates initial coefficients based on the specified sample rate.
| float MoogLadderFilter::process | ( | float | input | ) |
Process single audio sample through simplified ladder.
Process sample through simplified ladder with nonlinear saturation.
| input | Input audio sample |
Core processing method implementing the four-pole cascade with nonlinear saturation and resonance feedback. Uses simplified topology for computational efficiency.
@algorithm_steps
This method implements a streamlined version of the Moog ladder that captures the essential frequency response and nonlinear characteristics while maintaining computational efficiency suitable for real-time use.
Calculate input with resonance feedback from final stage This implements the negative feedback that creates resonance
Process through four cascaded one-pole lowpass sections Each section uses the bilinear transform tuning coefficient and includes tanh() saturation for nonlinear analog character
The algorithm implements: y[n] += tuning × (tanh(input) - tanh(y[n])) This provides both lowpass filtering and nonlinear saturation
Return final stage output This provides the complete 24dB/octave lowpass response with nonlinear saturation and resonance characteristics
| float MoogLadderFilter::process | ( | float | input | ) |
Process single audio sample through filter.
| input | Audio sample for filtering |
Core processing method implementing the four-pole ladder filter with resonance feedback and optional nonlinear saturation for analog character.
| void MoogLadderFilter::setCutoff | ( | float | cutoffHz | ) |
Set cutoff frequency with bilinear transform compensation.
Set cutoff frequency with validation and bilinear transform.
| cutoffHz | Cutoff frequency in Hz |
Configures the filter cutoff frequency using bilinear transform for accurate frequency mapping from analog prototype to digital implementation.
@range [5Hz, 0.45 × sampleRate] automatically enforced @transform Uses tan(π × fc / fs) for frequency pre-warping
Clamp cutoff to safe range preventing aliasing and instability Upper limit of 0.45 × sampleRate provides safety margin below Nyquist
| void MoogLadderFilter::setCutoff | ( | float | cutoffHz | ) |
Set filter cutoff frequency with automatic coefficient update.
| cutoffHz | Cutoff frequency in Hz |
Configures the filter cutoff frequency with range validation and automatic coefficient recalculation using bilinear transform with frequency pre-warping for accurate analog frequency matching.
| void MoogLadderFilter::setResonance | ( | float | res | ) |
Set resonance amount with classic Moog scaling.
Set resonance with validation and coefficient update.
| res | Resonance amount [0.0-1.0] |
Configures filter resonance using classic Moog-style scaling where feedback = resonance × 4.0 to account for the four-pole attenuation in the ladder structure.
@range [0.0-1.0] automatically enforced @scaling feedback = res × 4.0 (classic Moog relationship)
Clamp resonance to [0.0-1.0] range for stability
| void MoogLadderFilter::setResonance | ( | float | resonanceAmount | ) |
Set filter resonance amount with feedback calculation.
| resonanceAmount | Resonance intensity [0.0-1.0] |
Controls the amount of positive feedback that creates the characteristic resonance peak. Higher values produce more prominent peaks and can lead to self-oscillation at the cutoff frequency.
| void MoogLadderFilter::setSampleRate | ( | float | rate | ) |
Update sample rate and recalculate coefficients.
Update sample rate with coefficient recalculation.
| rate | New sample rate in Hz |
Allows dynamic sample rate changes with automatic coefficient recalculation to maintain frequency accuracy.
| void MoogLadderFilter::setSampleRate | ( | float | rate | ) |
Update sample rate and recalculate coefficients.
| rate | New sample rate for coefficient recalculation |
Allows dynamic sample rate changes with automatic coefficient updates to maintain proper frequency response characteristics.
|
private |
Update filter coefficients when parameters change.
Update coefficients using bilinear transform relationships.
Recalculates tuning and feedback coefficients using bilinear transform relationships when cutoff or resonance changes.
This method implements the core bilinear transform calculations that provide accurate frequency mapping from analog prototype to digital implementation while maintaining computational efficiency.
Calculate normalized frequency for bilinear transform
Apply bilinear transform frequency pre-warping tuning = tan(π × fc) compensates for frequency compression in bilinear transform, ensuring accurate cutoff frequency
Calculate feedback coefficient using classic Moog scaling Factor of 4.0 accounts for cumulative attenuation through four filter poles in the ladder structure
|
private |
Update filter coefficients when parameters change.
Recalculates tuning and feedback coefficients using bilinear transform methodology when cutoff frequency or resonance parameters are modified.
|
private |
Current cutoff frequency in Hz.
|
private |
Resonance feedback coefficient.
Resonance feedback gain coefficient.
Calculated as resonance × 4.0 using classic Moog scaling to account for four-pole attenuation in feedback path.
|
private |
Previous input sample for difference equations.
|
private |
Previous output sample for feedback calculation.
|
private |
Current resonance amount [0.0-1.0].
|
private |
Audio system sample rate.
System parameters.
Audio processing sample rate
|
private |
Bilinear transform tuning coefficient.
Pre-computed coefficients for efficient processing.
Computed as tan(π × cutoff / sampleRate) for frequency pre-warping compensation in bilinear transform.
Bilinear transform coefficient with pre-warping
|
private |
Filter stage state variables [4 elements].
Filter state variables.
Internal state of each filter pole in the cascade structure. These maintain the temporal memory of the filter.
Filter stage outputs (4-pole cascade)