The article Music theory for programmers explains fundamental music theory principles through physics, arithmetic, and Web Audio API code examples rather than standard musical notation.
Key Topics Covered
- Sound as Numbers: Sound is air pressure changing over time. Audio digital synthesis uses oscillators (like sine waves at $440\text{ Hz}$) and volume envelopes (such as ADSR) to convert frequencies into clear, clickable notes.
- Timbre & Harmonics: The unique sound of an instrument (timbre) comes from its harmonic series—extra frequencies vibrating at integer multiples ($1\times, 2\times, 3\times$) above the fundamental frequency.
- Octaves & Ratios: Doubling a frequency results in an octave ($2:1$ ratio). Simpler frequency ratios ($3:2$ for a fifth, $4:3$ for a fourth) sound harmonious because their harmonic patterns overlap, whereas complex ratios cause unpleasant volume wobbles (beating/dissonance).
- 12-Tone Equal Temperament: Pure mathematical intervals don't loop cleanly (the Pythagorean comma). Modern music compromises by dividing the octave into twelve equal multiplicative steps ($2^{1/12}$ per semitone), allowing notes to be treated as simple integers (MIDI numbers).
- Scales: Scales are formed by selecting specific subsets of the 12 notes using patterns of step intervals (e.g., $2, 2, 1, 2, 2, 2, 1$ for a major scale) to create structured musical melodies and chords.
No comments:
Post a Comment