Skip to content

Samplers & Samples

Load and play audio samples as drum kits or melodic instruments.

A reference to a single drum sample slot. Obtained via .slot() on a Sampler (e.g. kit.slot("bd")).

fn param(name: String) -> InstrumentParam

Returns 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

fn param_get(name: String) -> Number

Gets 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

fn param_set(name: String, value: Number) -> DrumSample

Sets 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

fn params(filter: String?) -> Array

Returns the available parameter names for this slot.

Parameters:

  • filter (String) — substring filter (optional)

Returns: Array — the available parameter names as Strings

fn envelope(attack_ms: Number, decay_ms: Number, sustain: Number, release_ms: Number) -> DrumSample

Sets the ADSR envelope for this sample.

Parameters:

  • attack_ms (Number) — attack time in milliseconds
  • decay_ms (Number) — decay time in milliseconds
  • sustain (Number) — sustain level (0.0-1.0)
  • release_ms (Number) — release time in milliseconds

Returns: DrumSample — the slot reference, for chaining

fn name() -> String

Returns the sample name.

Returns: String — the sample name

fn note() -> Number

Returns the MIDI note number for this sample.

Returns: Number — the MIDI note mapped to this sample

An audio sample loaded from a WAV file. Construct with Sample("path/to/file.wav"). All methods return a new Sample (immutable transforms).

fn Sample(path: String) -> Sample

Loads 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) -> Sample

Returns 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

fn reverse() -> Sample

Returns the sample playing backwards (toggles on each call).

Returns: Sample — a new sample with reversed playback

fn pitch(semitones: Number) -> Sample

Pitch-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) -> Sample

Sets the sample velocity.

Parameters:

  • velocity (Number) — velocity level (non-negative)

Returns: Sample — a new sample at the given velocity

fn pan(position: Number) -> Sample

Sets 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

A CLAP drum sampler plugin with per-sample note mapping. Construct with Sampler(Kit("kit_name")).

fn Sampler(kit: Kit or String) -> Sampler

Creates 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

fn samples() -> Array

Returns an array of loaded sample names.

Returns: Array — the loaded sample names as Strings

fn sample_info() -> Array

Returns an array of [name, note, file] for each sample.

Returns: Array — one [name, note, file] entry per sample

fn note_for(name: String) -> Number

Returns the MIDI note number for the given sample name.

Parameters:

  • name (String) — sample name

Returns: Number — the MIDI note mapped to that sample

fn set_note(name: String, new_note: Number) -> Sampler

Remaps a sample to a different MIDI note.

Parameters:

  • name (String) — sample name
  • new_note (Number) — MIDI note number to assign

Returns: Sampler — the sampler, for chaining

fn name() -> String

Returns the kit name.

Returns: String — the kit name

fn param(name: String) -> InstrumentParam

Returns 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

fn param_get(name: String) -> Number

Gets a parameter value by raw path.

Parameters:

  • name (String) — parameter path (e.g. “slot_0/gain”)

Returns: Number — the current parameter value

fn param_set(name: String, value: Number) -> Sampler

Sets 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

fn param_set_norm(name: String, value: Number) -> Sampler

Sets 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

fn params(filter: String?) -> ParamList

Returns 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) -> Sample

Gets a sample by name.

Parameters:

  • name (String) — sample name

Returns: Sample — the named sample

fn choke_group(group: Number, samples: Array) -> Sampler

Assigns 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

fn load_kit(kit: Kit) -> Sampler

Loads a kit into the sampler.

Parameters:

  • kit (Kit) — the kit to load

Returns: Sampler — the sampler, for chaining

fn slot(name: String) -> DrumSample

Returns a reference to a drum sample slot by name.

Parameters:

  • name (String) — slot name

Returns: DrumSample — a reference to the named slot

A CLAP melodic sampler plugin with pitch-shifting. Construct with SamplerMelodic(Kit("kit_name")) or SamplerMelodic() for empty.

fn SamplerMelodic(kit: Kit or String) -> SamplerMelodic

Creates 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

fn load_sample(name: String, root_note: Number) -> SamplerMelodic

Loads a sample from the kit directory.

Parameters:

  • name (String) — sample name
  • root_note (Number) — root note for pitch mapping (optional)

Returns: SamplerMelodic — the sampler, for chaining

fn envelope(attack_ms: Number, decay_ms: Number, sustain: Number, release_ms: Number) -> SamplerMelodic

Sets the ADSR envelope for the current sample.

Parameters:

  • attack_ms (Number) — attack time in milliseconds
  • decay_ms (Number) — decay time in milliseconds
  • sustain (Number) — sustain level (0.0-1.0)
  • release_ms (Number) — release time in milliseconds

Returns: SamplerMelodic — the sampler, for chaining

fn root(note: Number) -> SamplerMelodic

Overrides the root note for the current sample.

Parameters:

  • note (Number) — MIDI note number for the root pitch

Returns: SamplerMelodic — the sampler, for chaining

fn samples() -> Array

Returns an array of loaded sample names.

Returns: Array — the loaded sample names as Strings

fn sample_info() -> Array

Returns an array of [name, root_or_nil, file] for each sample.

Returns: Array — one [name, root_or_nil, file] entry per sample

fn root_for(name: String) -> Number

Returns 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() -> String

Returns the plugin name.

Returns: String — the plugin name

fn param(name: String) -> InstrumentParam

Returns a parameter reference by name.

Parameters:

  • name (String) — parameter name (e.g. “RootNote”, “Gain”)

Returns: InstrumentParam — supports .get(), .set(), and << for modulation

fn param_get(name: String) -> Number

Gets 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

fn param_set(name: String, value: Number) -> SamplerMelodic

Sets 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

fn param_set_norm(name: String, value: Number) -> SamplerMelodic

Sets 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

fn params(filter: String?) -> ParamList

Returns 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) -> Sample

Gets a sample by name.

Parameters:

  • name (String) — sample name

Returns: Sample — the named sample

fn load_kit(kit: Kit) -> SamplerMelodic

Loads a kit into the sampler.

Parameters:

  • kit (Kit) — the kit to load

Returns: SamplerMelodic — the sampler, for chaining

fn set_loop(start_secs: Number, end_secs: Number) -> SamplerMelodic

Sets the loop region in seconds.

Parameters:

  • start_secs (Number) — loop start time in seconds
  • end_secs (Number) — loop end time in seconds

Returns: SamplerMelodic — the sampler, for chaining

fn set_loop_normalized(start: Number, end: Number) -> SamplerMelodic

Sets 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) -> Kit

Loads 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()