Pocket synth

A synth device: a waveform, a filter and a volume, a panel with a pad that plays it, a Web Audio engine with noteOn and noteOff, and tools for agents.

Audio UI

One oscillator through a resonant filter. Press the pad: the pitch goes across and the filter cutoff goes up. It is a device: a state, a panel, an engine and tools, each its own file.

Installation

pnpm dlx shadcn@latest add @audio-ui/pocket-synth

It installs the device's state, its engine and its panel to components/audio-ui/devices/pocket-synth/. The demo above, which wires them to a loop, is @audio-ui/block-pocket-synth.

Controls

Controls · 3

Panel

The panel has a pad that plays the synth: its position gives the note, so the pitch goes across and the cutoff goes up. pocketSynthPitch(position) and pocketSynthCutoff(position) turn a position from 0 to 1 into hertz. The panel sends notes out and does not make the sound, so it plays through any engine.

import { PocketSynthPanel } from "@/components/audio-ui/devices/pocket-synth/panel";
import { pocketSynthDevice } from "@/components/audio-ui/devices/pocket-synth/device";

const [state, setState] = useState(() => pocketSynthDevice.defaults());

<PocketSynthPanel onValueChange={setState} value={state} />;

Engine

Create it, connect it and update it as for any device: see The engine.

engine.noteOn(note); // starts a note, or glides the one being held
engine.noteOff(); // lets it go

One voice at a time. noteOn starts a note, or glides the one being held to the new one, and noteOff releases it. The wave and the filter type of a state change under a held note. An agent plays the synth with the play tool.

Built by Ouest Labs, the source code is available on GitHub.
RSS