Full Download Introduction to Digital Music with Python Programming: Learning Music with Code 1st Edition Horn PDF DOCX
Full Download Introduction to Digital Music with Python Programming: Learning Music with Code 1st Edition Horn PDF DOCX
com
https://ebookmeta.com/product/introduction-to-digital-music-
with-python-programming-learning-music-with-code-1st-
edition-horn/
OR CLICK HERE
DOWLOAD NOW
https://ebookmeta.com/product/introduction-to-digital-music-with-
python-programming-learning-music-with-code-1st-edition-michael-horn/
ebookmeta.com
https://ebookmeta.com/product/an-introduction-to-statistical-learning-
with-applications-in-python-gareth-james/
ebookmeta.com
https://ebookmeta.com/product/an-introduction-to-programming-and-
computer-science-with-python-first-edition-clayton-cafiero/
ebookmeta.com
https://ebookmeta.com/product/aether-bound-the-rise-of-lilith-1-1st-
edition-megan-haskell/
ebookmeta.com
Demon Lord Retry Volume 2 1st Edition Kurone Kanzaki
https://ebookmeta.com/product/demon-lord-retry-volume-2-1st-edition-
kurone-kanzaki/
ebookmeta.com
https://ebookmeta.com/product/rockfall-tertiary-effects-1-1st-edition-
william-allen/
ebookmeta.com
https://ebookmeta.com/product/promised-virgin-bellucci-mafia-1-1st-
edition-jessica-macedo/
ebookmeta.com
Power Hungry Women of the Black Panther Party and Freedom
Summer and Their Fight to Feed a Movement 1st Edition
Suzanne Cope
https://ebookmeta.com/product/power-hungry-women-of-the-black-panther-
party-and-freedom-summer-and-their-fight-to-feed-a-movement-1st-
edition-suzanne-cope/
ebookmeta.com
Introduction to Digital Music
with Python Programming
DOI: 10.4324/9781003033240
Typeset in Bembo
by codeMantra
Melanie dedicates her contribution of the book to the
memory of her friend, Bernie Worrell, who taught her
how to listen.
Mike dedicates his contribution to his wife, Diana Reed,
and his children, Madeleine and Lucas.
Contents
List of fgures ix
Photo and illustration credits xiii
Foreword xiv
Acknowledgments xvi
Michael Horn
Chicago, Illinois ( July 2021)
Note
1 I was also fortunate to have grown up in a time and place where these ac-
tivities were seen as socially acceptable for a person of my background and
identity.
Acknowledgments
We are grateful to the many people who have helped make this book possi-
ble. We especially want to thank Dr. Amartya Banerjee who has anchored
the TunePad development team. The TunePad project grew out of a col-
laboration with the EarSketch team at Georgia Tech that was initiated by
Dr. Brian Magerko and Dr. Jason Freeman. We thank Dr. Nichole Pinkard,
Dr. Amy Pratt, and the Northwestern Ofce of Community Education
Partnerships. We thank the TIDAL Lab team at Northwestern University
including Mmachi Obiorah, Wade Berger, Izaiah Wallace, Brian Andrus,
Jamie Gorrson, Matthew Brucker, Lexie Zhao, Ayse Hunt, Kallayah
Henderson, Cortez Watson Jr., Sachin Srivastava, and many, many oth-
ers. We thank our community partners including the Evanston Public
Library, the NAACP of DuPage County, the James R. Jordan Foun-
dation, the Meta Media program at the McGaw YMCA, the Hip-Hop
FIRM, EvanSTEM, the Center for Creative Entrepreneurship, Studio
2112, the James R. Jordan Boys and Girls Club, Lake View High School
and Marshaun Brooks, Lane Tech High School and Amy Wozniak, Gary
Comer Youth Centers, and Chicago Youth Centers, Project Exploration,
BBF Family Services, and the Museum of Science and Industry. Shout-
outs to Marcus Prince and Sam Carroll who gave us insightful curriculum
ideas, to Tom Knapp who contributed to TunePad’s graphical design, and
to the amazing interns we’ve worried with over the years.
Special thanks go to the people who gave input into the ideas and text
of this manuscript including George Papajohn and Diana Reed. We also
thank Joseph Mahanes, Abbie Reeves, and others who put up with us
while we worked on this book.
TunePad was created by the Tangible Interaction Design and Learn-
ing (TIDAL) Lab at Northwestern University in collaboration with the
EarSketch team at the Georgia Institute of Technology and with fund-
ing from the National Science Foundation (grants DRL-1612619, DRL-
1451762, and DRL-1837661) and the Verizon Foundation. Any opinions,
fndings, and/or recommendations expressed in the material are those of
the authors and do not necessarily refect the views of the funders.
1 Why music and coding?
These eight lines of Python code tell TunePad to play a pattern of kick
drums, snare drums, and high-hats. Most of the lines are playNote in-
structions, and, as you might have guessed, those instructions tell TunePad
to play musical sounds indicated by the numbers inside of the parentheses.
This example also includes something called a loop on line 6. Don’t worry
too much about the details yet, but the loop is an easy way to repeat a set
of actions over and over again. In this case, the loop tells Python to repeat
lines 7 and 8 four times in a row. The screenshot (Figure 1.1) shows what
this looks like in TunePad. You can try out the example for yourself with
this link: https://tunepad.com/examples/roses.
connection, and a small budget. The reasons behind the shift to digital
production tools are obvious. Computers have gotten to a point where
they are cheap enough, fast enough, and capacious enough to do real-time
audio editing. We can convert sound waves into editable digital informa-
tion with microsecond precision and then hear the efects of our changes
in real time. These DAWs didn’t just appear out of nowhere. They were
constructed by huge teams of software engineers writing code—millions
of lines of it. As an example, TunePad was created with over 1.5 million
lines of code written in over a dozen computer languages such as Python,
HTML, JavaScript, CSS, and Dart. Regardless of how you feel about the
digital nature of modern music, it’s not going away. Learning to code will
6 Why music and coding?
help you understand a little more about how all of this works under the
hood. More to the point, it’s increasingly common for producers to write
their own code to manipulate sound. For example, in Logic, you can write
JavaScript code to process incoming MIDI (Musical Instrument Digital
Interface) data to do things like create custom arpeggiators. Learning to
code can give you more control and help expand your creative potential
(Figure 1.2).
1 for _ in range(16):
2 if randint(6) > 1: # roll the die for a random number
3 playNote(4, beats=0.5) # play an eighth note
4 else:
5 playNote(4, beats=0.25) # or play 16th notes
6 playNote(4, beats=0.25)
What’s cool about these efects is that they’re parameterized. Because the
code describes the algorithms to generate music, and not the music itself, it
means we can create infnite variation by adjusting the numbers involved.
For example, in the trap hi-hat code, we can easily play around with how
frequently stuttered hats are inserted into the pattern by increasing or de-
creasing one number. You can think of code as something like a power drill;
you can swap out diferent bits to make holes of diferent sizes. The drill bits
are like parameters that change what the tool does in each specifc instance.
In the same way, algorithms are vastly more general-purpose tools that can
accomplish myriad tasks by changing the input parameters.
Creating a snare drum riser with code is obviously a very diferent kind
of thing than picking up two drumsticks and banging out a pattern on
a real drum. And, to be clear, we’re not advocating for code to replace
learning how to perform with live musical instruments. But, code can be
another tool in your musical repertoire for generating repetitive patterns,
exploring mathematical ideas, or playing sequences that are too fast or
intricate to play by hand.
1.6.3 REASON 3: Code lets you build your own musical toolkit
Becoming a professional in any feld is about developing expertise with
tools—acquiring equipment and knowing how to use it. Clearly, this
is true in the music industry, but it’s also true in software. Professional
software engineers acquire specialized equipment and software packages.
They develop expertise in a range of programming languages and techni-
cal frameworks. But, they also build their own specialized tools that they
use across projects. In this book, we’ll show you how to build up your own
8 Why music and coding?
library of Python functions. You can think of functions as specialized tools
that you create to perform diferent musical tasks. In addition to the exam-
ples we described above, you might write a function to generate a chord
progression or play an arpeggio, and you can use functions again and again
across many musical projects.
1.6.4 REASON 4: Code is useful for a thousand and one other things
As we mentioned earlier in this chapter, Python is one of the most power-
ful, multi-purpose languages in the world. It’s used to create web servers
and social media platforms as much as video games, animation, and music.
It’s used for research and data science, politics and journalism. Knowing a
little Python gives you access to powerful machine learning and artifcial
intelligence (AI/ML) techniques that are poised to transform most aspects
of human work, including in creative domains such as music. Python is
both a scripting language and a software engineering platform—equal
parts duct tape and table saw—and it’s capable of everything from quick
fxes to durable software applications. Learning a little Python won’t make
you a software engineer, just like learning a few guitar chords won’t make
you a performance musician. But it’s a start down a path. An open door
that was previously closed, and a new way of using your mind and a new
way of thinking about music.
Sometimes we’ll write code in a table with line numbers so that we can re-
fer to specifc lines. When we introduce new terms, we’ll bold the word.
If you get confused by any of the programming or music terminology,
check out the appendices, which contain quick overviews of all of the
important concepts. We’ll often invite you to follow along with online
examples. The best way to learn is by doing it yourself, so we strongly
Why music and coding? 11
encourage you to try coding in Python online as you go through the
chapters.
Notes
1 It’s said that fans were so infatuated with Liszt’s piano “rockstar” status that
they fought over his silk handkerchiefs and velvet gloves at his performances.
2 We recommend https://www.w3schools.com/python/.
Interlude 1
BASIC POP BEAT
In this interlude we’re going to get familiar with the TunePad interface by
creating a basic rock beat in the style of songs like Roses by SAINt JHN.
You can follow along online by visiting
https://tunepad.com/interlude/pop-beat
DOI: 10.4324/9781003033240-2
Basic pop beat 13
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.