FactoTune: an MP3 player in Factorio built from 2,000 speakers
A Factorio player wants real songs, not MIDI beeps. FactoTune mixes 360 speaker sounds with linear algebra to approximate any audio file.

Tired of alt-tabbing between Spotify and Factorio, only to return to a base overrun by biters? The creator of FactoTune decided the factory should play the music itself, driven by logic circuits.
Music has been played in Factorio before, but only as MIDI: notes on a fixed set of instruments from the programmable speaker. MIDI stores which key is pressed, when and for how long. It has no voice and no mixing. FactoTune aims for the actual recording, so you can load any audio file and have the game play it.
How does FactoTune work?
The programmable speaker offers eleven instruments and 360 sounds in total, each playable at a volume from 0 to 100. The idea is to play many of these sounds at once, each at a carefully chosen volume, so that together they add up to the original track. Finding those volumes is a linear algebra problem: turn every sound into a list of numbers, stack them into a big matrix and solve for the best fit.
The author's first attempt, nicknamed Smoothie, solved the whole song in one go. It failed, because almost every speaker sound lasts under a second while a song runs for minutes. The fix was to slice the song into tiny pieces and solve each one separately.
Why two audio blocks?
The game runs at 60 ticks per second, but audio is mixed on a separate thread in blocks of 512 samples, about 86 times a second. That thread only checks for new messages at the start of a block, so a sound may play for one block or two, and the game does not say which. So each slice is two audio blocks long, and the author had to guess how the threads line up.
Plain least squares produced negative volumes, which do not exist in the game. Simply setting them to zero (the "Eraser") did not help. The "Picky Eater" approach did: the wiki says only 50 sounds can play at once, so for each slice it picks the sound that fills the biggest gap, refits all the volumes and drops any that would go negative, until 50 remain. For the first time the error fell and the song became recognisable, though noisy.
Volumes must also be whole numbers, and the speaker plays one step louder than the value set, so one is added before the value enters the game. Most chosen volumes turned out to be five or lower.
Apps worth a look
Tap the right tiles, add them up, hit the target. Easy to learn, hard to master. Free, for all ages.
Talk to an AI conversation partner; every sentence comes back corrected and explained in your language. 9 languages, A1 to C2.
Open EDIFACT and X12 messages, see every segment explained, convert to JSON/XML, export PDF and Excel. Runs locally, no upload.
Pick who it is for, the occasion and their personality. The search engine reads product descriptions from local shops and ranks what fits. Free, no sign-up.
More from this day
See all →
BYD Ti7 banned in the EU after Hague court rules on Defender design

Fake Elon Musk crypto scam on YouTube: Coinbase blocks $4.7 million

Linus Torvalds slams AI-written EXT4 pull request in Linux 7.4-rc5

Steam top-up via Kupikod costs up to 24% extra, test of 11 services
More in: Gaming
See all →
Steamworks wait times hit 45 days as Steam gets 1,600 releases a week

GTA VI PC port Leonida pulled after Take-Two DMCA notice

The Cube: first teaser in 18 months for the Atomic Heart MMO shooter
