04 · press · players
Tape recorder Pro
Press play and the tape winds between smoked acrylic reels over a wound pack, on a satin metal body with neutral keys; scrub the waveform and the reels turn under your hand, record and your voice writes itself into the track in red. The only colour is light: amber in the play key's LED and the head line, red while recording.
Install
npx shadcn@latest add @mu-pro/tape-recorderPro. Installs with a licence key through the @mu-pro registry. Checkout opens soon: until then Pro installs are closed, and nothing can be bought on this site.
Usage
import { TapeRecorder } from "@/components/mu/tape-recorder/TapeRecorder";
<TapeRecorder
tracks={[{ title: "Night drive", duration: 152 }, { title: "Low orbit", duration: 188 }]}
/>How it works
Input and reduced motion
- Pointer / touch: play or pause, previous and next (previous rewinds to the start first if you're past three seconds), stop rewinds to the start, record starts recording. Next fast-forwards to the end of the tape, then the packs and playhead glide to the new track's start; pressing again while it winds skips at once, so every press counts. Drag along the waveform to scrub: the reels turn under your hand, and a press more than two seconds away winds there.
- Keyboard: every key is a button; the waveform is a slider (arrow keys move 5s, Shift moves 15s, Page Up and Page Down 30s, Home and End go to the ends). A held arrow key keeps building on where it was going.
- Reduced motion: the reels don't spin, rewinds and track changes jump, and titles and waveforms swap at once; the tape packs, playhead and timecode still follow the song, and a recording fills in a bar at a time. The REC lamp stays lit instead of blinking, and a wind makes no whirr.
- Off-screen, the frame loop and the REC lamp's blink pause until the recorder is back in view. At rest nothing repaints.
The transport
One state owns the machine: stopped, playing, recording, paused-recording or winding (a wind carries where it is going and the state it returns to). Keys, the record lamp and LED, the counter, the reels, the play key's glyph and the waveform all follow it, so two states can never show at once. tapeTransport (the reducer) and its types are exported.
- Record from stopped or playing starts recording (record and play together, like a deck). Record while recording does nothing; the key stays latched.
- While recording the tape runs, the REC lamp blinks, the record key and the play key's LED glow red, the counter climbs, the reels turn, and the level writes itself into the waveform in red behind the head, replacing the track's bars over the recorded span.
- Play while recording pauses the take: the tape coasts to a hold and the lamp stays lit. Play or record resumes it. Play never starts a separate playback during a recording.
- Stop ends recording and playback from any state, and rewinds to the start.
- Previous, next and scrubbing are disabled while recording or paused (dimmed, no press).
- Any key interrupts a wind, which then acts on the state the wind came from. The end of the tape stops a recording; playback moves on to the next track.
- A polite live region announces "Recording", "Recording paused", "Recording resumed" and "Recording stopped" (set them in
labels).
The waveform
The scrubber is the current track's waveform: fine mirrored bars, 1.5px wide on a 4px pitch and up to 28px tall, so the count follows the width and every bar lands on whole device pixels. Behind the head the bars are in ink, ahead of it in the faint line colour. A take is kept per track for the session (in memory): while recording it is bright red, and on playback it is a dimmer red, a solid mix of the red into the panel. Prev, next and scrubbing are off while recording, so the strip stays at full strength to show the take.
The reels
The reels are one canvas, drawn at one backing pixel per device pixel. Each pack keeps its area, so the emptier reel turns faster; both turn clockwise as the tape plays and back as it rewinds. A reel turns at most 20° a frame, and within a frame its windows and hub teeth are drawn as a motion blur, so a fast wind reads as a smear and never runs backwards. Everything that doesn't turn (head, guides, shadows, rims, hubs, the acrylic's gloss, a full reel's wound layers) is baked once per size and theme, so a frame draws only what moves; the canvas paints only while the machine moves, and is drawn sharp once it parks. Glows use canvas shadows rather than filters, so Safari draws them too.
The drawing lives in reels.ts and runs on a worker (the canvas is handed over; in Safari the worker sends bitmaps back), so while the tape runs the page's thread only passes a message a frame. Bundlers that support new Worker(new URL("./reels.ts", import.meta.url)) (Vite, Next.js with Turbopack or webpack 5, Parcel) get the worker, shipped beside the component as reels.ts; the canvas is handed over only after the worker's first frame. If a bundler can't make the worker, a Content Security Policy refuses it (worker-src), it fails, or it sends no first frame within half a second, the same code draws on the page on a fresh canvas instead, so the reels never stay blank and the fallback never throws. Under a worker-src 'none' policy the browser still logs its own refusal.
On the page's thread, at a 4× slower CPU on a 3× phone: about 46 ms a second playing, 69 recording and 110 for the 1.2s of a wind with its track change (82, 143 and 201 in headless Chromium with a GPU, whose compositor path costs more); about 0 at rest and off-screen.
Props
| Prop | Default | What it does |
|---|---|---|
tracks | five demo tracks | { title, duration, peaks? }: duration in seconds; peaks is the track's waveform, numbers 0–1 of any length, resampled to the bars (without it, each track gets its own seeded song-like waveform) |
device | "RTT—02" | the name in the status bar |
onTrackChange | — | called with the new track index |
level | simulated voice | () => number, the live input level 0–1, read every frame while recording (for example from a microphone analyser); without it, a simulated voice in syllables, phrases and pauses |
labels | English | accessible names { play, pause, resume, prev, next, stop, record, seek }, and what a screen reader hears as recording changes { recording, recordingPaused, recordingResumed, recordingStopped } |
sound | off | key clunks and the wind's whirr: true, or a volume 0–1 (see Sound) |
className | — | added to the root |
Sound
Off by default. With sound (or a volume, sound={0.5}) every key that can press clunks, record arms with a heavier double latch when it starts a take, and a wind (stop, next, previous, a far press on the waveform, the slider keys) whirrs for exactly as long as the tape winds. The whirr runs down when the wind ends or is cut short, and stops if the recorder leaves the view. The end of a track is silent. setMuted(true) from components/mu/sounds.ts silences every cottoncandy item at once.
Licence
Included with Pro: use it in unlimited end products for you and your clients; no reselling as a kit. See the licence.