Barrios AI

Artificial Intelligence for Musicians

  1. Introduction
  2. Emergent Harmonic Structures | Software 1.0
  3. Pythagoras and the Music of the Spheres
  4. Building the Modes from Ancient Theory
  5. Harmonic Ratios in Nature and Music
  6. Musical Mathematics
  7. Exploring Chance and Randomness
  8. Statistics of Sound
  9. Software 2.0 | Deep Learning: Teaching Computers to See
  10. Software 2.0 | Deep Learning: Teaching Computers to Hear
  11. Software 3.0 | Generative AI: Teaching Computers to Read & Write
  12. Software 3.0 | NotebookLM as RAG

Chapter 7: Statistics of Sound

Free Preview

7.1 Music as Data

Think of a melody as numbers: pitch, duration, timbre. Simple statistics reveal style and structure.

# Example melody in MIDI pitches
melody_pitches = [60, 62, 64, 65, 67, 69, 71, 72]
melody_pitches

7.2 Music Analysis with Pandas and Python

Spreadsheets are just tables: every row describes one song, every column stores the same kind of fact for each song (tempo, key, energy, …).
Why is that powerful?

  • Consistency → quick math Uniform columns let us sort, filter, and average in a single line of code.
  • Clarity → better questions Well-labeled tables make patterns jump out: which keys dominate? How fast is the typical Miles Davis tune?
  • Automation → scale The Pandas library treats a CSV file like a programmable spreadsheet, so the same analysis works on twenty songs or twenty-thousand.

In the table below each row is a jazz classic; the columns capture five numeric (quantitative: countable values) or categorical (qualitative: descriptive categories) features:

  • Title: song name (categorical)
  • Artist: performer or ensemble (categorical)
  • Tempo: beats per minute (numeric)
  • Key: tonal center (categorical)
  • Energy: 0 to 1 proxy for loudness, density, rhythmic drive (numeric)

You’ll compute summary stats and build three quick plots:

  1. Histogram of tempo: see how fast most tunes sit.
  2. Scatter of tempo vs energy: spot high-energy outliers.
  3. Box-plot of tempo by key: compare common jazz keys side-by-side.

Continue reading this chapter

You're reading a free preview. Purchase the book to unlock every chapter in Artificial Intelligence for Musicians.

✓ Full book unlocked✓ Every chapter✓ Runnable code✓ Lifetime access