This book would not be possible without the encouragement of manypeople. Id like to thank the nice folks who took my tutorial at the2012 PyCon. The tutorial was based on an earlier draft of this book,and their participation was essential in cleaning the material andinspiring me to finish this book. Id like to thank Vilson Vieira,Marcos Sampaio, Alexandre Passos, and Tiago Vaz for their invaluablesuggestions. Finally, Id like to acknowledge Mara for herpatience, love, and support.
Introduction to Music Notation in n Seconds or Less
Music notation is both simple and complex, not unlike mathnotation. In this chapter well learn enough music notation tounderstand the examples in this book.
The first thing to know about music notation is that time isrepresented from left to right while pitch is represented from bottomto top:
As youd expect, there are symbols to represent different things. Themain symbols are the clef, the time signature, the note head, and thestem, as you can see in the following image:
The time signature shows how many beats are in a measure and the notevalue of the beat. For instance, in the previous image we have sevenbeats (represented by the number 7) of quarter notes (represented bythe number 4). Naturally, we can subdivide a beat into smaller notevalues (see section ).
The actual pitch of a note is determined by the position of a notehead on the staff and the clef being used. Clefs solve the problem ofcramming 80+ notes into five lines. There are three kinds ofclefsG-clef, F-clef, and C-clefand they indicate the pitch nameon a specific line. For instance, the treble clef (the one used in thetwo previous images) indicates that the second line from the bottomhas the note G, while the bass clef indicates that the fourth linefrom the bottom has the low F note.
In the following image we can see six notes in the same graphicalposition in the top staff. Because each note occurs after a differentclef, they will represent different pitches. The arrows show theposition of each note on the piano, while the bottom staff shows wherethese notes would be placed in the treble clef. The sub- andsuperscript eight indicates that a note will sound one octave below orabove than written, respectively.
The note shape and the number of beams (the horizontal linesconnecting two or more notes) indicate the note duration. In thefollowing example the notes have shorter duration as the musicprogresses (see section ). Unlike Python, butlike the C programming language, space is not significant, but it is used to make a score easyto read. Notice how the space between the first and second note isgreater than the space between the third and fourth note. This isbecause the first note is longer than the third:
Finally, you may see symbols above or below a note such as a dot, agreater than (>), a line, or a fermata (on the last note in thefollowing image). They are symbols of expression to tell theperformer how the note should be played. There are dozens ofexpression symbols, but we dont need to worry about them in thisbook:
In this chapter we had the shortest introduction to music notation inthe history of introductions, but this is pretty much all you need toknow to follow the music examples in this book.
The Primitives of Music
In this chapter well see an overview of notes, intervals, and durationsand how to represent them in Python.
Notes
A note is a symbol representing a musical sound.
Pitch is the combination of a frequency in Hertz and a note name. Forinstance, central A has a frequency of 440Hz. This combination issomewhat arbitrary. In the past, the frequency of central A wouldchange depending on the region. In some places, it was equal to 315Hz,for example.
An octave is the interval between two pitches where their frequency has aratio of 2:1. For example, central A has a frequency of 440Hz and theA one octave above has a frequency of 880Hz. Two notes an octaveapart are in a sense alike, being different only in their relativeregisters and often seeming to blend into one another . Inmost cultures the two frequencies are perceived as the same pitchin different registers. In the following image we have twooctaves. Notice how the pattern of black keys is repeated in each octave:
There are many ways to divide an octave. In fact, octave division has beenan important component in music theory for 2500+ years. Today, themost common way to divide the octave is into 12 equal parts, theso-called equal temperament. The equal temperament became prevalent inthe 18th century, and before that many others temperaments were used(see section )