HeadlinesBriefing favicon HeadlinesBriefing.com

Building the Aetheryte Radio Audio Engine

Hacker News •
×

The author details the JavaScript implementation behind the Aetheryte Radio, replicating Final Fantasy XIV's ambient audio behavior. The game plays "whir" sound effects at random intervals, pitches, and volumes to create an illusion of life and mask asset repetition. FFXIV provides min/max values for these parameters, enabling direct translation to code: random index selection, playback rates between 0.794 and 1.0, and gain values between 0.6 and 1.0.

The audio graph setup follows standard Web Audio API patterns: allocate a node, set metadata, connect. A constant hum loop is created using a buffer source with a fixed playback rate of 0.63, connected to a gain node and set to loop indefinitely.

The whir system avoids conventional loops. Instead of `while(true)` with sleeps, `setTimeout` schedules the next whir at a random delay (0–2001ms). The `chooseWhir` function creates a source node, assigns random properties, connects it, and starts playback. Crucially, when the sound ends, the node is disconnected and a new one is scheduled via `onended`, adding marginal latency acceptable for ambient effects.