Files
Cagire/docs/engine/audio_modulation.md

2.4 KiB

Audio-Rate Modulation

Any parameter can be modulated continuously using modulation words. Instead of a fixed value, these words produce a modulation string that the engine interprets as a moving signal.

All time values are in steps, just like attack, decay, and release. At 120 BPM with speed 1, one step is 0.125 seconds. Writing 4 lfo means a 4-step period.

LFOs

Oscillate a parameter between two values.

saw s 200 4000 4 lfo lpf .         ( sweep filter over 4 steps )
saw s 0.3 0.7 2 tlfo pan .         ( triangle pan over 2 steps )
Word Shape Output
lfo Sine min~max:period
tlfo Triangle min~max:periodt
wlfo Sawtooth min~max:periodw
qlfo Square min~max:periodq

Stack effect: ( min max period -- str )

Slides

Transition from one value to another over a duration.

saw s 0 1 0.5 slide gain .         ( fade in over half a step )
saw s 200 4000 8 sslide lpf .      ( smooth sweep over 8 steps )
Word Curve Output
slide Linear start>end:dur
expslide Exponential start>end:dure
sslide Smooth (S-curve) start>end:durs

Stack effect: ( start end dur -- str )

Random

Randomize a parameter within a range, retriggering at a given period.

saw s 200 4000 2 jit lpf .         ( new random value every 2 steps )
saw s 200 4000 2 sjit lpf .        ( same but smoothly interpolated )
saw s 200 4000 1 drunk lpf .       ( random walk, each step )
Word Behavior Output
jit Sample & hold min?max:period
sjit Smooth interpolation min?max:periods
drunk Random walk min?max:periodd

Stack effect: ( min max period -- str )

Envelopes

Define a multi-segment envelope for a parameter. Provide a start value, then pairs of target and duration.

saw s 0 1 0.1 0.7 0.5 0 8 env gain .

This creates: start at 0, rise to 1 in 0.1 steps, drop to 0.7 in 0.5 steps, fall to 0 in 8 steps.

Stack effect: ( start target1 dur1 [target2 dur2 ...] -- str )

Combining

Modulation words return strings, so they compose naturally with the rest of the language. Use them anywhere a parameter value is expected.

saw s
  200 4000 4 lfo lpf
  0.3 0.7 8 tlfo pan
  0 1 0.1 0.7 0.5 0 8 env gain
.