Class fx_amplitude_mod¶
Defined in File dm_fx_amplitude_modulator.h
Inheritance Relationships¶
Base Type¶
public fx_effect
(Class fx_effect)
Class Documentation¶
-
class
fx_amplitude_mod
: public fx_effect¶ Effect: Amplitude modulator for creating tremelo-like effects.
Amplitude modulators are the basic building blocks of tremelos and rhythmic effects. They essentially use an oscillator / waveform or an external control signal to vary the amplitude / volume of a signal.
#include <dreammakerfx.h> fx_amplitude_mod mod1(1.0, // Rate (Hz) is once per second 0.8, // Depth (0.0->1.0) 0, // Initial phase (degrees) OSC_SINE,// Oscillator type is a sine wave false); // Don't use external LFO void setup() { pedal.init(); // Initialize pedal // Route audio through effects pedal.route_audio(pedal.instr_in, mod1.input); pedal.route_audio(mod1.output, pedal.amp_out); pedal.add_bypass_button(FOOTSWITCH_LEFT); // Use left footswitch/LED to bypass effect pedal.run(); // Run effects } void loop() { // Pot 0 changes the rate of the tremelo from 0 to 4Hz if (pedal.pot_0.has_changed()) { mod1.set_rate_hz(pedal.pot_0.val*4.0); } // Pot 1 changes the depth from 0.0 to 1.0 if (pedal.pot_1.has_changed()) { mod1.set_depth(pedal.pot_1); } pedal.service(); // Run pedal service to take care of stuff }
There are lots of cool things you can try with amplitude modulators: use tap function to set rate, use a instrument input through a pitch shifter as the external modulator, use high modulation frequency like 440.0Hz, try a few in parallel running through filters with different initial phase values (to create harmonic tremelos).
Public Functions
-
fx_amplitude_mod
(float rate_hz, float depth)¶ Basic constructor/initializer for amplitude modulator.
fx_amplitude_mod mod1(1.0, // Rate (Hz) is once per second 0.8); // Depth (0.0->1.0)
- Parameters
[in] modulation_rate
: When using an internal oscillator, the “modulation” rate is oscillation (cycles per second). When in doubt, start with 1.0 (one cycle per second)[in] modulation_depth
: How much the volume is “modulated”. A value of 0.0 is none at all and a value of 1.0 means full volume to zero volume.
-
fx_amplitude_mod
(float rate_hz, float depth, float initial_phase_deg, OSC_TYPES modulation_type, bool use_ext_modulator)¶ Advanced constructor for the amplitude modulator.
fx_amplitude_mod mod1(1.0, // Rate (Hz) is once per second 0.8, // Depth (0.0->1.0) 0, // Initial phase (degrees) OSC_SINE,// Oscillator type is a sine wave false); // Don't use external LFO
- Parameters
[in] rate_hz
: When using an internal oscillator, the “modulation” rate is oscillation (cycles per second). When in doubt, start with 1.0 (one cycle per second)[in] depth
: How much the volume is “modulated”. A value of 0.0 is none at all and a value of 1.0 means full volume to zero volume.[in] initial_phase_deg
: The initial phase of the oscillator in degrees. When in doubt, use 0.0. This is useful when you want to have multiple oscillators running at different phases such as in harmonic tremelo where one may be at 0.0 and the other at 180.0.[in] modulation_type
: SeeOSC_TYPES
for available waveforms (sine, square, triangle, random, pulse, etc.) as the modulation source.[in] use_ext_modulator
: Rather than using an internal modulator, you can also use an external audio source. Route audio to the .ext_mod_in audio to use it as the external modulator.
-
void
enable
()¶ Enable the amplitude modululator (it is enabled by default)
-
void
bypass
()¶ Bypass the amplitude modululator (will just pass clean audio through)
-
void
set_depth
(float depth)¶ Sets the depth of the amplitude modululator.
mod1.set_depth(0.5); // Sets the depth of the modulator to a fixed value
- Parameters
[in] depth
: The depth fom 0.0 -> 1.0. 0.0 is no modulation at all, 1.0 is full modulation.
-
void
set_rate_hz
(float rate_hz)¶ Sets the rate of the modulator in Hertz (cycles per second)
- Parameters
[in] rate_hz
: The rate hz
-
void
set_lfo_type
(OSC_TYPES new_type)¶ Sets the the type of oscillator used as the LFO.
- Parameters
[in] new_type
: The new type of LFO (OSC_TYPES)
-
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_audio_node *
ext_mod_in
¶ Audio routing node: external modulator audio input
-
fx_control_node *
depth
¶ Control routing node: amplifude modulator depth (should be between 0.0 and 1.0)
-
fx_control_node *
rate_hz
¶ Control routing node: amplitide modulator rate (Hz) (i.e. 1.0 = once per second)
-