How to compose music with just a single line of code

How to compose music with just a single line of code
Credit: Unsplash: Max Duzij

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.

Photos-from-Lobotomia-02

In computer history’s infancy, the term “magic” was often used to describe a program that works but with an obscure reason as to why. Engineers were constantly dabbling in uncharted territories and each new discovery had the potential to create magic, a process so clever and fascinating that its mechanism is difficult to grasp.

Computer scientists at the MIT AI Lab started to write down and share their personal notes on findings they would stumble upon and collect, in Guy L. Steele’s words, “a bizarre and eclectic potpourri of technical trivia”.

These notes are now known as the HACKMEM (short for hack memos) and, even though they are not being referred to as much today, they are an incredible record of insights into the minds of influential engineers from that period.

The MIT AI Lab also participated in the creation of the Jargon File, a glossary of slang words and expressions used by computer programmers.

When looking at the definition of “magic” and in the Jargon files, here’s what we find: magic

1. adj. As yet unexplained, or too complicated to explain; compare automagically and (Arthur C.) Clarke’s Third Law: “Any sufficiently advanced technology is indistinguishable from magic.” “TTY echoing is controlled by a large number of magic bits.” “This routine magically computes the parity of an 8-bit byte in three instructions.”

2. adj. Characteristic of something that works although no one really understands why (this is especially called black magic).

3. n. [Stanford] A feature not generally publicized that allows something otherwise impossible, or a feature formerly in that category but now unveiled.

4. n. The ultimate goal of all engineering & development, elegance in the extreme; from the first corollary to Clarke’s Third Law: “Any technology distinguishable from magic is insufficiently advanced”.

In relation to bytebeat, another term found in the Jargon File stands out: hack value: n.

Often adduced as the reason or motivation for expending effort toward a seemingly useless goal, the point being that the accomplished goal is a hack. For example, MacLISP had features for reading and printing Roman numerals, which were installed purely for hack value. […] this cannot really be explained, only experienced. As Louis Armstrong once said when asked to explain jazz: “Man, if you gotta ask you’ll never know.”

Possibly one of the reasons bytebeat took the Demoscene and hacker community by storm is because of its high hack value.

In the Demoscene, artists and programmers get together to create sometimes extremely small programs producing an artistic outcome. Demos are then presented at various competitions and winners are chosen according to the hack value of their demo: a balance between extremely efficient code, impressive artistic results, and the program’s simplicity and elegance.

Eyes towards The future

Though bytebeat is an underground movement, it’s still alive in 2020. Some programmers and researchers have been investing energy into developing various programs around bytebeat theory.

One such modern applications of bytebeat worth mentioning is Rampcode: a live coding system built on top of PureData, created by Argentinian philosophy professor, musician, and creative coder Gabriel Vinazza (a.k.a. GEDE).

Final thoughts

Maybe the fact that so few people have yet to experiment with bytebeat means there are still many interesting discoveries to be done on the subject. After all, its concept serves as a reminder that, no matter how far technology goes, there’s beauty and, yes, magic, to be found in the simplest things.

How to compose music with just a single line of code

111 Successful Attempts of Infiltration to Jammu and Kashmir over Last Year, Centre Tells Lok Sabha
1-MIN READ

111 Successful Attempts of Infiltration to Jammu and Kashmir over Last Year, Centre Tells Lok Sabha

Representative image. (Reuters)

Representative image. (Reuters)

There were 176 attempts of infiltration from across the border to Jammu and Kashmir from August 2019 to July 2020 and 111 of these were successful.

  • Last Updated: September 16, 2020, 4:38 PM IST

As many as 111 infiltration attempts from across the border to Jammu and Kashmir have been successful in the last one year, the Lok Sabha was informed on Tuesday. Union Minister of State for Home G Kishan Reddy also said 138 terrorists were killed by security forces between March and August this year.

There were 176 attempts of infiltration from across the border to Jammu and Kashmir from August 2019 to July 2020 and 111 of these were successful, he said in a written reply. Reddy said Jammu and Kashmir has been affected by terrorism, which is sponsored and supported from across the border, for more than the last three decades.

He said the government has adopted a policy of zero tolerance towards terrorism, and security forces are taking effective and continuous action in countering terrorism. "As a result, 138 terrorists have been neutralised in Jammu and Kashmir from March 1, 2020 to August 31, 2020. During this period of six months, 50 security force personnel attained martyrdom in terrorist-related incidents, ceasefire violations and cross border firings in Jammu and Kashmir," the minister added.

Next Story
Loading

How to compose music with just a single line of code

akali dal leader sirsa files complaint NCB manjinder singh karan johar party

ਕਰਨ ਜੌਹਰ ਦੀ ਪਾਰਟੀ ਵਿੱਚ Drugs ਇਸਤੇਮਾਲ ਕਰਨ ਦਾ ਇਲਜ਼ਾਮ, ਮਨਜਿੰਦਰ ਸਿੰਘ ਸਿਰਸਾ ਨੇ ਕੀਤੀ NCB ਨੂੰ ਸ਼ਿਕਾਇਤ ਦਰਜ

ਹਰ ਵੇਲੇ Update ਰਹਿਣ ਲਈ ਸਾਨੂੰ Facebook 'ਤੇ like ਤੇ See first ਕਰੋ .



Other From the World

loading...

How to compose music with just a single line of code

'Ek Aur Plate': Raipur Man's Automatic 'Pani Puri' Machine Goes Viral and Foodies are Lining up
2-MIN READ

'Ek Aur Plate': Raipur Man's Automatic 'Pani Puri' Machine Goes Viral and Foodies are Lining up

Screenshot from video tweeted by @AwanishSharan.

Screenshot from video tweeted by @AwanishSharan.

IAS officer Awanish Sharan posted a video on microblogging site Twitter sharing the newest 'jugaad' in town-- an automatic pani puri (gol gappe) machine that dispenses three varieties of water as per your liking.

  • Last Updated: September 16, 2020, 5:24 PM IST

Indians love street food. But the times have changed for the worse. The ensuing pandemic and the ever-growing number of persons affected by the deadly infection of COVID-19 has pushed Indians (and the world) indoors. The need of the hour for those who venture out for work or otherwise is to stay covered and maintain distance from one another.

This unique and unfortunate situation has called for drastic measures to be taken especially by the eateries. Contactless food deliveries, for one. But what if we told you about an automatic pani puri that reduces contact and completely skips the step where the vendor dips their hand in the pani container?

Well, it's 2020 and anything's possible.

Recently IAS officer Awanish Sharan posted a video on microblogging site Twitter sharing the newest jugaad in town-- an automatic pani puri (gol gappe) machine that dispenses three varieties of water as per your liking.

Named "Touch Me Not Pani Puri", the stall is located in Raipur, Chattisgarh officer Sharan wrote in his tweet.

Needless to say, street food lovers on the Internet were impressed.

Some, however, raised questions about the safety and hygiene as the vendor wasn't wearing a mask in the now-viral video.

Back in July, a video did the rounds on social media showed that a man in Banaskantha district of Gujarat had developed an automatic pani puri machine which worked just like an ATM. The viral video also demonstrated how the machine worked.

Also Read: Gujarat Man Develops 'Pani Puri ATM' Amid Coronavirus Fears and Foodies are Here for it

One had to insert money into the machine, just like you did for a vending machine. Once you did, a plate of pani puri would come up on the conveyor belt.

Next Story
Loading

How to compose music with just a single line of code

International Day for the Preservation of the Ozone Layer: All You Need to Know
1-MIN READ

International Day for the Preservation of the Ozone Layer: All You Need to Know

File photo: Scientists from the German Aereospace Center (DLR) used data from the Copernicus Sentinel-5P satellite, to record an unusual ozone hole form over the Arctic. (Credit: Copernicus data (2020), processed by DLR/BIRA/ESA)

File photo: Scientists from the German Aereospace Center (DLR) used data from the Copernicus Sentinel-5P satellite, to record an unusual ozone hole form over the Arctic. (Credit: Copernicus data (2020), processed by DLR/BIRA/ESA)

September 16 is celebrated as International Day for the Preservation of the Ozone Layer or World Ozone Day. Ozone is the essential gaseous layer around our planet which maintains the balance in nature.

  • Last Updated: September 16, 2020, 11:35 AM IST

We all are aware about the fact that the world is on fire, from the west coast in the United States of America to the catastrophic bushfires in Australia earlier this year. It has become essential for us to preserve our planet earth. September 16 is celebrated as International Day for the Preservation of the Ozone Layer or World Ozone Day. Ozone is the essential gaseous layer around our planet which maintains the balance in nature.

What is Ozone?

Just like we wear sunscreen on our bodies to protect ourselves from the harmful effects of sunlight, the ozone layer acts like the sunscreen for planet earth. It is a fragile gaseous shield which protects the Earth from the harmful portion of the rays of the sun, thus helping to preserve life on the planet. The stratospheric layer shields Earth from most of the sun’s harmful ultraviolet radiation.

What happened to it?

This delicate shield was endangered after observations and measurements from satellites and other instruments resulting in an ozone hole over Antarctica that was growing larger every year. Now, a similar hole has opened over the Arctic. The stratospheric ozone coverage worldwide had dropped 5% between 1970 and the mid-1990s. The damage to the layer was due to ozone-depleting gases (ODSs) used in aerosols and cooling, such as refrigerators and air-conditioners. The ozone hole was threatening to increase cases of skin cancer and cataracts, and damage plants, crops, and ecosystems.

What did we do?

To tackle this problem, governments around the world came together and adopted the Vienna Convention for the Protection of the Ozone Layer in 1985. The Convention’s Montreal Protocol asked governments, scientists and industry workers to cut out 99 per cent of all ozone-depleting substances. Due to these substantial steps, the ozone layer is now healing and is expected to return to pre-1980 values by mid-century according to the United Nations.

Did we solve it?

Countries around the world have worked together to reduce and eliminate the use of chlorofluorocarbons (CFCs) and other ozone-destroying chemicals for 30 years now. The collective effort bore its fruits after a 2016 study, which tracked the evolution of the size of the ozone hole over Antarctica and observed that stratospheric ozone concentrations were continuing to increase and that the size of the Antarctic ozone hole had declined between 2000 and 2015. The ozone is expected to fully heal between 2040 and 2070.

Next Story
Loading