Learn music with Python and Math

Music for Geeks and Nerds

Are you interested in learning more about music but have found most material condescending or to present things magically instead of logically?

The good news is that much of music can be understood with programming and math, two things you're already good at!

In this book you'll learn some elements of music from a programmer's perspective.

The Amazing Product

Get a Free Sample

Open book

Not ready to buy? No problem, download the sample and see if you like it.

The Layers of Music

In this book you'll learn:
  • primitives of music such as notes and duration
  • means of combining primitives into motives and chords
  • music operations such as transposition, retrograde, and inversion
  • means of abstraction phrases and form

All using Python and some basic math.

About the Author

I'm Pedro Kroger (@pedrokroger), a professor of Music Composition, Computer Music, and the author of Modern Python Development with PyCharm. I've been known to teach programming to musicians and music to computer scientists.

I live near the beach in sunny Salvador (Brazil). I also lived in Austin, San Francisco (USA), Rome (Italy), and London (UK).

Pedro Kroger

The Book Buy now for $25 with PayPal or pay with a Credit Card

DRM-free eBook (PDF, ePub, Mobi) with a money back guarantee.

Examples in Python

Every concept is explained in English with a corresponding implementation in Python, using the Pyknon music library.

Made for Smart People

Don't you hate those books that go on and on just to fill up space? This book is short and to the point; you get the information you want with no frills.

Fully Illustrated

100 code samples, 40 images, 18 exercises because showing is better than telling.

No music knowledge necessary

You don't need to have a musical background to learn from this book.

Questions? Please drop me a line and I’ll do my best to answer them.


If you don't like the book, it's no problem. Just reply to your purchase receipt email within 30 days and I will issue a full refund. In addition, I'll buy you coffee when we meet :-)

Code, Examples, & Resources

If you bought the ebook from this site you already have the accompanying source code and audio examples. However, if you got it from Amazon, you may need to download them here: source code and audio examples. Check also the resources page.

How About Paper?

A paperback edition is now available at Amazon. Get your copy now.


Because of the layout and images, the recommended format for this book is the PDF version. The ePub and Mobi versions are included for your convenience, but due to the nature of e-readers, I can't guarantee they will work with every e-reader. It should work with most e-readers, though.