LabDAW

useDemoSource

The sound a device plays: the one chosen in its session, such as from a preview's bar, else the one that shows best what the device does. It tells the session its default, so a bar can offer the choice only where there is one. Outside a session it is always the default.

pnpm dlx shadcn@latest add @audio-ui/use-demo-source
import { useDemoSource, useDemoSound } from "@/hooks/use-demo-source";
Fileshooks/use-demo-source.ts
Depends ondemo-sound, use-audio-session, use-device-loop, use-play-switch, web-audio
npmNothing
Used byblock-auto-pan, block-bass-enhancer, block-binaural-panner, block-channel-eq, block-chorus, block-compander, block-compressor, block-deesser, block-delay, block-device-chain, block-distortion, block-ducker, block-equalizer, block-exciter, block-expander, block-filter, block-frequency-shifter, block-gate, block-graphic-eq, block-limiter, block-lofi, block-mid-side, block-multiband, block-overdrive, block-phaser, block-redux, block-reverb, block-rotary, block-saturator, block-stutter, block-tilt-eq, block-transient, block-unlimiter, block-utility, block-vibe, block-wah
ExportKindWhat it is
useDemoSourcefunctionThe sound a device plays: the one chosen in its session, such as from a preview's bar, else fallback, the one that shows best what the device does.
useDemoSoundfunctionThe demo sound a device plays (useDemoSource), rendered for the page's context, with the kick that goes with it as a sidechain key when key is set: the sound of useDeviceLoop.

Usage

The sound a device plays: the one chosen in its session, such as from a preview's bar, else fallback, the one that shows best what the device does. It tells the session its fallback, so a bar offers the choice only where there is one.

import { useDemoSource } from "@/hooks/use-demo-source";

const name = useDemoSource("groove"); // one of DEMO_SOURCES

The sounds are demo-sound's, made in code. Outside a session it is always fallback.

useDemoSound(fallback, { key }) renders that sound for the page's context, with the kick that goes with it when key is set: the sound of useDeviceLoop. It renders once the session's play switch is on, so no audio context is made before a press, and is null until then.

import { useDemoSound } from "@/hooks/use-demo-source";

const sound = useDemoSound("groove");
Built by Ouest Labs, the source code is available on GitHub.
RSS