Introduction to Digital Music with Python provides a foundation in music and code for the beginner and shows how coding empowers new forms of creative expression while simplifying and automating many of the tedious aspects of production and composition.
With the help of online, interactive examples on Digital Audio Workstation (DAW) platforms called TunePad and EarSketch, this book covers the fundamentals of rhythm, chord structure and melodic composition alongside the basics of digital production. Each new concept is anchored in a real-world musical example that will have you making beats in a matter of minutes.
Including core programming concepts such as loops, variables, lists and functions, Introduction to Digital Music with Python is designed for beginners of all backgrounds, requiring no previous experience with music or code, including undergraduates and aspiring professionals.
When I was a kid growing up in Texas, I “learned” how to play viola. I put learned in quotes because it was really just a process of rote memorization—hours and hours of playing the same songs over and over again. I learned how to read sheet music, but only to the extent that I knew the note names and could translate them into the grossest of physical movements. I never learned to read music as literature, to understand its deeper meaning, structure, or historical context. I never understood anything about music theory beyond being annoyed that I had to pay attention to accidentals in diferent keys. I never composed anything, not even informally scratching out a tune. I never developed habits of deep listening, of taking songs apart in my head and puzzling over how they were put together in the frst place. I never played just for fun. And, despite the best intentions of my parents and teachers, I never fell in love with music.
Learning how to code was the complete opposite experience for me. I was largely self-taught. The courses I took in school were electives that I chose for myself. Teachers gave me important scafolding at just the right times, but it never felt forced. I spent hours working on games or other projects (probably when I should have been practicing viola). I drew artwork, planned out algorithms, and even synthesized my own rudimentary sound efects. I had no idea what I was doing, but that was liberating. No one was around to point out my mistakes or to show me how to do things the “right” way (at least, not until college). I learned how to fgure things out for myself, and the skills I picked up from those experiences are still relevant today. I fell in love with coding.
But I know many people whose stories are fipped 180 degrees. For them, music was so personally, socially, and culturally motivating that they couldn’t get enough. They’d practice for hours and hours, not just for fun but for something much deeper. For some it was an instrument like the guitar that got them started. For others it was an app like GarageBand that gave them a playful entry point into musical ideas. To the extent that they had coding experiences, those experiences ranged from uninspiring to of-putting. It’s not that they necessarily hated coding, but it was something they saw as not being for them.
In the foreword of his book, Mindstorms: Children, Computers, and Powerful Ideas, Seymour Papert wrote that he “fell in love with gears” as a way of helping us imagine a future in which children (like me) would fall in love with computer programming, not for its own sake, but for the creative worlds and powerful ideas that programming could open up. Part of what he was saying was that love and learning go hand in hand, and that computers could be an entry point into many creative and artistic domains such as mathematics and music. Coding can revitalize subjects that have become painfully rote in schools.
The process of developing TunePad over the past several years has been a fascinating rediscovery of musical ideas for me. Code has given me a different kind of language for thinking about things like rhythm, chords, and harmony. I can experiment with composition unencumbered by my maladroit hands. Music has become something creative and alive in a way that it never was for me before. Music theory is no longer a thicket of confusing terminology and instead has become a fascinating world of mathematical beauty that structures the creative process.
Melanie, Cameron, and I hope that this book gives you a similarly joyful learning experience with music and code. We hope that you feel empowered to explore the algorithmic and mathematical beauty of music. We hope that you discover, as we have, that music and code reinforce one another in surprising and powerful ways that open new creative opportunities for you. We hope that, regardless of your starting point—as a coder, as a musician, as neither, as both—you will discover something new about yourself and what you can become.
Chicago, Illinois (July 2021)