light/dark mode
https://
algorithmic music
 online

Introduction

course description

In this course, students will learn how to use JavaScript and web-based technologies to create algorithmic musical compositions and experimental web-based instruments. Through the use of the WebAudio API and JavaScript libraries like Tone.js, students will learn how to programmatically generate and manipulate sound, creating interactive and generative audio works that can be shared online.

This will usually start with some example code I share on this site. Like the example below, this code will be interactive. Press the "play note" button to hear a sound, then change the number on line 6 below and press the "run code" button above the code to re-compile it. Then click the button again to hear the change in frequency.

run code

← Press this button to re-run the code, this will take any changes you made and re-render the result to the right of the editor.

copy code

← Press this button to copy the full code (including any hidden code) to your clipboard. If you have an idea or a question you want to "discuss" (ie process) with an AI (like Claude, ChatGPT or PhoenixAI) it helps to include the code in your "question" (ie input) refer to the AI Policy for more on this.

open code in netnet

← Press this button to open the full code netnet. This website is great for quick tests, but if you want to keep experimenting with an example you should work on it elsewhere. On netnet you can learn more about the code and spot errors, you can also "save" your progress by pressing and choosing to either download it, create a project (when u're logged into a GitHub account on netnet) or generate a quick URL you can use to share a sketch with me via email.

download code

← Press this button to download the full code to your computer. While those of us newer to coding might prefer to work in netnet, others might already have a preferred code editor, programming environment and workflow. Those student can use this button to download the code in these examples to use as starting points for their own projects. Refer to the assignments page for more info on submitting assignments.

This class is an intermediate level programming course. A beginner to intermediate level understanding of core programming concepts (ideally in JavaScript) is required. While a background in music can certainly be beneficial, it is not required for success in this course. Ultimately, this means you need to understand what code is, a special language that can be used to get the computer to do all the myriad things a computer can do. Like writing a recipe or casting a spell, the code we write are instructions for the “magic” we want the computer to generate. In our case, we’ll be writing in JavaScript, the defacto programming language of the Internet. If you’re familiar with other programming languages (like C++, Python, Java, etc) then you’re likely already familiar with all the core concepts and will just need to get used to JavaScript’s syntax and eccentricities. We’ll be reviewing these in week 1, but for a much deeper dive I highly recommend the book Eloquent Javascript by Marijn Haverbeke (the entirety of which is available online for free).

Of course, today we have generative AI, LLM-powered chatbots that can help us write and debug code (which we'll use), and on the software side we have DAWs (apps like Ableton or FL Studio) that let us shape sound without even having to code at all. Those tools are useful, but can undermine the point of this class, our goal isn't to create digital music the easist/quickest way possible, it's to to unlock the creative possibilities that come from understanding the computer as a creative medium itself. Music software limit us to the buttons and menus their designers imagined. By learning the fundamentals of sound/music programming, we open ourselves to a much larger range of creative possibilities: we gain the ability to design our own instruments, invent new ways of playing, and shape sound in ways no off-the-shelf program can. And while we'll be leveraging AI throughout this course (see AI Policy) this won't be about "vibe coding" our way to a result, but about developing the literacy to understand and mold code so our ideas can grow from it. The goal is not just to make music with a computer, but to explore what music can be when the computer itself becomes our medium.




Attribution: Text and code written by Nick Briz. The code editor icons designed by Meko and licensed under Creative Commons Attribution License (CC BY 3.0). Sheet Music generated using ABC.js by Paul Rosen and Gregory Dyke. All sounds generated using the Web Audio API and/or Tone.js by Yotam Mann and other contributors.