Music Theory for (Non)Musicians and (Non)Programmers
Notations, Part One
In prior articles, we seen some music notation, but there has been no explanation of what they mean. This article will begin covering this topic, but as the previous topics, notations are an expansive subject, and thus, will cover many articles.
In "Beats, Part One," we saw this image:
We learned the top number of the time signature indicates beats per measure and ignored everything else. The bottom number of the time signature shows the type of note we are using for each beat. In this case, we are using a "quarter note" for each beat.
From our knowledge, the staff is telling us:
§ The staff is in the key of C (no sharps or flats are shown)
§ The notes are in treble, indicated by the "G" clef
§ There are 100 beats per minute
§ There are 4 beats per measure (top 4 or of the time signature)
§ A quarter note represents on beat (bottom 4 of the time signature)
What is a Quarter Note?
This is actually a nuanced question, and a question that can stump many musicians when they first start to play. A quarter note, without context, means nothing. A musician cannot strike a single note and say "this is a quarter note." Instead, she must know the beats per minutes and she must know the time signature.
The 4/4 time signature shown above tells the musician that the quarter note takes one beat, but that doesn't mean anything unless she knows the beats per minute. A quarter note in music with 100 beats per minute will have about twice the sustain as a quarter note in a piece of music with 50 beats per minute.
Without the time signature, the musician cannot know how many beats a quarter note takes. In later articles, we will look at other time signatures, but as a quick example, a time signature of 4/8 indicates that a quarter note takes two beats instead of one.
note: A quarter note has many names, depending on the country the author is from. Another name for "quarter note" is "crotchet." Throughout this series, I will stick the the American vernacular.
Time Signatures Using the Quarter Note
Now that we've seen 4/4, what are some other common signatures?
Second to 4/4, the two most common time signatures that indicates a quarter note takes one beat are 3/4 and 2/4.
3/4 Time Signature
2/4 Time Signature
Programming the Quarter Note in 4/4, 3/4, and 2/4
This program will be a slight modification of the program found in "Beats, Part One." As an input, we will take a time signature argument as a tuple, beats per minute, and quantity of bars.
A sample output, representing 4/4 time, will look like this:
Q q q; q | Q q q; q | Q q q; q
"Q" denotes a major accent, "q" is unaccented, and "q;" is a minor accent.
import time def music_one(ts, bpm, bars): beats_per_bar = ts note = ts sleep_step = 60/bpm if beats_per_bar % 2 == 0 and beats_per_bar > 2: minor_accent = beats_per_bar // 2 else: minor_accent = False while bars > 0: print("Q ", end = "", flush = True) time.sleep(sleep_step) for i in range(1, beats_per_bar): if i == minor_accent: print ("q; " , end = "", flush = True) else: print ("q " , end = "", flush = True) time.sleep(sleep_step) print("| ", end = "", flush = True) bars -= 1 music_one((3, 4), 100, 2) >>> Q q q | Q q q | music_one((4, 4), 100, 3) >>> Q q q; q | Q q q; q | Q q q; q | music_one((2, 4), 100, 4) >>> Q q | Q q | Q q | Q q |
More can be done with this code. We could add checks to ensure these are valid time signatures (what is "valid" will be covered in later articles), or we can use the tempo markings found in "Beats, Part One." For right now, mission accomplished. The next several articles will dive deeper into how notations, time signatures, and beats per minutes are entwined.
If you would like to see these ideas and concepts in action, please visit my newest project: butternotes.com