Class fx_compressor¶
Defined in File dm_fx_compressor.h
Inheritance Relationships¶
Base Type¶
public fx_effect
(Class fx_effect)
Class Documentation¶
-
class
fx_compressor
: public fx_effect¶ Effect: Compressor/Limiter.
Think of a compressor as a small robot that controls a volume knob based on how loud you’re playing. When you strike a loud chord, the robot immediately turns the volume down and as the chord rings out, the robot turns the volume up progressively, so it sounds like you’re just sustaining the chord. Instead of dying off, it sounds steady for a few seconds as the robot is turning up the volume. Compressors are used a lot with acoustic instruments and vocals but also with electric guitars too. A common in country music is running a Telecaster through a compressor.
#include <dreammakerfx.h> fx_compressor compressor_1(-30.0, // Initial threshold in dB 8, // Initial ratio (1:8) 10.0, // Attack (10ms) 100.0, // Release (100ms) 2.0); // Initial output gain (2x); void setup() { pedal.init(); // Initialize pedal // Route audio through effects pedal.route_audio(pedal.instr_in, compressor_1.input); pedal.route_audio(compressor_1.output, pedal.amp_out); pedal.add_bypass_button(FOOTSWITCH_LEFT); // Use left footswitch/LED to bypass effect pedal.run(); // Run effects } void loop() { // Run pedal service to take care of stuff pedal.service(); if (pedal.pot_left.has_changed()) {. // Left pot sets threshold from -20dB to -70dB compressor_1.set_threshold(-20 – (50.0 * pedal.pot_left.val); } if (pedal.pot_center.has_changed()) { // Center pot sets compression ration from 1:1 to 40:1 compressor_1.set_ratio(1.0+ (40.0 * pedal.pot_center.val)); } if (pedal.pot_right.has_changed()) { // Right pot sets output gain from 1.0 to 6.0 compressor_1.set_output_gain(1.0 + pedal.pot_right.val*5.0); } }
There are several cool things to do with compressors: Add a compressor on either side of a clipper to create more dynamics, run two compressors through a LPF and HPF to create a multi-band compressor (where low end and high end are compressed independently), vary compressor parameters with an LFO to get some wild sounds.
Public Functions
-
fx_compressor
(float thresh, float ratio, float attack, float release, float gain_out)¶ Constructs a new instance.
- Parameters
[in] thresh
: Where the robot starts turning down the volume. This value is in decibels so a good place to start is between -60.0 and -30.0[in] ratio
: How aggressively the robot will turn down the volume when the input exceeds the threshold. Values from 2-16 create a softer effect. A very high value of 100.0 creates a hard ceiling.[in] attack
: Time in milliseconds for robot to respond when a note exceeds the threshold. Setting this to 20-30 will allow a bit of a peak to sneak through.[in] release
: how long before the robot stops controlling volume after volume goes below threshold[in] gain_out
: output volume (from 1.0 and up)
-
void
enable
()¶ Enable the this_effect (it is enabled by default)
-
void
bypass
()¶ Bypass the this_effect (will just pass clean audio through)
-
void
set_threshold
(float threshold)¶ Sets the compressor threshold.
- Parameters
[in] threshold
: The threshold is where the robot starts turning down the volume. This value is in decibels so a good place to start is between -60.0 and -30.0
-
void
set_ratio
(float ratio)¶ Sets the compression ratio.
- Parameters
[in] ratio
: The ratio is how aggressively the robot will turn down the volume when the input exceeds the threshold. Values from 2-16 create a softer effect. A very high value of 100.0 creates a hard ceiling.
-
void
set_attack
(float attack)¶ Sets the time it takes for the compressor to be fully engaged after volume exceeds threshold.
- Parameters
[in] attack
: The attack is the time in milliseconds for robot to respond when a note exceeds the threshold. Setting this to 20-30 will allow a bit of a peak to sneak through.
-
void
set_release
(float release)¶ Sets the time it takes for the compressor to release the volume control when the volume goes back below the threshold.
- Parameters
[in] release
: The release is the time in milliseconds for robot to respond when a note falls below the threshold.
-
void
set_output_gain
(float gain_out)¶ Sets the output gain of the compressor.
- Parameters
[in] gain_out
: The gain out (typically 1.0 for no gain adjustment and higher to increase gain)
-
void
print_params
(void)¶
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 *
threshold
¶ Control routing node [input]: Compressor/limiter threshold in dB (i.e. -30.0)
-
fx_control_node *
ratio
¶ Control routing node [input]: Compressor/limiter compression ratio (a value of 100.0 would be a ratio of 1:100)
-
fx_control_node *
attack
¶ Control routing node [input]: Compressor/limiter attack rate in milliseconds
-
fx_control_node *
release
¶ Control routing node [input]: Compressor/limiter release rate in milliseconds
-
fx_control_node *
out_gain
¶ Control routing node [input]: Compressor/limiter output gain (linear value so a value of 2.0 would double the signal amplitude)
-