Sitemap

Live Coding

5 min readJun 20, 2022

Live Coding is an awesome mash of programming and creating music. If you are a programmer who comes from a more musical background instead of a more STEM one, then this will probably, heavily intrigue you. It involves a seemingly arbitrary concatenation of code, to produce either visual effects, sounds, or both. Obviously the arbitrary part isn’t so arbitrary if you understand both coding and how music theory works. The main components involved with live coding require a text editing environment combined with a software that utilized the environment to produce sounds or visuals, as well as some creativity of course. These live coding environments include TidalCycles, Pure Data, SuperCollider, Lua, Fluxus, and many others. These environments allow for a user to build a library which allows unfinished and temporary details that can be changed and manipulated at the run time. This allows for a pretty impressive live performance of human expression mixed with computational algorithms. Live coding also involves collaboration with other artists in real time, meaning they’re both performing in the same coding environment at the same time. The source code that is being written during these performances is usually projected onto a screen so the audience can see it, along with programmed visuals.

Algoraves:

Official Algorave logo

Algoraves are exactly what they sounds like, which is a live event of dance music that is created from algorithms via programming, in real time. Since 2011, these events have taken place around the world in the underground electronic music scenes. The genres vary from minimal house/trance to ambient chiptune/noise and vaporwave, all the way to heavier (electronic) genres such as witchhouse or hardstyle. Of course categorizing these genres is often as arbitrary as the code itself due the nature of these different genres usually being combined in some capacity. Although live coding for these performances is a relatively newer occurrence, Brian Eno was experimenting with a more “algorithmic approach” to apply to early electronic dance music in the 1970’s. This influenced the rave culture in the early 90’s, Apex Twin’ 1996 ‘Girl/Boy EP’ featured some of those first implementations of algorithmic music, which later lead to the glitch music genre. The first official ‘algorave’ was in London was an opening act for the SuperCollider Symposium in 2012. This eventually lead the international movement we know today. These events brought to light the potential for meshing the power of programming with the power of art and sound.

Of course there is also the visual aspect as well, which is something that isn’t exclusive to live coding performances, but is a key component in them nonetheless. These visuals are also usually rendered with live coding environments as well and are sometimes even connected to the music itself.

Press enter or click to view image in full size
Radical!

The Code:

The actual code used when live coding is an interesting combination of functions and music theory, if you think of it, music is basically math at it’s core, and so is programming. Obviously they both branch out into various different types of complexities, but I believe that this is why they work so well together. Programming is all about getting the computer to do whatever you want it to do, and this is no different when it comes to playing an instrument.

Get Royce Taylor’s stories in your inbox

Join Medium for free to get updates from this writer.

Here is an example of code used in the Sonic Pi software environment:

use_debug falselive_loop :low do |idx|
# idx = 0
synth :zawa, wave: 1, invert_wave: 1, phase: 0.25, release: 5, note: :e1, cutoff: (range 60, 120, 10)[idx]
sleep 4
idx += 1
end
live_loop :lands, auto_cue: false do |idx|
use_synth :dsaw
use_random_seed 66679
with_fx :reverb, room: 1 do
16.times do
ns = (scale :e2, :minor_pentatonic, num_octaves: 3)
play ns.choose, detune: 12, release: 0.1, amp: 2, amp: rand + 0.5, cutoff: rrand(70, 120)
sleep 0.125
end
end
end
live_loop :bikes do |idx|
sleep 0.25
sample :guit_em9, rate: -1
sleep 7.75
end
live_loop :time, auto_cue: false do |idx|
sample :bd_haus, amp: 2.5
sleep 0.5
end

This code is used on a Raspberry Pi, which is a small computer, usually used to build small programs and video games. Here we see it used to create music. You can see how the different chunks of code read almost like measures on sheetmusic. There are a few more instructions than in sheet music, like which synth voices or sounds need to be used and how they need to be used. Then you add effects like reverb or delay, and THEN you can get into the patterns and tempos for the sounds. There individual tweeks that one can make to each note that is read by the program, just like there would be naturally when playing an instrument via accents (emphasis or lack of on a specific note in a specific style). Then you can break out of the functions to signal the end of that musical phrase.

Here are a couple examples of people live coding via the SonicPi environment so you may see it in action!

There are entire online communities and many github repositories full of content that contains everything one would need to get started if you’re feeling the need for a creative outlet that involves your love for computer science. I’ll link a very involved repository for you here! Try it out and tap into your creative side, it doesn’t require extensive knowledge of music theory, but I suggest learning the circle of fifths which I’ll also link here! I’d also suggest looking into basic synthesis and effects and you’ll be on your way to throwing your own wild dance parties.

POV you’re at a dance party

Sources: