Skip to content

Sampler engine

The sampler plays a kit: sixteen pads, each with one or more WAV files on the SD card. It is part of crosspad-core, and the board gives it only the bytes from the card and the memory to hold them.

When a kit loads, the engine reads the start of every sample, its head, into RAM. A pad hit starts from the head at once, without waiting for the card, and the rest of the sample streams from the card while the head plays.

A sample shorter than its head is held whole. It never goes back to the card, however often you hit it. Most drum hits are like this.

The engine gives each sample a head of up to 256 kB, about 1.45 s of 44.1 kHz stereo. For a large kit it halves the heads as often as it takes for the whole kit to fit, so every kit loads.

  • Up to 16 voices sound at once. Up to 10 of them may stream from the card at the same time; samples held whole in RAM do not count toward the 10.
  • A new hit above the limit takes the place of the oldest voice. That voice fades out over a few milliseconds, so the change makes no click.
  • Hitting a pad again restarts it.
  • A one-shot that has been silent for 200 ms stops, and the rest of its file is not read. A looped or held pad plays on.
  • A pad’s pitch (−12 to +12 semitones) plays in real time: the engine reads the sample faster or slower. As on a turntable, a higher pad is also shorter.
  • Reverse and the HP and LP filters are rendered once into a copy of the sample, in a hidden .fx folder next to it. The pad plays that copy. The copy is made when you change the setting or when the kit loads.
  • Pick a kit while another is loading, and the CrossPad loads your newest pick as soon as the current load is done. Kits you scrolled past are not loaded.
  • Pads that are sounding keep sounding. A pad that is not swapped at that moment plays the outgoing kit, and its light is dimmed and breathing. Each sounding pad is swapped when its sound ends, at the latest 4 s after the swap starts: a looped pad never ends by itself.
  • A pitched kit replaces the whole engine, so a change to or from a pitched kit stops the sounding pads first.
  • Pad hits from every source (a finger, USB or Bluetooth MIDI, the sequencer) reach the engine the same way. Pad logic that has to tell a finger from the sequencer reads PadManager::pressSource(pad).
  • The engine renders inside the audio engine’s block. See Audio engine: 44.1 kHz for the timing rules every audio node follows.