Samplers & Samples
Load and play audio samples as drum kits or melodic instruments.
DrumSample
Section titled “DrumSample”A reference to a single drum sample slot. Obtained via .slot() on a Sampler (e.g. kit.slot("bd")).
fn param(name: String) -> InstrumentParamReturns a parameter reference for this slot.
Parameters:
name(String) — parameter name: “gain”, “pan”, “attack”, “decay”, “sustain”, “release”, “slice_start”, “slice_end”, “reverse”
Returns: InstrumentParam — supports .get(), .set(), and << for modulation
param_get
Section titled “param_get”fn param_get(name: String) -> NumberGets a parameter value by name (shorthand for .param(name).get()).
Parameters:
name(String) — parameter name (e.g. “gain”, “pan”, “attack”)
Returns: Number — the current parameter value
param_set
Section titled “param_set”fn param_set(name: String, value: Number) -> DrumSampleSets a parameter value by name.
Parameters:
name(String) — parameter name (e.g. “gain”, “pan”, “attack”)value(Number) — new parameter value
Returns: DrumSample — the slot reference, for chaining
params
Section titled “params”fn params(filter: String?) -> ArrayReturns the available parameter names for this slot.
Parameters:
filter(String) — substring filter (optional)
Returns: Array — the available parameter names as Strings
envelope
Section titled “envelope”fn envelope(attack_ms: Number, decay_ms: Number, sustain: Number, release_ms: Number) -> DrumSampleSets the ADSR envelope for this sample.
Parameters:
attack_ms(Number) — attack time in millisecondsdecay_ms(Number) — decay time in millisecondssustain(Number) — sustain level (0.0-1.0)release_ms(Number) — release time in milliseconds
Returns: DrumSample — the slot reference, for chaining
fn name() -> StringReturns the sample name.
Returns: String — the sample name
fn note() -> NumberReturns the MIDI note number for this sample.
Returns: Number — the MIDI note mapped to this sample
Sample
Section titled “Sample”An audio sample loaded from a WAV file. Construct with Sample("path/to/file.wav"). All methods return a new Sample (immutable transforms).
Constructor
Section titled “Constructor”fn Sample(path: String) -> SampleLoads an audio sample from a WAV file.
Parameters:
path(String) — path to the .wav file
Returns: Sample — the loaded sample (transform with .slice(), .pitch(), .vel(), .pan(), .reverse())
fn slice(start: Number, end: Number) -> SampleReturns a sample playing a portion from start to end.
Parameters:
start(Number) — slice start position (0.0-1.0)end(Number) — slice end position (0.0-1.0)
Returns: Sample — a new sample playing only the sliced portion
reverse
Section titled “reverse”fn reverse() -> SampleReturns the sample playing backwards (toggles on each call).
Returns: Sample — a new sample with reversed playback
fn pitch(semitones: Number) -> SamplePitch-shifts the sample by the given number of semitones. Accumulates across multiple calls.
Parameters:
semitones(Number) — semitone offset (positive = up, negative = down)
Returns: Sample — a new pitch-shifted sample
fn vel(velocity: Number) -> SampleSets the sample velocity.
Parameters:
velocity(Number) — velocity level (non-negative)
Returns: Sample — a new sample at the given velocity
fn pan(position: Number) -> SampleSets the pan position.
Parameters:
position(Number) — pan position (-1.0 = left, 0.0 = center, 1.0 = right, clamped)
Returns: Sample — a new sample at the given pan position
Sampler
Section titled “Sampler”A CLAP drum sampler plugin with per-sample note mapping. Construct with Sampler(Kit("kit_name")).
Constructor
Section titled “Constructor”fn Sampler(kit: Kit or String) -> SamplerCreates a drum sampler instrument. No-arg form creates an empty sampler (use .load_kit() to load a kit later).
Example:
Sampler() — empty sampler Sampler(“CR-78”) — sampler with kit (shorthand) Sampler(Kit(“CR-78”)) — sampler with kit
Parameters:
kit(Kit | String) — kit value, or a kit name string as shorthand (optional)
Returns: Sampler — the drum sampler
samples
Section titled “samples”fn samples() -> ArrayReturns an array of loaded sample names.
Returns: Array — the loaded sample names as Strings
sample_info
Section titled “sample_info”fn sample_info() -> ArrayReturns an array of [name, note, file] for each sample.
Returns: Array — one [name, note, file] entry per sample
note_for
Section titled “note_for”fn note_for(name: String) -> NumberReturns the MIDI note number for the given sample name.
Parameters:
name(String) — sample name
Returns: Number — the MIDI note mapped to that sample
set_note
Section titled “set_note”fn set_note(name: String, new_note: Number) -> SamplerRemaps a sample to a different MIDI note.
Parameters:
name(String) — sample namenew_note(Number) — MIDI note number to assign
Returns: Sampler — the sampler, for chaining
fn name() -> StringReturns the kit name.
Returns: String — the kit name
fn param(name: String) -> InstrumentParamReturns a parameter reference by raw path. Tip: use .slot(“bd”).param(“gain”) for named access.
Parameters:
name(String) — parameter path (e.g. “slot_0/gain”, “slot_1/attack”)
Returns: InstrumentParam — supports .get(), .set(), and << for modulation
param_get
Section titled “param_get”fn param_get(name: String) -> NumberGets a parameter value by raw path.
Parameters:
name(String) — parameter path (e.g. “slot_0/gain”)
Returns: Number — the current parameter value
param_set
Section titled “param_set”fn param_set(name: String, value: Number) -> SamplerSets a parameter value by raw path.
Parameters:
name(String) — parameter path (e.g. “slot_0/gain”)value(Number) — new value in the parameter’s native range
Returns: Sampler — the sampler, for chaining
param_set_norm
Section titled “param_set_norm”fn param_set_norm(name: String, value: Number) -> SamplerSets a parameter value using a normalized [0,1] input.
Parameters:
name(String) — parameter path (e.g. “slot_0/gain”)value(Number) — normalized value (0.0 to 1.0)
Returns: Sampler — the sampler, for chaining
params
Section titled “params”fn params(filter: String?) -> ParamListReturns a ParamList with all sampler parameters.
Parameters:
filter(String) — only include parameters whose name contains this substring (optional)
Returns: ParamList — parameter data (columns: Parameter, Value, Range, Default)
fn get(name: String) -> SampleGets a sample by name.
Parameters:
name(String) — sample name
Returns: Sample — the named sample
choke_group
Section titled “choke_group”fn choke_group(group: Number, samples: Array) -> SamplerAssigns samples to a choke group. Samples in the same group cut each other off (e.g. open/closed hi-hat).
Parameters:
group(Number) — choke group ID (1+)samples(Array) — sample names in the group
Returns: Sampler — the sampler, for chaining
load_kit
Section titled “load_kit”fn load_kit(kit: Kit) -> SamplerLoads a kit into the sampler.
Parameters:
kit(Kit) — the kit to load
Returns: Sampler — the sampler, for chaining
fn slot(name: String) -> DrumSampleReturns a reference to a drum sample slot by name.
Parameters:
name(String) — slot name
Returns: DrumSample — a reference to the named slot
SamplerMelodic
Section titled “SamplerMelodic”A CLAP melodic sampler plugin with pitch-shifting. Construct with SamplerMelodic(Kit("kit_name")) or SamplerMelodic() for empty.
Constructor
Section titled “Constructor”fn SamplerMelodic(kit: Kit or String) -> SamplerMelodicCreates a melodic sampler. No-arg form creates an empty sampler (use .load_kit() to load a kit later). Pitch-shifts a single sample for melodic playback.
Example:
SamplerMelodic() — empty sampler SamplerMelodic(“bass”) — sampler with kit (shorthand) SamplerMelodic(Kit(“bass”)) — sampler with kit
Parameters:
kit(Kit | String) — kit value, or a kit name string as shorthand (optional)
Returns: SamplerMelodic — the melodic sampler
load_sample
Section titled “load_sample”fn load_sample(name: String, root_note: Number) -> SamplerMelodicLoads a sample from the kit directory.
Parameters:
name(String) — sample nameroot_note(Number) — root note for pitch mapping (optional)
Returns: SamplerMelodic — the sampler, for chaining
envelope
Section titled “envelope”fn envelope(attack_ms: Number, decay_ms: Number, sustain: Number, release_ms: Number) -> SamplerMelodicSets the ADSR envelope for the current sample.
Parameters:
attack_ms(Number) — attack time in millisecondsdecay_ms(Number) — decay time in millisecondssustain(Number) — sustain level (0.0-1.0)release_ms(Number) — release time in milliseconds
Returns: SamplerMelodic — the sampler, for chaining
fn root(note: Number) -> SamplerMelodicOverrides the root note for the current sample.
Parameters:
note(Number) — MIDI note number for the root pitch
Returns: SamplerMelodic — the sampler, for chaining
samples
Section titled “samples”fn samples() -> ArrayReturns an array of loaded sample names.
Returns: Array — the loaded sample names as Strings
sample_info
Section titled “sample_info”fn sample_info() -> ArrayReturns an array of [name, root_or_nil, file] for each sample.
Returns: Array — one [name, root_or_nil, file] entry per sample
root_for
Section titled “root_for”fn root_for(name: String) -> NumberReturns the root note for the given sample, or nil.
Parameters:
name(String) — sample name
Returns: Number — the root note for that sample, or nil if unset
fn name() -> StringReturns the plugin name.
Returns: String — the plugin name
fn param(name: String) -> InstrumentParamReturns a parameter reference by name.
Parameters:
name(String) — parameter name (e.g. “RootNote”, “Gain”)
Returns: InstrumentParam — supports .get(), .set(), and << for modulation
param_get
Section titled “param_get”fn param_get(name: String) -> NumberGets a parameter value by name (shorthand for .param(name).get()).
Parameters:
name(String) — parameter name (e.g. “RootNote”, “Gain”)
Returns: Number — the current parameter value
param_set
Section titled “param_set”fn param_set(name: String, value: Number) -> SamplerMelodicSets a parameter value by name.
Parameters:
name(String) — parameter name (e.g. “RootNote”, “Gain”)value(Number) — new value in the parameter’s native range
Returns: SamplerMelodic — the sampler, for chaining
param_set_norm
Section titled “param_set_norm”fn param_set_norm(name: String, value: Number) -> SamplerMelodicSets a parameter value using a normalized [0,1] input.
Parameters:
name(String) — parameter name (e.g. “RootNote”, “Gain”)value(Number) — normalized value (0.0 to 1.0)
Returns: SamplerMelodic — the sampler, for chaining
params
Section titled “params”fn params(filter: String?) -> ParamListReturns a ParamList with all sampler parameters.
Parameters:
filter(String) — only include parameters whose name contains this substring (optional)
Returns: ParamList — parameter data (columns: Parameter, Value, Range, Default)
fn get(name: String) -> SampleGets a sample by name.
Parameters:
name(String) — sample name
Returns: Sample — the named sample
load_kit
Section titled “load_kit”fn load_kit(kit: Kit) -> SamplerMelodicLoads a kit into the sampler.
Parameters:
kit(Kit) — the kit to load
Returns: SamplerMelodic — the sampler, for chaining
set_loop
Section titled “set_loop”fn set_loop(start_secs: Number, end_secs: Number) -> SamplerMelodicSets the loop region in seconds.
Parameters:
start_secs(Number) — loop start time in secondsend_secs(Number) — loop end time in seconds
Returns: SamplerMelodic — the sampler, for chaining
set_loop_normalized
Section titled “set_loop_normalized”fn set_loop_normalized(start: Number, end: Number) -> SamplerMelodicSets the loop region using normalized [0,1] positions.
Parameters:
start(Number) — loop start position (0.0-1.0)end(Number) — loop end position (0.0-1.0)
Returns: SamplerMelodic — the sampler, for chaining
fn Kit(kit_name: String) -> KitLoads kit metadata (samples, notes, files) without creating a plugin.
Parameters:
kit_name(String) — name of the kit (optional, defaults to “CR-78”)
Returns: Kit — kit metadata, inspectable or passable to Sampler()/SamplerMelodic()