{
  "id": 5924932,
  "title": "Music Theory for Programmers",
  "url": "https://urgent.news/2026/09/02/music-theory-for-programmers",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-02T20:19:13.000Z",
  "source": {
    "name": "Hacker News",
    "slug": "hacker-news",
    "url": "https://runjs.app/blog/music-theory-for-programmers"
  },
  "original_language": "en",
  "account": "Music theory can often seem like a mysterious and arbitrary system, devoid of any underlying logic. However, this article aims to break down the fundamental principles of music theory from first principles, using code as a tool to derive and understand these concepts. The foundation of music lies in the twelve notes, and the major scale's shape and the chords that sound pleasing are not mere conventions, but rather the result of physics and arithmetic. By writing code, we can explore these relationships and see how they manifest in the world of music. The journey begins with a single number changing over time, leading to the derivation of the twelve notes, building scales and chords out of arrays, and creating a chord progression that sounds like actual music. This process is done without the need for an instrument, relying solely on the Web Audio API and the simple representation of sound as a list of numbers describing the position of a speaker cone. The number 440 is the starting point, representing the frequency agreed upon to be called A, serving as the tuning fork for the rest of the system. While the mapping from frequency to pitch is straightforward, the magic happens when we consider the harmonic series. Each note played by an instrument not only produces its fundamental frequency but also a stack of additional frequencies, known as harmonics, which contribute to the unique sound or timbre of that instrument. By understanding the harmonic series and its role in shaping the timbre of various musical instruments, we gain insight into why certain notes and chords sound familiar and pleasing to our ears, regardless of the culture or instrument involved.",
  "summary": null,
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}