Sampler
Plays an attached WAV asset as an instrument of up to eight voices in the Toy's tuning, with a playback region, a sustain loop and ADSR.
- Source
- Since 0.2.0
- instrument
- sample
- wav
- voices
- keyboard
- loop
- tuning
An instrument made from a recording. Attach a WAV file to the node, play it from a Frame piano, the computer keyboard or MIDI, and every key plays the recording at its own pitch.
What it does#
Each note takes one of up to eight voices. A voice reads the attached file from its start, faster for higher keys and slower for lower ones, and shapes it with its own attack, decay, sustain and release. Owners and MIDI channels are kept apart, the sustain pedal holds notes, pitch bend moves them ±2 semitones, and a ninth note steals the oldest released voice first, as in the Polyphonic instrument.
The engine decodes and resamples the file once, when the Toy is prepared, so a note never waits for it. Until a file is attached the node is silent; the inspector says why when the file is missing or cannot be played.
Files it plays#
WAV only: 16, 24 or 32-bit integer or 32 and 64-bit float, one to eight channels, 8 to 192 kHz. A mono file plays on every output lane, a stereo file plays left and right on a stereo cable, and a multichannel file folds to a mono cable by its average. MP3 and FLAC are not decoded; convert them to WAV first.
Pitch and tuning#
Keys play the Toy's tuning. The root note plays the file as recorded and every other key plays it at the tuning's pitch ratio to the root: an octave up plays twice as fast, and in 19-EDO each key up is one nineteenth of an octave.
When to use it#
Use it for instruments built from a recorded sound: a piano note, a vocal syllable, a drum hit played across the keys. For one long recording that should simply play, such as a backing track, use the Audio player.
Ports#
| Port | Direction | Signal | Lanes |
|---|---|---|---|
midi | Input | MIDI | 16 MIDI channels |
audio | Output | Audio | Inferred from the cable |
Parameters#
| Parameter | Label | Range | Default | Unit | Scale | Notes |
|---|---|---|---|---|---|---|
gain | Gain | -60 to 12 | 0 | dB | linear | Level of the summed voices. -60 dB is silent. |
root | Root note | 0 to 127 | 60 | linear | The note that plays the file at its recorded pitch. Every other note plays at the tuning's ratio to it. | |
tune | Fine tune | -100 to 100 | 0 | cents | linear | Moves every note by this many cents, for this sampler only. |
start | Start | 0 to 1 | 0 | linear | Where a note starts playing, as a fraction of the file. Read when a note starts. | |
end | End | 0 to 1 | 1 | linear | Where a note stops playing, as a fraction of the file. At or before Start the region is empty and notes are silent. | |
loop | Loop | 0 to 2 | 0 | linear | Sustain loop while a note is held: off, forward, or forward and back. A released note plays on to End. Choices: 0 Off, 1 Forward, 2 Ping-pong. | |
loop_start | Loop start | 0 to 1 | 0 | linear | Start of the sustain loop, as a fraction of the file, kept inside the region. | |
loop_end | Loop end | 0 to 1 | 1 | linear | End of the sustain loop, as a fraction of the file, kept inside the region. | |
attack_ms | Attack | 0 to 10000 | 1 | ms | linear | Voice attack time. |
decay_ms | Decay | 0 to 10000 | 100 | ms | linear | Voice decay time. |
sustain | Sustain | 0 to 1 | 1 | % | linear | Held voice envelope level. Stored as a fraction; shown ×100 as a percentage. |
release_ms | Release | 0 to 10000 | 150 | ms | linear | Voice release after note-off or sustain release. |
velocity | Velocity | 0 to 1 | 1 | % | linear | How much note velocity sets a voice's level. 0 plays every note at full level. Stored as a fraction; shown ×100 as a percentage. |
voices | Voices | 1 to 8 | 8 | linear | Voices a note can take. 1 is mono with last-note priority and glide. | |
glide_ms | Glide | 0 to 2000 | 0 | ms | linear | In mono, the time a held voice takes to slide to the next note without restarting. |
mode | Mode | 0 to 1 | 0 | linear | Gate plays while the note is held. One-shot plays the region to its end and ignores note-off. Choices: 0 Gate, 1 One-shot. | |
mpe | MPE | 0 to 2 | 0 | linear | In a zone, a member channel's pitch bend moves only the voice holding that channel's note; master-channel bend moves every voice. Choices: 0 Off, 1 Lower zone, 2 Upper zone. | |
mpe_bend | MPE bend | 0 to 96 | 48 | st | linear | Semitones a full member-channel pitch bend moves its note in an MPE zone. |
asset: asset.
Gain (gain)#
The level of all voices together, from −60 dB (silent) to +12 dB. Voices add up, so a loud recording played as a chord can need a few decibels less.
Root note (root) and Fine tune (tune)#
root is the MIDI note at which the file plays at its recorded pitch; set it to the note the recording is of. tune moves every key by up to 100 cents for this sampler only.
Start (start) and End (end)#
The part of the file a note plays, as fractions of its length. A note starts at Start and stops at End, fading out over the last 2 ms so the cut does not click. An End at or before Start leaves nothing to play.
Loop (loop), Loop start (loop_start) and Loop end (loop_end)#
A sustain loop. While a key or the pedal holds a note, Forward jumps from Loop end back to Loop start and Ping-pong turns around at each end. Release the note and it plays on to End during its release. The loop points stay inside the region; a loop shorter than one sample is ignored.
Attack (attack_ms), Decay (decay_ms), Sustain (sustain) and Release (release_ms)#
The per-voice envelope, as on the Polyphonic instrument. A short Attack keeps a percussive recording's transient; a long Release lets a note ring after the key.
Velocity (velocity)#
How much note velocity sets a voice's level. At 1 a soft key plays quietly; at 0 every note plays at full level.
Voices (voices) and Glide (glide_ms)#
How many of the eight voices notes may take. At 1 the sampler is mono: the newest key wins, and releasing it returns to a key still held. With Glide above 0 a held voice slides to the next key without restarting the recording, and a new note glides from the last one.
Mode (mode)#
Gate plays while the note is held. One-shot plays the region to End for every note, ignoring note-off, the pedal and the loop: right for drum hits.
MPE (mpe) and MPE bend (mpe_bend)#
As on the Polyphonic instrument: Lower zone and Upper zone make channel 1 or channel 16 the master and the other fifteen member channels, one per sounding note. A member channel's pitch bend moves only its own note, by up to mpe_bend semitones (48 by default); the master channel's bend moves every note and its pedal holds them.
Tips#
- Set Root note to the recording's own note before anything else, or every key is transposed.
- Choose loop points where the waveform is quiet or steady; a loop at a loud transient clicks.
- One-shot with Voices 1 makes a monophonic drum pad that cuts off its own tail.
- Effects go after it on the output cable; Reverb suits plucked samples.
See also#
Audio player, Polyphonic instrument, Keyboard, MIDI, Voices.
Help patches
Each help patch is an ordinary Toy that teaches one idea. The diagram shows the Patch; the preview shows its Frame. Open it in TuneToys to play and edit it.
1. Play a sample from the keys
beginner Teaches: gain, root, tune
A recorded pluck played by the keys, pitched from its root note.
Connections as text
- Keyboard midi output connected to Sampler midi input
- Sampler audio output connected to Patch outputs audio input
- The sample is a C4 pluck. Root note 60 says so: middle C plays it as recorded and every other key plays it faster or slower.
- Gain sets the level of all voices together; Fine tune moves every key by cents.
2. Shape each note
intermediate Teaches: attack_ms, decay_ms, sustain, release_ms, velocity
An amplitude envelope per voice and velocity sensitivity over a sampled pluck.
Connections as text
- Keyboard midi output connected to Sampler midi input
- Sampler audio output connected to Patch outputs audio input
- Every voice has its own envelope: a slow attack fades the pluck in, a long release lets it ring after the key.
- Velocity 0 plays every note at full level; at 1 a soft key plays quietly.
3. Hold a note with a loop
intermediate Teaches: start, end, loop, loop_start, loop_end
A region of the sample and a sustain loop that holds while the key is down.
Connections as text
- Keyboard midi output connected to Sampler midi input
- Sampler audio output connected to Patch outputs audio input
- Start and End pick the part of the file a note plays.
- With a loop, a held key repeats Loop start to Loop end; release it and the note plays on to End.
4. Mono glide and one-shot
advanced Teaches: voices, glide_ms, mode
One voice that slides between held keys, or one-shot notes that ignore note-off.
Connections as text
- Keyboard midi output connected to Sampler midi input
- Sampler audio output connected to Patch outputs audio input
- With one voice the newest key wins; hold one key and play another to slide to it, release to slide back.
- One-shot plays the whole region for every note, however short the key press.
Related nodes
- Audio player Plays an attached WAV asset as one stream for loops, beds and backing tracks, following the transport or running free.
- Polyphonic instrument Eight owned, velocity-sensitive oscillator voices with ADSR, sustain and MPE, played from a MIDI cable in the Toy's tuning.
- Keyboard Notes from the on-screen piano and computer typing become MIDI. The face of the piano widget.
- Reverb An eight-line modulated feedback-delay network with room, hall and plate-like tunings.