tur/synth
adsr-gen
(adsr-gen [params])
svf-low-pass
(svf-low-pass [cutoff :float q :float])
hard-clip
(hard-clip [limit :float])
voice
(voice [freq :float params gate-sig filter-cutoff :float filter-q :float])
subtractive synthesizer voice: oscillator -> filter -> envelope.
| freq | frequency in Hz | |
| params | ADSRParams for the amplitude envelope | |
| gate-sig | Signal<bool> controlling note on/off | |
| filter-cutoff | SVF cutoff frequency (normalised 0.0 to 1.0) | |
| filter-q | SVF resonance |
Signal<Sample> ready to be summed into a mix bus.
(voice 440.0 (ADSRParams 0.01 0.1 0.7 0.2) gate-sig 0.6 0.5)
voice-sf
(voice-sf [freq :float params filter-cutoff :float filter-q :float])
SF wrapper around voice for arrow-based composition.
| freq | frequency in Hz | |
| params | ADSRParams | |
| filter-cutoff | normalised cutoff | |
| filter-q | resonance |
SF<Tuple () bool, Sample> where the bool lane carries the gate.
poly-synth
(poly-synth [voices params filter-cutoff :float filter-q :float])
polyphonic synthesizer mixing multiple voices.
| voices | vector of (freq, gate-signal) tuples, one per voice | |
| params | ADSRParams shared by all voices | |
| filter-cutoff | shared filter cutoff | |
| filter-q | shared filter resonance |
Signal<Sample> summing all active voices.
(poly-synth (vec-of (Tuple 261.0 gate1) (Tuple 329.0 gate2)) params 0.6 0.4)
fm-voice
(fm-voice [carrier-freq :float modulator-freq :float mod-index :float params gate-sig])
two-operator FM voice.
| carrier-freq | carrier oscillator frequency in Hz | |
| modulator-freq | modulator oscillator frequency in Hz | |
| mod-index | modulation index (depth of FM) | |
| params | ADSRParams for amplitude and modulator envelopes | |
| gate-sig | Signal<bool> controlling note on/off |
Signal<Sample> with FM-processed output.
(fm-voice 440.0 880.0 2.0 (ADSRParams 0.01 0.1 0.7 0.3) gate-sig)
wavetable-osc
(wavetable-osc [wavetable freq :float])
wavetable oscillator with linear interpolation.
| wavetable | pre-computed waveform table (one cycle) | |
| freq | playback frequency in Hz |
SF<(),Sample> reading from the wavetable at the requested frequency.
((wavetable-osc (sine-wavetable 2048) 440.0) (constant ()))
sine-wavetable
(sine-wavetable [size])
generate a sine-wave lookup table.
| size | number of samples in the table |
vec<Sample> containing one cycle of a sine wave.
(sine-wavetable 2048)
square-wavetable
(square-wavetable [size duty])
generate a square-wave lookup table.
| size | number of samples in the table | |
| duty | duty cycle (0.0 to 1.0) |
vec<Sample> containing one cycle of a square wave.
sawtooth-wavetable
(sawtooth-wavetable [size])
generate a sawtooth-wave lookup table.
| size | number of samples in the table |
vec<Sample> containing one cycle of a sawtooth wave in [-1, 1).
wavetable-voice
(wavetable-voice [wavetable freq :float params gate-sig])
wavetable oscillator with ADSR amplitude envelope.
| wavetable | pre-computed waveform table | |
| freq | frequency in Hz | |
| params | ADSRParams | |
| gate-sig | Signal<bool> |
Signal<Sample>.
granular
(granular [source grain-duration :float grain-rate :float randomness :float])
simple granular synthesizer creating overlapping grain clouds.
| source | source audio signal to granulate | |
| grain-duration | duration of each grain in seconds | |
| grain-rate | grains spawned per second | |
| randomness | position randomisation amount (0.0 to 1.0) |
Signal<Sample> mixing all active grains.
(granular my-sig 0.05 20.0 0.3)
additive-voice
(additive-voice [base-freq :float harmonics params gate-sig])
additive synthesizer summing weighted harmonic sine waves.
| base-freq | fundamental frequency in Hz | |
| harmonics | vector of (amplitude, frequency-multiple) tuples | |
| params | ADSRParams for the overall amplitude envelope | |
| gate-sig | Signal<bool> |
Signal<Sample> summing all harmonics, shaped by the envelope.
(additive-voice 220.0 (vec-of (Tuple 1.0 1.0) (Tuple 0.5 2.0)) params gate-sig)
karplus-strong
(karplus-strong [freq :float decay :float noise-duration :float])
plucked string synthesis using a feedback delay line.
| freq | fundamental frequency in Hz | |
| decay | decay factor per averaging step (close to 1.0 for long sustain) | |
| noise-duration | duration of the initial noise burst in seconds |
Signal<Sample> simulating a plucked string.
(karplus-strong 261.63 0.995 0.01)
ks-voice
(ks-voice [freq :float decay :float noise-duration :float params gate-sig])
Karplus-Strong string with ADSR amplitude envelope.
| freq | frequency in Hz | |
| decay | per-sample decay factor | |
| noise-duration | noise burst duration in seconds | |
| params | ADSRParams | |
| gate-sig | Signal<bool> |
Signal<Sample>.
lead-synth
(lead-synth [freq :float gate-sig])
bright cutting lead synth preset.
| freq | frequency in Hz | |
| gate-sig | Signal<bool> |
Signal<Sample>.
bass-synth
(bass-synth [freq :float gate-sig])
deep warm bass synth preset.
| freq | frequency in Hz | |
| gate-sig | Signal<bool> |
Signal<Sample>.
pad-synth
(pad-synth [freq :float gate-sig])
soft evolving pad synth preset.
| freq | frequency in Hz | |
| gate-sig | Signal<bool> |
Signal<Sample>.
pluck-synth
(pluck-synth [freq :float gate-sig])
Karplus-Strong plucked string preset.
| freq | frequency in Hz | |
| gate-sig | Signal<bool> |
Signal<Sample>.
effects-chain
(effects-chain [effects input])
apply a sequence of signal processors in order.
| effects | vector of SF<Sample,Sample> processors to apply | |
| input | source signal SF<(),Sample> |
SF<(),Sample> with all effects applied in order.
(effects-chain (vec-of (gain 0.5) (low-pass 0.3)) my-osc)
example-effects-chain
(example-effects-chain [input])
demonstration chain: gain -> low-pass -> hard clip.
| input | source signal SF<(),Sample> |
SF<(),Sample>.
step-sequencer
(step-sequencer [notes tempo gate-duration])
simple monophonic step sequencer.
| notes | vector of (freq, duration) tuples defining the sequence | |
| tempo | playback tempo in beats per minute | |
| gate-duration | gate-on fraction of each note duration (0.0 to 1.0) |
Signal<Sample> playing the sequence repeatedly.
(step-sequencer (vec-of (Tuple 440.0 0.25) (Tuple 550.0 0.25)) 120.0 0.8)
Internal definitions
__sample-add__sample-mul__sample-clip