2.1 KiB
2.1 KiB
Scripting
Steps are programmed using Rhai, a simple scripting language.
Basic Syntax
Create sounds using sound() and chain parameters:
sound("kick").gain(0.8)
sound("hat").freq(8000).decay(0.1)
Context Variables
These are available in every step script:
step: Current step index (0-based)beat: Current beat positionbank: Current bank indexpattern: Current pattern indextempo: Current BPMphase: Phase within the bar (0.0 to 1.0)slot: Slot number playing this pattern
Randomness
rand(min, max): Random float in rangerrand(min, max): Random integer in range (inclusive)seed(n): Set random seed for reproducibility
Variables
Store and retrieve values across steps:
set("name", value): Store a valueget("name"): Retrieve a value
Sound Parameters
Core
sound(name): Create sound commandfreq(hz): Frequencynote(midi): MIDI note numbergain(amp): Volume (0.0-1.0)pan(pos): Stereo position (-1.0 to 1.0)dur(secs): Durationgate(secs): Gate time
Envelope
attack(secs): Attack timedecay(secs): Decay timesustain(level): Sustain levelrelease(secs): Release time
Filter
lpf(hz): Lowpass frequencylpq(q): Lowpass resonancehpf(hz): Highpass frequencybpf(hz): Bandpass frequency
Effects
delay(mix): Delay amountdelaytime(secs): Delay timedelayfeedback(amt): Delay feedbackverb(mix): Reverb amountverbdecay(secs): Reverb decay
Modulation
vib(hz): Vibrato ratevibmod(amt): Vibrato depthfm(hz): FM modulator frequencyfmh(ratio): FM harmonic ratio
Sample Playback
speed(ratio): Playback speedbegin(pos): Start position (0.0-1.0)end(pos): End position (0.0-1.0)
Examples
Conditional based on step:
if step % 4 == 0 {
sound("kick").gain(1.0)
} else {
sound("hat").gain(0.5)
}
Random variation:
sound("synth")
.freq(rand(200.0, 800.0))
.gain(rand(0.3, 0.7))
Using variables:
let n = get("counter");
set("counter", n + 1);
sound("beep").note(60 + (n % 12))