Instrument Effects
You can add one ore multiple effects to the sound of the instrument to manipulate the sounds timbre in different ways. The first argument is always the effect-name
. The arguments that follow depend on the selected effect. fx()
can be used as an alias to reduce some typing. For ease of use some arguments can be skipped to access the most used arguments. How this works is explained per effect if applicable.
new synth saw fx(<effect-name> <value1> <value2> ... <value-n>)
Static vs. Dynamic FX-Chains
The Mercury4Max version has a static effects-chain. This means the order in the effects under the hood is fixed. The order is documented under Static FX Chain. Because of this there is:
- No option to change the order of effects with the code
- No option to use effects multiple times in one instrument
new synth saw fx(reverb) fx(filter low 2000) fx(distort) fx(filter low 300)
// filter and distortion are fixed before reverb in the chain, the order of
// the code doesn't matter. There is only one filter in the chain, the first
// filter is therefore overwritten by the other
The MercuryPlayground version has a dynamic effects-chain. This means the order in the effects is determined by how you type the code. Because of this there is:
- Decide the order of effects by the order of the code you type
- Use effects multiple times on one instrument
new synth saw fx(reverb) fx(filter low 2000) fx(distort) fx(filter low 300)
// the reverb will be filtered, then distorted and then filtered again
// the resulting sound is filtered twice
There are differences in sound between the Mercury4Max and MercuryPlayground versions. Parameters may need some tweaking when you port from one environment to the other.
Not all effects from Mercury4Max are available in the MercuryPlayground because some are in the process of being ported, and some are sadly not as easy to implement with Web Audio.
Static FX-Chain
instrument (eg. sample, synth, input)
|
freeze (spectral freezer)
|
shift (pitchshifter)
|
vibrato (pitch modulation)
|
triggerFilter (envelope modulated filter)
|
kink (distortion)
|
distort (distortion)
|
filter (low/hi/band filter with optional LFO modulation)
|
comb (combfiltering)
|
degrade (downsampling)
|
squash (basic compression/distortion)
|
vocoder
|
looper (looping delay)
|
gain (the volume of the sound) -> sender
|
panning (mono to stereo)
||
double / chorus
||
|| >> vv
|| +
|| reverb (stereo)
++ << <<
||
lfo (low frequency oscillator)
||
delay (stereo pingpong delay)
||
output
| mono
- mono
|| stereo
= stereo
++ sum
chorus
Add a Chorus effect to the sound. The original sound is played in the center and two delayed version are played left and right, of which the delaytimes are slightly modulated. Arguments are the modulation speed in fraction, the modulation depth in milliseconds, the modulation wave sine
or random
, the dry-wet ratio between 0
and 1
and a detune factor between left and right modulation wave in floating.
arguments
Fraction(List)
-> modulation rate (default=4/1)Number+(List)
-> modulation depth in ms (default=8 for double, default=45 for chorus)Name(List)
-> modulation wave, sine or random (default=random)Float+(List)
-> dry-wet (default=1 for double, default=0.5 for chorus)Float+(List)
-> modulation rate detune (default=0.94562)
fx(chorus)
fx(chorus <rate>)
fx(chorus <rate> <depth> <wave> <dry-wet> <detune>)
new synth saw fx(chorus 5/1 30) shape(1 1/4) time(1/2) note(0 1)
There are some small differences for this effect in the browser version:
Fraction
-> modulation rate (default=8/1)Number+
-> modulation depth in ms (default=8 for double, default=45 for chorus)Float+
-> dry-wet (default=1 for double, default=0.5 for chorus)
fx(chorus)
fx(chorus <rate>)
fx(chorus <rate> <depth> <dry-wet>)
comb
A combfilter effect. This combines a small delayed version of the sound with the original sound resulting in a combfilter, giving a metallic quality to the sound. The first argument is the semitone the filter is tuned at (synced to the scale and allowing for detuning with floating points), the second optional argument is a feedback amount.
arguments
Number+(List)
-> filter frequency as note semiton (default=0)Float+(List)
-> filter feedback between 0 and 0.99 (default=0.8)Float+(List)
-> dry-wet factor 0-1 (optional, default=0.5)
new synth saw fx(comb 7 0.4)
degrade
A downsampling/8bit/chiptune effect. The signal is downsampled by a factor, where 0
means no downsampling (original samplerate) and 0.5
is half the samplerate etc (e.g. 44100 * 0.5 = 22050).
arguments
Float+(List)
-> downsampling amount between 0-1 (default = 0.5)Float+(List)
-> dry-wet factor 0-1 (optional, default=1)
new synth saw fx(degrade 0.75)
Alias: chip
delay
Add a pingpong delay effect to the sound. The effect has 4 arguments, the left delaytime, the right delaytime, the feedback and the damping. The delaytime is specified in bar time fractions, where 0.25
(or 1/4
) is a quarter note. The feedback is specified as a value between 0
and 1
. Positive feedback is allowed and internally compressed/distorted, but watch out for your ears just in case. The damping is a onepole lowpass filter for which the cutoff is specified between 0
and 1
where 0 means full damping, and 1 means none (filter open).
arguments
Fraction(List)
-> delaytime for left (optional, default=3/16)Fraction(List)
-> delaytime for right (optional, default=2/8)Float+(List)
-> feedback 0-1 (optional, default=0.8)Float+(List)
-> damping 0-1 (optional, default=0.5)Float+(List)
-> drywet 0-1 (optional, 1=100% wet, default=0.5)
fx(delay) (defaults)
fx(delay <timeLR>)
fx(delay <timeLR> <fb>)
fx(delay <timeL> <timeR> <fb>)
fx(delay <timeL> <timeR> <fb> <damp>)
fx(delay <timeL> <timeR> <fb> <damp> <drywet>)
new sample hat_909 time(1/2) fx(delay 3/16 7/16 0.5 0.7)
Alias: echo
distort
A distortion/overdrive/soft-clipping effect. Uses the tanh(x * g)
algorithm and a 1.0/sqrt(g)
for gain compensation.
arguments
Number+(List)
-> distortion amount, greater then 0 (optional, default=2)Float+(List)
-> dry-wet factor 0-1 (optional, default=1)
new sample kick_909 fx(drive 15 0.4)
Alias: drive
double
Add an Automated-Double-Tracking (ADT) effect to the sound. It will sound like two versions of the sound are created, one left and one right. This effect is the chorus
effect but with wet = 1
. See chorus
for more info about all the parameters.
new sample clap_808 fx(double) time(1/4)
filter
Add a filter to the sound. This can be a static filter or a modulated filter depending on the amount of arguments you provide. The filter-type can be a low
, high
or band
-pass filter. The second argument is the cutoff frequency in Hz and the third argument is the resonance between 0
and 1
. Passing a single argument only sets the cutoff, passing two arguments sets the cutoff and resonances. The filter then defaults to lowpass
.
arguments
Name
-> filter type, low, high, band (default=low)Number+(List)
-> cutoff frequency in Hz (default=1200)Float+(List)
-> resonance between 0-1 (default=0.45)
fx(filter)
fx(filter <cutoff>)
fx(filter <cutoff> <resonance>)
fx(filter <type> <cutoff> <resonance>)
new synth saw note(0 1) shape(-1) fx(filter low 800 0.6)
filter modulation
You can provide extra arguments to have the filter modulate between a low and high cutoff-frequency. In this case the arguments are as follows (in order): The filter-type low / high / band
. The modulation speed in float/fraction where 0.25
or 1/4
= a quarter note. The upper cutoff in Hz, the lower cutoff in Hz the resonance between 0
and 0.99
. The modulation shape tilt between 0
and 1
, where 0 is ramp-down, 1 is ramp-up and 0.5 is triangle form (although the ramp-up and down can change if you swap the upper and lower cutoff values). The exponential curve for the filter as floating point 0
- 100
.
arguments
Name
-> filter type, low, high, band (default=low)Fraction(List)
-> modulation ratio (default=1/1)Number+(List)
-> low modulation frequency in Hz (default=200)Number+(List)
-> high modulation frequency in Hz (default=3000)Float+(List)
-> resonance between 0-1 (default=0.45)Float+(List)
-> modulation slope 0-1 (up, triangle, down) (default=0.5)Float+(List)
-> exponential scaling (default=2)
new synth saw note(0 0) fx(filter low 1/4 100 3500 0.55 0 4)