How to compose music with just a single line of code

0 6

So you like TNW? Then join our upcoming online event, TNW2020, you don’t want to miss it.

This article was originally published on .cult by Mynah Marie. .cult is a Berlin-based community platform for developers. We write about all things career-related, make original documentaries and share heaps of other untold developer stories from around the world.

In 2011, a programmer going by the name of Viznut published the following video on YouTube:

Accompanying the video were various articles written by him and published on his blog. In them, he describes how he accidentally discovered that by running a simple C program outputting single characters and piping them into the audio interface of a computer, it’s possible to encode these bytes and turn them into not just sounds, but music.

The video and article created an uproar in the Demoscene community. People started experimenting with basic C programs and coming up with interesting melodies. Soon, Viznut published a more academic paper explaining the theory behind how to compose elaborate music compositions using this technique.

A new subgenre of electronic music was born: bytebeat.

Discovering the powerful capabilities of one-liner C programs

In its essence, a bytebeat program is a small C program consisting of an infinite loop, outputting to the terminal an endless string of ASCII characters. These chars can then be piped to another program and interpreted as raw audio output.

By influencing a variable t through bitwise operations at each loop iteration, we assure ourselves that the output of the formula will always be a different character, so different combinations of sounds will be heard.

The beauty of a bytebeat program comes from its simplicity. With one line of code, the programmer has the ability to create complex audio pieces only by manipulating a single variable.

When reading Viznut’s first articles on the subject, it’s interesting to note his own feeling of bewilderment when discovering that something so simple never seemed to have caught anyone’s attention before.

“A Bytebeat formula is a simple arrangement of digital-arithmetic operations that have been elementary to computers since the very beginning. It is apparently something that should have been discovered decades ago, but it wasn’t. […]

It is mind-boggling to think that the space of very short programs remains so uncharted that random excursions there can churn out new interesting structures even after seventy years.” — ViznutBringing magic back to technology

Bringing back a sense of “magic” in today’s fast-paced technological world

“One definition of magic […] is that it breaks people’s preconceptions of what is possible. In order to challenge and ridicule today’s technological bloat, we should particularly aim at discoveries that are far too simple and random to work but still do,” Viznut, Bringing magic back to technology.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More