Technical notes✕
←

Technical notes

How the software and games I made work inside.

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.

Signal flow of the YoruOS sound. Each part's stem goes through level, low-pass, pan and sidechain dip into the song bus, then through ducking, the screensaver low-pass, the volume and a limiter to the output. A reverb send leaves after the pan; cues join before the ducking. Window state drives each part's level, low-pass, pan and send; other audio drives the ducking; the screensaver drives the last low-pass. windows: open · front · x · y · drag loop / intro / outro player/demo/game screensaver slider stems ×10 level low-pass pan dip song bus reverb send kick envelope cues duck veil master limiter → out per part · AAC on the grid

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.

OtoShot

C++20 · WASAPI · Win32

Motivation

When something great plays in a game or a call, it’s gone unless you were recording. Screens have screenshots; sound didn’t. I wanted anyone to be able to keep a sound that just played and pass it on, casually. Keeping it is one key; the silence at both ends is trimmed for you, and you just paste or drag it.

Overview

A Windows app that rewinds to the sound your PC just played and copies it to the clipboard as a WAV with a hotkey.

Specifications

  • Output: WAV (linear PCM, 16-bit integer, 48 kHz, 2 ch), no dither
  • Internal format: 32-bit float, 48 kHz, 2 ch; 64 seconds (about 24.6 MB) kept in memory per stream
  • Capture: WASAPI shared-mode loopback (the signal after the OS mixer); devices not at 48 kHz are resampled with linear interpolation
  • Downmix: center and surrounds at −3 dB; LFE not included
  • Silence trimming: removes the leading and trailing parts where the RMS in 10 ms windows stays below −50 dBFS, leaving 150 ms of margin
  • Cut edges: 2.5 ms fades
  • Level: if any sample exceeds 0 dBFS, the whole clip is lowered instead of clipping
  • Handoff: placed on the clipboard as a file (CF_HDROP), so it pastes straight into a DAW or a chat

How it works

OtoShot captures what is playing (and, when needed, the microphone and a call device) with WASAPI, keeping the last 64 seconds of each stream in a ring buffer in memory. When the hotkey is pressed, it takes the last N seconds, removes the silence at both ends, writes a WAV, and places it on the clipboard as a file.

OtoShot ring buffers: playback, call device and microphone streams on a shared clock; the hotkey takes the last N seconds. rendercommsmic loopbackoptionaloptional ring · 64 sring · 64 sring · 64 s copy: last N s shared process clock

Key decisions

Because it captures continuously in the background, the capture thread avoids memory allocation and waiting on locks to keep the load low. Jitter in device timestamps never adds or drops samples, so there are no clicks.

Multiple streams are aligned on a shared clock before mixing. One headset’s microphone did not return correct timestamps and drifted about 3 seconds from the playback. Switching to an estimate based on arrival time brought the offset down to 0.3 ms.

GGKeeper

C++20 · WASAPI · libebur128 · Win32

Motivation

Re-adjusting the volume every time you switch games is a small chore that comes back every time. I wanted players to forget about volume and just play, so it asks nothing of them: it finds a launched game by itself and sets the volume right after launch.

Overview

A Windows app that detects running games automatically and evens out the loudness differences between titles.

Specifications

  • Measurement: ITU-R BS.1770 (K-weighting, 400 ms momentary, gating), captured at 48 kHz in 7.1 and integrated with channel weights (LFE excluded, surrounds +1.5 dB)
  • Correction: per-app session volume (a digital gain inside the Windows audio engine), 0 to −36 dB; never amplifies
  • Target: about −54 to −18 LUFS (default about −34.5 LUFS), measured on the game’s audio alone
  • Decision: a static gain decided right after launch and then held; not a continuous AGC

How it works

GGKeeper inserts no DSP into the signal path; it corrects only through each app’s session volume. It captures the game’s audio for analysis, measures loudness with the ITU-R BS.1770 method, and sets the gain from the difference to the target. With no virtual device and no hooks, latency and audio quality are untouched and nothing is injected into the game process.

GGKeeper gain over time: a guard while observing at launch, release to the decided gain, a downward-only review, then hold. 0 dB−6−12−18 observe review · down only hold guard release decided gain louder scene launchdecideend

Key decisions

It matches loudness, not peaks. Peak normalization would leave the most heavily limited masters sounding the loudest.

Rather than running an AGC all the time, GGKeeper holds a static gain decided right after launch. This keeps the dynamics and transients between scenes and avoids pumping. A modest guard applies until the decision, and the estimate is revised, downward only, when louder scenes keep coming afterward.

The measurement chain was verified on hardware. Testing with a tone of known level showed that two-channel capture read the front channels of a 7.1 endpoint 13.48 dB low because of the downmix. Capturing multichannel audio and integrating with the BS.1770 channel weights made the value independent of the playback device layout.

DawAudioStreamer

C++20 · JUCE · r8brain · libobs · WASAPI

Motivation

Getting a DAW’s sound into a stream or a call means rearranging your audio setup, a real burden in the middle of a session. I wanted people to share what they’re making straight from their usual setup, with no fuss: one plugin on the master is all it takes.

Overview

A streaming plugin (VST3 / AU) that sends your DAW’s master audio to OBS or Discord without changing your audio settings. Open source.

Specifications

  • Output to the DAW: the input returned as is (bit-identical)
  • Streaming path: 32-bit float, 48 kHz, 2 ch; a mono bus is duplicated to both channels; no SRC when the DAW runs at 48 kHz
  • SRC: r8brain-free-src (linear phase, 180 dB stopband attenuation, 3.5% transition band)
  • To OBS: 10 ms blocks as float planar; anything beyond 100 ms of backlog is discarded so latency cannot keep growing
  • To Discord: rendered into VB-CABLE in WASAPI shared mode (20 ms buffer); 40 ms target FIFO with a ±0.3% variable ratio to absorb clock drift

How it works

Built with JUCE, the plugin returns the master signal untouched and sends only a copy out for streaming. The copy is converted to 48 kHz with r8brain and handed to the OBS process through a single-producer, single-consumer lock-free ring in named shared memory. The ring’s 64-byte header holds a magic value, the protocol version, 64-bit atomic read and write positions, a dropped-frame counter and heartbeats for both sides; the heartbeats drive the connection status in the UI.

DawAudioStreamer architecture: the DAW's audio thread converts to 48 kHz and writes into shared-memory rings; a reader thread in OBS fans out to sources; for Discord, a bridge thread in the DAW process renders to VB-CABLE through adaptive resampling. DAW process OBS process clock A · audio device (ASIO …) bridge thread clock B · VB-CABLE shared memory processBlock r8brain SRC ring (OBS) ring (Discord) reader thread source source adaptive SRC WASAPI render VB-CABLE Discord audio thread fs → 48 kHz f32 SPSC · lock-free SPSC · lock-free 1 consumer, fan-out 40 ms FIFO · ±0.3% shared · 20 ms silent sink per-process capture

Key decisions

The audio thread does no allocation, no locking and no system calls that can block. The SRC builds its filters and buffers in prepareToPlay, and oversized host blocks are split rather than rejected. When the ring is full, the writer drops and counts instead of blocking. On the OBS side, any number of sources share one reader thread per process that fans the audio out, preserving the single-consumer contract. Before 0.4.5 each source read on its own and they stole blocks from one another, causing gaps and clicks.

Discord screen sharing uses per-application process loopback, so the plugin renders from inside the DAW process to VB-CABLE (a silent sink) in WASAPI shared mode, and sharing the DAW window carries the audio. The DAW’s audio device and VB-CABLE run on separate clocks, so the playback ratio is adjusted within ±0.3% in proportion to the error against a 40 ms target FIFO level (4-point cubic interpolation), absorbing the drift.

ひびきの庭

Godot 4 · GDScript

Motivation

I’d been studying game AI and wanted to take on characters that move in sync with music. Players need no musical knowledge: just make sounds, and the creatures form a small ensemble with them.

Overview

A browser game where you place sound-responsive characters called 音色 in a garden and watch the group grow into a small ensemble.

Specifications

  • Sound source: no audio files; everything is synthesized at run time (additive sine synthesis and noise)
  • Mix: 22.05 kHz, 2 ch, equal-power panning from the horizontal position on screen
  • Master: reverb and a hard limiter (ceiling −0.8 dB)
  • Tempo: 112 BPM on a 16th-note grid
  • Scale: notes picked from each role’s root using minor pentatonic intervals (0, 3, 5, 7, 10 semitones)
  • Roles: bass, kick, hat, percussion, pulse, melody and chime
  • Runtime: Godot 4 web export (single-threaded), in PC and smartphone browsers

How it works

Each 音色 is a Utility AI agent. From its internal state (fear, curiosity, trust and sync) and what it hears and sees of its neighbors, it scores possible actions and chooses one, such as wandering, approaching, fleeing or gathering. Movement combines steering behaviors.

Each role has its own sound. The kick gets its attack from a fast downward pitch sweep, the hat is a short decay of noise mixed with high partials, and the chime stacks inharmonic partials for a metallic ring.

Key decisions

As the group’s sync rises, notes are quantized to the 16th-note grid and each role plays its own pattern. The bass lands on beats 1 and 3, the hat ticks in eighths, and the kick hits beat 1 plus the offbeats of beats 2 and 3 (steps 7 and 11), so the groove is syncopated rather than four-on-the-floor. Rather than everyone playing the same note, each plays its own part on the same beat, so the closer they come together, the more it sounds like an ensemble.

ひびきの庭 trigger patterns: where each role tends to play within 16 steps when sync is high. 12345678910111213141516 BassKickHatPercPulseMelodyChime filled: trigger slot · outline: conditional / per-agent · 16 steps = 1 bar @ 112 BPM

Because pitches stay within a pentatonic set, overlapping 音色 rarely clash by a semitone. Fearful agents play slightly sharp, shorter and quieter, which makes them sound restless.

日本語
GGKeeperBalancing…
Game A-15.2 LU
Game B-36.0 LU
Game C-22.0 LU

Just an animation. The real GGKeeper evens out the volume between games. Work page

OtoShot