Juliacon 2024

A live coding music performance with Julia
07-12, 15:00–15:30 (Europe/Amsterdam), Else (1.3)

Are you sick of practicing arpeggios? Is the metronome your natural enemy? Are you suffering from Julia withdrawal symptoms when you play music?

No worries, Julia can help. Simply learn live coding, the art of changing a program that generates music while it generates music! Generative music and improvisation combined.

This presentation is a short music performance with Julia followed by a breakdown and tutorial into live coding with Julia.


The core of this presentation is a live coding music performance using hot code reloading and PortMidi.jl.

Live coding essentially combines musical improvisation with generative music. Expanding on the idea of the REPL (read-evaluate-print-loop), one can consider live coding as a performance during which 'the human' changes 'the program' that generates the music; all done in a way that does not interrupt the musical flow. This allows interactive exploration of musical ideas, and live coding is a very cool subgenre of electronic music.

There exist many domain-specific languages for this task: Extempore, Impromptu, Max, Pure Data, TidalCycles, and SuperCollider. The common challenge is to combine hot code reloading during execution without introducing timing issues. These are all features Julia already has, making it a fun environment for live coding.

To implement hot code reloading, we rely on temporal recursion. Imagine a function that calls itself after a given delay using Base.invokelatest. If we redefine the function during this sleeping time, we can change it without interrupting the "read-evaluate-play music-recursion". Together with a bit of asynchronous programming, plain Julia is basically all you need for live coding.

Now, the cool part is that Julia's ecosystem is much larger than most other live coding environments. For example, what about using DifferentialEquations.jl to generate the notes? Or using Makie's reactive programming for visuals! And, of course, how about using the packages from JuliaMusic for the theory? Unlimited options to make the next hit (or extremely crappy tunes).

See also: GitHub

I apply mathematics and computer science to developmental biology. My primary research aim is to develop and use detailed mathematical models to help biologists with questions inaccessible via experiments.

This speaker also appears in: