# Recipes · zvuk

zvuk v1.14.1 · MIT · https://zvuk.schmooky.dev/recipes/

Click. Hear. Copy. Paste. Six clickable patterns covering most of the engine.

Recipes

# Recipes

Click. Hear. Copy. Paste. Six clickable patterns covering most of the engine.

Every recipe below is a live React island running the actual engine. Click the buttons; hear the result; copy the snippet next to it into your project.

* * *

## 1\. Slot reel — layered SFX with timeline scheduling

sfx busidle

★

★

★

Spin

scheduleAt(t) × 5 — start whoosh, ticks, three staggered stops, win sting

Unlock & load reels

ts ts

```
engine.scheduleAt(engine.now, () => engine.sound('reel-spin').play());

// Tick during spin
for (let t = 0; t < 1.6; t += 0.12) {
  engine.scheduleAt(engine.now + t, () => engine.sound('reel-tick').play({ volume: 0.5 }));
}

// Stagger the three reel-stops
[1.0, 1.4, 1.8].forEach((delay) => {
  engine.scheduleAt(engine.now + delay, () => engine.sound('reel-stop').play({ pitch: { jitter: 0.06 } }));
});

// Win sting on top
engine.scheduleAt(engine.now + 2.1, () => engine.sound('win-sting').play({ volume: 0.9 }));
```

* * *

## 2\. Random pitch / volume jitter — make stacked SFX feel organic

Use your own sound

sfx busidle

pitch jitter±0.08volume jitter±0.10

Hit me

0 voices spawned

Unlock & load

ts ts

```
for (let i = 0; i < 6; i++) {
  engine.sound('hit').play({
    pitch:  { jitter: 0.08 },
    volume: { jitter: 0.05 },
  });
}
```

* * *

## 3\. Bus crossfade — click-free with curve

Use your own sound

music bus\-inf dB

bus outputidle

music.level0.60

write output.gain.value directly (no 10 ms ramp)

fadeTo(1, 0.6)fadeTo(0.1, 0.8)fadeTo(0, 1.2)stop voice

Unlock & start loop

ts ts

```
engine.bus('music').fadeTo(0, 1.2, 'equal-power');
```

* * *

## 4\. Voice limit + steal strategy

Use your own sound

sfx busidle

max4steal strategyoldestlowest-priorityquietestnone (reject)

active: 0 / 4spawned: 0

fire voicestop all

Unlock & load

ts ts

```
engine.bus('sfx').setConcurrency({ max: 8, steal: 'lowest-priority' });
engine.sound('hero-attack').play({ priority: 10 });
engine.sound('footstep').play({ priority: 0 });
```

* * *

## 5\. Snapshot crossfade — switch the whole mix

Use your own sound

music busidle

snapshotmenusnapshotgameplaysnapshotboss

music level: 0.80

sfx level: 0.30

Unlock & start

ts ts

```
const menu = engine.snapshot('menu', {
  buses: { music: { level: 0.8, muted: false }, sfx: { level: 0.3, muted: false } },
  parameters: {},
});
await menu.apply({ fade: 0.8 });
```

* * *

## 6\. Parameter modulator — one knob, many targets

Use your own sound

bus outputidle

parameter("intensity")0.30

bus("music").level\[0.3 → 1.0\]

0.600

reverb.wet (preview)\[0.85 → 1.15\]

1.000

Unlock & start

ts ts

```
const intensity = engine.parameter('intensity', 0.3);
intensity.bindTo((v) => engine.bus('music').level = v, { from: 0.3, to: 1, curve: 'easeInOut' });
intensity.set(0.7);
```
