Class fx_biquad_filter¶
Defined in File dm_fx_biquad_filter.h
Inheritance Relationships¶
Base Type¶
public fx_effect
(Class fx_effect)
Class Documentation¶
-
class
fx_biquad_filter
: public fx_effect¶ Effect: Biquad filter for implementing various types of filters (low pass, high pass, band pass, etc.)
The biquad filter can be used to create static filters such as equalizers and dynamic filters such as auto-wahs and other interesting swept filtering effects.
Filters are a basic building block of so many audio effects. Filters allow certain frequencies to pass through and decrease the volume at other frequencies.
A wah pedal is a band pass filter that is “swept” across a range of frequencies based on foot position.
In this example, we’ll create an auto-wah filter where we have an envelope tracker which tracks the volume we’re playing at and uses this to move the filter frequency. This example uses both route_audio AND route_control. This is where the magic lies.
#include <dreammakerfx.h> fx_envelope_tracker envy_tracky(10, // 10 ms attack 100, // 100 ms release false); // not triggered fx_biquad_filter wah_filter(300.0, // 300 Hz starting frequency FILTER_WIDTH_NARROW, // Width of the filter is narrow BIQUAD_TYPE_BPF); // Type is bandpass void setup() { pedal.init(); // Initialize pedal // Route audio through effects pedal.route_audio(pedal.instr_in, wah_filter.input); pedal.route_audio(wah_filter.output, pedal.amp_out); // Route audio to envelope tracker pedal.route_audio(pedal.instr_in, envy_tracky.input); // Route control from envelop tracker to filter frequency pedal.route_control(envy_tracky.envelope, wah_filter.freq, 1000.0, 300.0); // range 0->1 to 300->300+1000 pedal.add_bypass_button(FOOTSWITCH_LEFT); // Use left footswitch/LED to bypass effect pedal.run(); // Run effects } void loop() { pedal.service(); // Run pedal service to take care of stuff }
There are lots of cool things you can try with filters: hook up a filter to the envelope tracker to create an auto-wah, run a clipper through a filter to get various tube sounds, hook up an oscillator to the filter frequency to create a rhythmic filter sweep, run filters through amplitude modulators to create harmonic modulators.
Public Functions
-
fx_biquad_filter
(float filt_freq, float filt_resonance, BIQUAD_FILTER_TYPE filt_type)¶ Basic constructor for biquad filter.
// 200Hz 2nd-order (default) low-pass filter to just let bass frequencies through fx_biquad_filter simple_filt(200.0, 1.0, BIQUAD_TYPE_LPF );
- Parameters
[in] filt_freq
: This is the cutoff frequency or center frequency of the filter in Hertz.[in] filt_resonance
: This is how quickly the filter “rolls off” – is it a gentle, wide filter or a tight narrow filter? A value of 1.0 is no resonance; > 1.0 is more resonant, < 1.0 is less resonant.[in] filt_type
: Filters come in lots of colors. Low-pass filters (LPF) cut higher frequencies. High-pass filters (HPF) cut lower frequencies. Band-pass filters (BPF) cut frequencies on both sides of the filter frequency. And notch filters cut the frequencies at the filter frequency and allow others to pass.
-
fx_biquad_filter
(float filt_freq, float filt_resonance, BIQUAD_FILTER_TYPE filt_type, BIQUAD_FILTER_ORDER order)¶ Basic constructor for biquad filter.
// A stronger 6th order 200Hz low-pass filter to just let bass frequencies through fx_biquad_filter simple_filt(200.0, 1.0, BIQUAD_TYPE_LPF, BIQUAD_ORDER_6 );
- Parameters
[in] filt_freq
: This is the cutoff frequency or center frequency of the filter in Hertz.[in] filt_resonance
: This is how quickly the filter “rolls off” – is it a gentle, wide filter or a tight narrow filter? A value of 1.0 is no resonance; > 1.0 is more resonant, < 1.0 is less resonant.[in] filt_type
: Filters come in lots of colors. Low-pass filters (LPF) cut higher frequencies. High-pass filters (HPF) cut lower frequencies. Band-pass filters (BPF) cut frequencies on both sides of the filter frequency. And notch filters cut the frequencies at the filter frequency and allow others to pass.[in] order
: The number of filtering stages – higher is more extreme filtering effect
-
fx_biquad_filter
(float filt_freq, float filt_resonance, float filter_gain, BIQUAD_FILTER_TYPE filt_type, EFFECT_TRANSITION_SPEED trans_speed)¶ Advanced constructor for biquad filter.
- Parameters
[in] filt_freq
: This is the cutoff frequency or center frequency of the filter in Hertz.[in] filt_resonance
: This is how quickly the filter “rolls off” – is it a gentle, wide filter or a tight narrow filter? A value of 1.0 is no resonance; > 1.0 is more resonant, < 1.0 is less resonant.[in] filter_gain
: The filter gain in dB (used in peaking and shelf filters)[in] filt_type
: Filters come in lots of colors. Low-pass filters (LPF) cut higher frequencies. High-pass filters (HPF) cut lower frequencies. Band-pass filters (BPF) cut frequencies on both sides of the filter frequency. And notch filters cut the frequencies at the filter frequency and allow others to pass.[in] trans_speed
: When a new filter frequency or filter width is provided, the transition speed determines how quickly the filter will transition.
-
fx_biquad_filter
(float filt_freq, float filt_resonance, float filter_gain_db, BIQUAD_FILTER_TYPE filt_type, EFFECT_TRANSITION_SPEED trans_speed, BIQUAD_FILTER_ORDER order)¶ Advanced constructor for biquad filter.
- Parameters
[in] filt_freq
: This is the cutoff frequency or center frequency of the filter in Hertz.[in] filt_resonance
: This is how quickly the filter “rolls off” – is it a gentle, wide filter or a tight narrow filter? A value of 1.0 is no resonance; > 1.0 is more resonant, < 1.0 is less resonant.[in] filter_gain_db
: The filter gain in dB (used in peaking and shelf filters)[in] filt_type
: Filters come in lots of colors. Low-pass filters (LPF) cut higher frequencies. High-pass filters (HPF) cut lower frequencies. Band-pass filters (BPF) cut frequencies on both sides of the filter frequency. And notch filters cut the frequencies at the filter frequency and allow others to pass.[in] trans_speed
: When a new filter frequency or filter width is provided, the transition speed determines how quickly the filter will transition.[in] order
: The number of filtering stages – higher is more extreme filtering effect
-
void
enable
()¶ Enable the biquad filter (it is enabled by default)
-
void
bypass
()¶ Bypass the biquad filter (will just pass clean audio through)
-
void
set_freq
(float freq)¶ Sets a new cutoff/critical frequency (Hz).
- Parameters
[in] freq
: The new center frequency for the filter in Hz (must be lower than 24000.0)
-
void
set_q
(float q)¶ Sets a new Q factor for the filter. For more information on Q factor, read this: https://en.wikipedia.org/wiki/Q_factor.
- Parameters
[in] q
: The Q factor (must be between 0.01 and 100.0)
-
void
set_resonance
(float filt_resonance)¶ Sets the resonance; 1.0 is none (0.7071)
- Parameters
[in] filt_resonance
: The resonance (must be between 0.01 and 100.0)
-
void
set_gain
(float gain)¶ Sets the filter gain. This is only used in shelving filters.
- Parameters
[in] gain
: The gain in dB
-
void
print_params
(void)¶ Print the parameters for this effect.
Public Members
-
fx_audio_node *
input
¶ Audio routing node: primary audio input
-
fx_audio_node *
output
¶ Audio routing node: primary audio output
-
fx_control_node *
freq
¶ Control routing node: center/critical frequency of the filter in Hz (i.e. 800.0 for 800Hz)
-
fx_control_node *
q
¶ Control routing node: width of the filter
-
fx_control_node *
gain
¶ Control routing node: gain of the filter (used in shelving filters)
-