Writing Music with Ruby: A subtle introduction to music theory
summary
Ruby code generates sine waves at 440Hz A, writes 16-bit PCM WAV files at standard sample rates, and maps frequencies by the 12th root of 2 to produce chromatic notes, octaves, scales, modes, thirds and chords. The demo builds chord progressions (I–V–vi–IV), arpeggios, and a stochastic song that mutates each run; audio output works but sounds “too perfect” until distortion and clipping are added. Library is educational, hacky, and not production-ready.
AI-written summary · about
chapters (10)
- 0:00Introduction and background
- 2:17Music theory and challenges
- 7:07Understanding sound waves
- 9:58Generating digital audio
- 14:44Abstraction: octaves
- 16:45Tones and semitones
- 18:56Modes and scales
- 22:11Chords and progressions
- 26:18Composing songs with code
- 31:16Conclusion and final thoughts








