A physical simulation of how a record player makes sound. More
Instead of playing an audio file, the music is cut into a spiral groove, and a simulated stylus, cantilever, tonearm and cartridge read it back. What you hear is the voltage that motion would induce in the cartridge, after phono equalisation.
This is a physical simulation of a record player's mechanics, which happen to play sound. It works in four steps, each a small file in src/.
src/
1. Cut. The lathe (cut.js) turns the audio into the two walls of a stereo groove at 33⅓ rpm, millions of points on each: RIAA pre-emphasis, a limiter so a real cutter could have cut it, and variable pitch so the side fits on a 12" disc. The records on the shelf are cut ahead of time. Files you bring are cut here, in a worker. From then on the only thing that exists is the disc.
cut.js
2. Press. The pressing plant (press.js) changes the geometry itself: wall roughness, dust, scratches, warp, an off-centre hole, groove echo. Nothing in it is an audio effect. It is seeded, so the same record always presses the same way.
press.js
3. Play. The engine (engine-core.js, groove.js) runs on the audio thread. It moves a stylus tip weighing a third of a milligram, on a springy cantilever at the end of a pivoting arm, against both walls hundreds of thousands of times a second, and turns that motion into the voltage of a moving-magnet cartridge.
engine-core.js
groove.js
4. Draw. The deck (render.js) is WebGL2, and the disc is drawn from the cut itself: the actual spiral, lit by how hard each revolution is modulated. The small view in the corner is the real groove wall passing under the stylus.
render.js
"Real", procedural flaws.
Drop the needle anywhere, or drag the record to scratch it. Drag empty space to look around and scroll to zoom in on the stylus. In Controls you can change the stylus, lower the tracking force, press a dirtier copy, or cut your own audio.
Set by hand rather than derived: how rough the walls are, and how much the bearing rumbles and the motor flutters. Not simulated: stylus rake angle and record wear.