# drum-synthesis

> One-shot percussion synthesis (kick, snare, hihat) built from oscillators and noise bursts, each with its own tune and decay

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

```ts
import { triggerClick, triggerKick, triggerSnare, triggerHihat } from "@/lib/drum-synthesis";
```

- Files: `lib/drum-synthesis.ts`
- Depends on: nothing; npm: nothing
- Used by: `arrangement-engine`, `block-drum-rack`, `demo-sound`, `drum-rack`, `pad-demo`, `sequencer`, `use-piano-roll-playback`

| Export | Kind | What it is |
| --- | --- | --- |
| `DrumOptions` | interface | Shapes one hit: `tune` in semitones from the voice's own pitch, `decay` in seconds. |
| `triggerClick` | function | A metronome's click at `time` on the audio clock, higher on the first beat of a bar. |
| `triggerKick` | function | Sine oscillator with a fast pitch sweep (150Hz→40Hz) and exponential amplitude decay, a classic 808-style kick. |
| `triggerSnare` | function | Band-passed noise burst for body plus a short triangle "click" for attack transient. |
| `triggerHihat` | function | High-passed noise burst, a closed-hihat-style tick by default; a longer `decay`, such as 0.5 seconds, rings like an open hihat. |

## Usage

A kick, a snare and a hihat made from oscillators and noise, with no samples to load. Each starts at `time` and plays out on its own.

```tsx
import { triggerHihat, triggerKick, triggerSnare } from "@/lib/drum-synthesis";

triggerKick(ctx, output, time);
triggerSnare(ctx, output, time, { tune: 2 });
triggerHihat(ctx, output, time, { decay: 0.5 }); // a longer decay rings open
```

`tune` shifts a hit in semitones from its own pitch and `decay` sets how long it lasts, in seconds. The [Pad](/docs/components/base/pad) page plays a kit with them.
