The Magnet 041: One-line algorithmic music
Before we get started, I wanted to thank everyone who has resubscribed to the newsletter. I started The Magnet a year ago and your support means a lot to me.
Also, thank you to everyone who has shared these issues on Twitter, Facebook, Linked In, and other social networks. The Magnet is 100% subscriber-supported and your sharing is essential to its success. If you know of anyone who might enjoy this newsletter, please forward them this issue.
Finally, thank you to everyone who has given me feedback on the newsletter. I always appreciate the suggestions.
This week’s issue of The Magnet is focused on smallish items I found interesting. I hope you enjoy them!
One-line algorithmic music
I've been experimenting with ways to get interesting sounds from an Arduino (a low-cost electronic prototyping platform). One of the coolest things I've come across so far is Ville-Matias Heikkilä's algorithmically generated music. These are ever-changing songs made with just one line of code. It is a genre of algorithmic music known as Beatbyte, and people have developed Beatbyte programs for Arduinos and other platforms, including the web.
Check out this browser-based version to try making some one-line algorithmic songs of your own. Truthfully, I have no idea how these one-line formulas actually work. According to this article, the formulas define “a waveform as a function of time, measured here in 1/8000 of a second.” And operators like << shift the bits in the bytes that define the variable t. As you can tell, I’m way out of my league here. If you know how this works, I would appreciate hearing from you. (As I was proofreading this issue, I came across a 2011 paper written by Heikkilä that looks like it has a thorough explanation, but I haven’t read it yet).
The good news is you don't have to know how the formulas work to make sounds. Visit this website and use trial-and-error to write some formulas and see what happens. Suggestions to get started:
return t
return 2*t
return .1*t
return t&96&t>>8
return t&(t>>8)
return t&(t>>8)|(t>>4)
return t++*(t>>9)|(t>>2)
Keep tweaking and experimenting. You’ll soon come up with something that sounds like a song!
Here’s a formula that’s full of surprises. It almost sounds like someone is talking.
My goal in learning this is to make a small wooden box that has an Arduino, a speaker, a battery, and a button in it. Each time you press a button it generates a random formula and plays a never-before-heard song that will never be heard again.
Thanks for reading! Mark Frauenfelder writes the Magnet.