About this site
Astro · TypeScript · Web Audio API
Why the site
More than a list of works: a place that shows what 夜人 is like and that sound and software get made here, so visitors get it by touching things, without reading an explanation.
The site in brief
Works sit as icons and windows on a night-sky desktop. Works and pages open in windows, so you look around without leaving the desktop. With sound on, “夜の巣” (Yoru no Su), a song written for the site, plays along with the windows you open.
Site: details
- Never lost: each icon is also a plain link, so it all works without JavaScript
- Never interrupted: pages open inside windows too, so you stay on the desktop and music keeps playing
- Any device: on a phone it stays a desktop
- Easy on the body: reduced motion stops the animations
- Inside 夜人’s world: the sky follows the visitor’s clock, with an afterglow at dusk, every star out at midnight and a paling horizon before dawn; the moon waxes and wanes with the real one; the boot log shows this build’s real values; the terminal opens works and plays songs
Why the sound
First of all, I wanted to try interactive music. And I wanted to bring the song to people without breaking its world or making it feel like marketing. Looking around the works is what plays it, and the windows you open change what you hear. So that it never startles anyone, sound plays only when the visitor chooses it.
Sound specifications
- Song: 107 BPM, 4/4, a 16-bar loop. Stems for 10 parts
- Mapping: chord always plays; each window brings in one or two parts (DawAudioStreamer → bass, GGKeeper → kick and clap, the terminal → arpeggio, …)
- Entry: on the next beat; closing a window takes its part out in time with the beat
- Distance: parts of windows behind others sit quieter, muffled and further away. Horizontal position sets the pan, height the amount of reverb
- Sidechain: an envelope from the kick stem dips the other parts, with a depth set per part
- Ducking: down while the music player plays, a demo video has sound, or the game is open; slowly back after
- Screensaver: a low-pass and a deeper reverb push the song behind the screen
- Cues: pitches taken from the current chord’s tones, placed on a sixteenth-note grid; typing alone sounds at once
- Start and end: a 2-bar intro leads into the loop; turning sound off hands over to an outro on the next downbeat
How the sound works
“夜の巣” is split into stems, and only the parts belonging to the open windows play (vertical remixing). All stems loop from the same start time, and only each part’s gain moves. A MutationObserver picks up windows opening, closing, coming forward, moving and being dragged; changes are gathered briefly and turned into targets for gain, low-pass, pan and reverb send. A dragged window moves every frame, so its pan updates only once it has moved far enough.
The sidechain is not a compressor: an envelope of the kick stem is made in advance, loops as a low-rate buffer in sync with the stems, and is added to each part’s gain. With the kick’s part silent, the depth is zero.
Ducking follows the playback state that YouTube’s embed reports over postMessage, so pausing in the embed itself also brings the desktop song back.
Sound: key decisions
The loop seam. Opus (WebM) decoded 24 samples early compared with the WAV, so the loop’s start didn’t line up. AAC, with the encoder delay removed by the MP4 edit list, matched the WAV’s length and position to the sample, so the site uses AAC.
The reverb at switch-off. Turning sound off stopped the song but left the reverb playing, then cut it with a click: the reverb send branched off before each part’s level. Stopping now fades each take feeding the parts, and the room rings out on its own.
Quick toggling. The loop, intro and outro play as separate takes, and an old take fades out by itself. Async steps carry a generation number so an older one can’t step in late.
