Introduction

Why Music Programming?

Sound is mathematics made audible. Every note is a frequency, every rhythm is a time interval, every chord is a set of ratios. This course teaches you to generate, manipulate, and schedule sound directly in your browser using the Web Audio API — no plugins, no libraries, just JavaScript and math.

  • Notes & Frequencies — MIDI numbers, the equal-temperament formula, frequency conversion, note names, and scale construction
  • Chords & Harmony — Interval ratios, chord voicings (major, minor, dom7, maj7), and transposition
  • Synthesis & Rhythm — BPM and note durations, arpeggiation, and precise note scheduling with onset times
  • Effects & Timbre — Decibels, gain conversion, LFOs for tremolo and vibrato, and 16-step drum patterns

The Web Audio API

The browser's built-in audio engine lets you create oscillators, connect them through gain and filter nodes, and schedule events with sample-accurate timing. Every lesson's code runs live in an iframe — you'll hear what you write.

const ac = new AudioContext();
const osc = ac.createOscillator();
const gain = ac.createGain();
osc.frequency.value = 440; // A4
osc.connect(gain);
gain.connect(ac.destination);
osc.start();
osc.stop(ac.currentTime + 1);

Prerequisites

Basic JavaScript (functions, arrays, Math object). No music theory background required — every concept is introduced from first principles.

Next →