# Block gate

> A gate you can plug in: its state, a panel that draws its transfer curve with a handle on the threshold and an engine that plays it. Play a loop through it and raise the threshold: the quiet parts go

A shadcn/ui block from the [@audio-ui](https://www.audio-ui.dev/?utm_source=shadcn.exchange) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/audio-ui/block-gate).

- Page, with a live preview: https://shadcn.exchange/r/audio-ui/block-gate
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/audio-ui/block-gate-light-1be830cbac43e10e.png
- Registry item: https://www.audio-ui.dev/r/new-york-v4/block-gate.json
- Listed: 2026-10-17, source last changed 2026-10-17

## Install

```bash
npx shadcn@latest add https://shadcn.exchange/r/audio-ui/block-gate.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- npm packages: `@audio-ui/react`
- Registry items: `@audio-ui/gate-panel`, `@audio-ui/gate-device`, `@audio-ui/gate-engine`, `@audio-ui/play-toggle`, `@audio-ui/use-device-loop`, `@audio-ui/use-master-bus`

## Files

### `block-gate.tsx`

```tsx
"use client";

import { useState } from "react";
import { PlayToggle } from "@/components/audio-ui/play-toggle";
import { GatePanel } from "@/components/audio-ui/devices/gate/panel";
import { useDeviceLoop } from "@/hooks/use-device-loop";
import { useMasterBus } from "@/hooks/use-master-bus";
import {
  renderHeldChord,
  renderKickLoop,
} from "@/lib/demo-loop";
import {
  type GateState,
  gateDevice,
} from "@/components/audio-ui/devices/gate/device";
import { createGateEngine } from "@/components/audio-ui/devices/gate/engine";

const MASTER_VOLUME = 0.7;
/** A held chord, opened by the kick of the loop: the key is heard by the gate only. */
const START = {
  external: true,
  floorDb: -70,
  attackMs: 1,
  holdMs: 20,
  releaseMs: 80,
  thresholdDb: -24,
};

/**
 * A gate you can plug in: its state, a panel that draws its transfer curve
 * with a handle on the threshold and an engine that plays it, each its own
 * file. It starts keyed: a held chord that the kick of the loop opens and
 * closes. Raise the threshold and the kick opens it for less time; switch the
 * key off and the gate follows the chord itself.
 */
export function BlockGate() {
  const [state, setState] = useState<GateState>(
    () => gateDevice.apply(gateDevice.defaults(), START).state
  );
  const master = useMasterBus(MASTER_VOLUME);
  const { playing, toggle } = useDeviceLoop({
    create: createGateEngine,
    destination: master,
    key: renderKickLoop,
    signal: renderHeldChord,
    state,
  });
  return (
    <div className="rounded-xl h-full w-full min-w-0">
      <GatePanel onValueChange={setState} value={state}>
        <PlayToggle
          label="Play a loop through it"
          onToggle={toggle}
          playing={playing}
        />
      </GatePanel>
    </div>
  );
}
```
