Introduction
Nature, music, and number are all somehow intertwined ... one can be transformed into another.
– Making Music with Computers, Bill Manaris and Andrew R. Brown
This book is a work in progress guide to creating generative music with JavaScript.
There already exist many ways to make generative music, but this book is about learning how to create something from scratch using JavaScript and the Web Audio API. We can fairly easily write a program to generate noise, and with a little work even something that sounds vaguely like music, but can we design systems that produce something that approaches the qualities of "real" music? Let's find out!
Principles
To help us focus, the book has a few guiding principles:
Fun over rigour: We'll take inspiration from science and nature, but also take some artistic license along the way.
Composition over sound design: The focus will be on creating musical structures, with sound generation delegated to instrument samples.
Systems over performance: We're aiming for music that is self evolving and requires no interaction from us or the listener (i.e. procedural music in contrast with live coding).
Simple building blocks: We'll build things from the ground up. As we go we'll encapsulate our learning into a set of modules we can plug together to make more sophisticated music.
Structure
Primers
To help us get started, the book begins with short primers on each of its three subjects:
Generative: Here we define what we mean by "generative", and cover how generative processes can be applied to creating music.
Music: Here we explain the building blocks of music: melody, harmony and rhythm.
JavaScript: Here we cover the music-focused features available in JavaScript, namely the Web Audio API.
Music
Next, we move on to programming the basic building blocks of music:
TODO
List chapters
Generative
Finally, we go on to develop systems that create music based on different generative ideas:
TODO
List chapters
Who This Book Is For
This book is primarily aimed at web developers interested in using their existing skills to make music. There's nothing truly web-specific about what we'll learn, we're essentially just using the browser as our development platform. With that said, it will be useful to have a working knowledge of JavaScript and related tooling (e.g. Node.js, npm) to get the most of out of this book.
Code Examples
All of the code examples in this book are runnable. You can hear the results by clicking the "Run" button in the corner of each code block.
Prior Art
This book takes inspiration from the following:
- The Nature of Code – simulations of natural systems.
- Overtone – collaborative programmable music.
- Sonic Pi – a code-based music creation and performance tool.
- Tone.js – a framework for creating interactive music in the browser.
- jMusic – music composition in Java.