Audio UI
Puts the sound in a room. It is a device: a state, a panel, an engine and tools, each its own file.
Installation
Copy to Clipboardpnpm dlx shadcn@latest add @audio-ui/reverb
It installs the device's state, its engine and its panel to components/audio-ui/devices/reverb/. The demo above, which wires them to a loop, is @audio-ui/block-reverb.
Controls
Controls · 6
Panel
The panel draws the level of the tail falling in dB, from the end of the pre-delay to -60 dB, and picks the type in its title bar. reverbDecay(state) is the curve it draws, and reverbImpulse(sampleRate, state) makes the impulse response of the room.
Copy to Clipboardimport { ReverbPanel } from "@/components/audio-ui/devices/reverb/panel"; import { reverbDevice } from "@/components/audio-ui/devices/reverb/device"; const [state, setState] = useState(() => reverbDevice.defaults()); <ReverbPanel onValueChange={setState} value={state} />;
Engine
Create it, connect it and update it as for any device: see The engine.
The room is a convolver fed an impulse response made from the type, the decay and the damping. Room is noise shaped to the decay. Every other type is its own algorithm rung by a click, from @audio/reverb-dattorro, @audio/reverb-fdn, @audio/reverb-spring, @audio/reverb-freeverb and @audio/reverb-schroeder, its feedback set so the tail falls by 60 dB over the decay time. These algorithms hold no modulation, so the impulse response is the algorithm itself, and every type plays at the cost of one convolver. A plate, a spring and a Freeverb ring for half a second at the least: a shorter decay brings their tail down along the same exponential. A spring longer than about 9 s stops at that.
A convolver cannot change its impulse without a click, so the engine has two and cross-fades: a new room is built in the idle one once a control has rested for 120 ms. Building a type other than Room takes a few tens of milliseconds for a long decay.