# drum-rack

> Drum racks: an instrument whose chains are pads, each answering a note with the instrument at its head, such as a Drum Synth, or else a voice of the drum synthesis or a recording, into its own devices, a pad of a choke group cutting the others short; the engine that plays one on a MIDI track.

```bash
npx shadcn@latest add @audio-ui/drum-rack
```

```ts
import { padsOf, createDrumRackEngine } from "@/lib/drum-rack";
```

- Files: `lib/drum-rack.ts`
- Depends on: `arrangement`, `drum-synthesis`, `instrument-rack`, `rack`, `voice-pool`; npm: `@audio-ui/engine`
- Used by: `arrangement-engine`

| Export | Kind | What it is |
| --- | --- | --- |
| `PadRecording` | type | A recording a pad plays: an `AudioBuffer`, or its channels decoded. |
| `padsOf` | function | The pads of a drum rack that a note plays: the chains that answer it. |
| `DrumRackEngine` | interface | A drum rack playing on a context: a note player whose note on plays the pads of its pitch, as loud as its velocity, and rings for their decay; a note off lets nothing go, and `release` takes back the hits that start after its time, as a stop does, those sounding ringing out. |
| `createDrumRackEngine` | function | Plays drum racks on `ctx`. |

## Usage

An instrument of pads: each chain answers a note with the instrument at its head (a [Drum Synth](/docs/components/base/drum-synth), say), or a voice of the drum synthesis or a recording, into its own devices, summed as a rack with its macros. A pad of a choke group cuts the others short.

```ts
import { createDrumRackEngine, padsOf } from "@/lib/drum-rack";

const drums = createDrumRackEngine(ctx, libraryDevice);
drums.output.connect(destination);
drums.update(rack, { tempo });
const pads = padsOf(rack, 36); // the chains a note plays
```

Start a rack from [`drum-kit`](/docs/lib/drum-kit); its face is the [Drum rack panel](/docs/components/base/rack#drum-racks), and the [arrangement engine](/docs/lib/arrangement-engine) plays it on a MIDI track.
