tur/synth
pat->param
(pat->param [p session node-id param-index])
send a pattern value to a synth control at the current beat time.
| p | NumPattern to evaluate | |
| session | scscm session | |
| node-id | synth node ID | |
| param-index | control parameter index |
pats->params
(pats->params [session node-id param-patterns])
send multiple pattern values to synth controls.
| session | scscm session | |
| node-id | synth node ID | |
| param-patterns | list of [param-index pattern] tuples |
pats->named-params
(pats->named-params [session node-id param-map param-name->index])
send pattern values to named synth controls.
| session | scscm session | |
| node-id | synth node ID | |
| param-map | map of param-name -> [control-index pattern] | |
| param-name->index | function mapping param names to control indices |
PatternPlayer
(defstruct PatternPlayer [])
a player that triggers and controls synths from a pattern.
player-new
(player-new [session def-name pattern bpm])
create a new (stopped) pattern player.
| session | scscm session | |
| def-name | SynthDef name | |
| pattern | Pattern<map<cstr,float>> producing parameter maps | |
| bpm | tempo in beats per minute |
PatternPlayer (not yet started).
player-start
(player-start [player])
start a pattern player.
| player | PatternPlayer to start |
Updated PatternPlayer with running=true.
player-stop
(player-stop [player])
stop a pattern player and free all its synth nodes.
| player | PatternPlayer to stop |
Updated PatternPlayer with running=false.
player-update
(player-update [player new-pattern])
swap the pattern in a running player.
| player | PatternPlayer to update | |
| new-pattern | replacement pattern |
Updated PatternPlayer.
player-swap
(player-swap [player new-param-map])
atomically swap parameter-map pattern in a player.
| player | PatternPlayer to update | |
| new-param-map | new parameter map pattern |
Updated PatternPlayer.
pattern-synth
(pattern-synth [session def-name param-patterns & [bpm time/DEFAULT_BPM])
create a synth driven by pattern parameters at time 0.
| session | scscm session | |
| def-name | SynthDef name | |
| param-patterns | list of [control-index pattern] tuples | |
| bpm | tempo (default: time/DEFAULT_BPM) |
Node ID of created synth, or nil on failure.
pattern-synth-player
(pattern-synth-player [session def-name param-patterns bpm duration])
create a player that continuously updates synth parameters.
| session | scscm session | |
| def-name | SynthDef name | |
| param-patterns | list of [control-index pattern] tuples | |
| bpm | tempo | |
| duration | duration in beats |
PatternPlayer (already started).
note->freq
(note->freq [note])
convert a MIDI note number to frequency in Hz.
| note | MIDI note number (0-127; 69 = A4 = 440 Hz) |
Frequency in Hz. (note->freq 69) ; => 440.0
vel->amp
(vel->amp [vel])
convert a MIDI velocity to a linear amplitude value.
| vel | MIDI velocity (0-127) |
Amplitude in [0, 1]. (vel->amp 127) ; => 1.0
note-pattern
(note-pattern [pitch & [vel (pattern/const 100) gate (pattern/const true)])
produce a synth parameter map from pitch, velocity, and gate patterns.
| pitch | IntPattern of MIDI note numbers | |
| vel | NumPattern for velocity (default: const 100) | |
| gate | BoolPattern for gate (default: const true) |
Pattern<map> with :freq, :amp, and :gate keys. ((note-pattern (cycle 60 62 64)) 0.0)
note-pattern-dur
(note-pattern-dur [pitch vel dur & [gate (pattern/const true)])
note pattern including note duration.
| pitch | IntPattern | |
| vel | NumPattern | |
| dur | NumPattern for duration in beats | |
| gate | BoolPattern (default: const true) |
Pattern<map> with :freq, :amp, :gate, and :dur keys.
chord-pattern
(chord-pattern [& note-patterns])
stack multiple note patterns to play chords.
| note-patterns | one or more Pattern<map> to play simultaneously |
Pattern<vec<map>> with one map per note.
arp-pattern
(arp-pattern [chord & [speed 4 direction :up])
arpeggiate a chord pattern.
| chord | Pattern<vec<int>> producing MIDI note lists | |
| speed | notes per beat (default: 4 = 16th notes) | |
| direction | :up, :down, :up-down, or :random (default: :up) |
IntPattern cycling through chord tones. ((arp-pattern my-chord 4 :up) 0.0)
drum-pattern
(drum-pattern [& hits])
build a drum pattern from a list of (time, name, velocity) hits.
| hits | list of [time-in-cycle drum-name velocity] tuples |
Pattern<map> with :note and :vel keys for the active hit, or {} for silence.
drum-name->note
(drum-name->note [name])
map a drum abbreviation to a GM MIDI note number.
| name | drum name string (e.g., "bd", "sd", "hh") |
MIDI note number.
kick
(kick [& times])
kick drum pattern triggered at specific beat positions.
| times | beat positions within the cycle to trigger the kick |
Pattern<map> with {:note 36 :vel 127} on hits, {} otherwise.
((kick 0 1 2 3) 0.0)
snare
(snare [& times])
snare drum pattern triggered at specific beat positions.
| times | beat positions to trigger the snare |
Pattern<map> with {:note 38 :vel 100} on hits, {} otherwise.
((snare 1 3) 1.0)
hat
(hat [& times])
hi-hat pattern triggered at specific beat positions.
| times | beat positions to trigger the hi-hat |
Pattern<map> with {:note 42 :vel 80} on hits, {} otherwise.
((hat 0 0.5 1 1.5 2 2.5 3 3.5) 0.0)
pattern->osc
(pattern->osc [pattern session node-id time])
send a parameter map pattern to a synth node via OSC.
| pattern | Pattern<map<cstr,float>> | |
| session | scscm session | |
| node-id | synth node ID | |
| time | current time in beats |
trigger-pattern
(trigger-pattern [session def-name pattern bpm])
create a player that spawns a new synth on each pattern event.
| session | scscm session | |
| def-name | SynthDef name | |
| pattern | Pattern<map> producing parameters for each new note | |
| bpm | tempo |
PatternPlayer (already started).
freq-pattern
(freq-pattern [base-freq & [modulation (pattern/const 0)])
frequency pattern with optional additive modulation.
| base-freq | base frequency in Hz | |
| modulation | additive NumPattern (default: const 0) |
NumPattern for synth frequency.
amp-pattern
(amp-pattern [base-amp & [envelope (pattern/const 1)])
amplitude pattern with optional envelope modulation.
| base-amp | base amplitude (0-1) | |
| envelope | multiplicative NumPattern (default: const 1) |
NumPattern for synth amplitude.
pan-pattern
(pan-pattern [base-pan & [modulation (pattern/const 0)])
stereo pan pattern with optional modulation, clamped to [-1, 1].
| base-pan | base pan position (-1 = left, 0 = center, 1 = right) | |
| modulation | additive NumPattern (default: const 0) |
NumPattern clamped to [-1, 1].
synth-params
(synth-params [freq-pattern amp-pattern pan-pattern])
combine freq, amp, and pan patterns into a parameter map pattern.
| freq-pattern | NumPattern for frequency | |
| amp-pattern | NumPattern for amplitude | |
| pan-pattern | NumPattern for pan |
Pattern<map> with :freq, :amp, and :pan keys.
synth-pattern-player
(synth-pattern-player [session def-name param-patterns bpm])
create a player driven by a named parameter map.
| session | scscm session | |
| def-name | SynthDef name | |
| param-patterns | map of param-name -> pattern | |
| bpm | tempo |
PatternPlayer (already started).