#@title Setting up music21 in the background. { form-width: "30%" }
# !pip install --upgrade music21
#!add-apt-repository ppa:mscore-ubuntu/mscore-stable -y
# !apt-get update
!apt-get install musescore
!apt-get install xvfb
import os
os.putenv('DISPLAY', ':99.0')
!start-stop-daemon --start --pidfile /var/run/xvfb.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset
from music21 import *
us = environment.UserSettings()
us['musescoreDirectPNGPath'] = '/usr/bin/mscore'
us['directoryScratch'] = '/tmp'
!sh -e /etc/init.d/x11-common start
hint
tooliv
tool (interval vector)tntype
from the Humdrum Extras Toolkitsonority
from the Humdrum Extras ToolkitThese all work quite well.
You can also just parse the kern files in Python, if they're separated consistently. For example, you could parse it as:
for each line:
for each column in that line:
process something.
But you would have to write all of the things to parse out what it means to be a triad, interval vectors, etc.
Thankfully, people have already done that for us.
intervalVector()
tool.chord.Chord
function.commonName
pitchedCommonName
forteClass
primeForm
It requires a bit more time to parse the files (you can use the chordify
function to reduce), but it has a bit more functionality, overall.
For eaxample, you can get:
### the common name (quality) of a chord.
from music21 import *
cMinor = chord.Chord(["C4","G4","E-5"])
###the common name function.
cMinor.commonName
'minor triad'
###pitch and quality
c1 = chord.Chord(['c', 'e-', 'g'])
c1.pitchedCommonName
'C-minor triad'
###it can find some obscure ones
c3 = chord.Chord(['c', 'd-', 'e', 'f#'])
c3.commonName
'all-interval tetrachord'
### but if it doesn't exist, it just gives the Forte class.
c3 = chord.Chord([0, 1, 2, 3, 4, 9])
c3.commonName
'forte class 6-36B'
### and find dominant chords.
c4a = chord.Chord(['c', 'e', 'g', 'b-'])
c4a.commonName
'dominant seventh chord'
### and augmented sixth chords.
c4b = chord.Chord(['c', 'e', 'g', 'a#'])
c4b.commonName
'German augmented sixth chord'
### forte class.
c1 = chord.Chord(['c', 'e-', 'g'])
c1.forteClass
'3-11A'
### equivalent of tntype.
c1 = chord.Chord(['c', 'e-', 'g'])
c1.forteClass
'3-11A'
### tntype without inversion.
c1 = chord.Chord(['c', 'e-', 'g'])
c1.forteClassTnI
'3-11'
### prime form
c1 = chord.Chord(['c', 'e-', 'g'])
c1.primeForm
[0, 3, 7]
jos = corpus.parse('josquin/laDeplorationDeLaMorteDeJohannesOckeghem')
mergedScores = jos.mergeScores()
scoreExcerpt = mergedScores.measures(127, 133)
scoreExcerpt.show()
The chordify
function can reduce the harmony to an object that can be more easily analyzed.
reduction = scoreExcerpt.chordify()
reduction.show()
The loop below (from the music21 User Guide) shows how you can annotate the interval of the piece:
for c in reduction.recurse().getElementsByClass('Chord'):
c.closedPosition(forceOctave=4, inPlace=True)
c.annotateIntervals()
reduction.show()
A similar loop can show all of the labels:
for i in reduction.recurse().getElementsByClass('Chord'):
print(i.commonName)
minor triad minor triad Minor Third minor triad minor triad minor triad minor triad Minor Third lydian tetrachord minor triad perfect-fourth minor tetrachord minor triad minor triad
In order to get Roman numerals, you need to give it the key first. In the example below, you can manually input the key and the chord spelling.
kb = key.Key('C')
f = chord.Chord('F#5 A#5 C#6')
rf = roman.romanNumeralFromChord(f, kb)
rf.figureAndKey
'#IV in C major'
rf.lyric = rf.figureAndKey
rf.show()
#### import a piece
bach_chorale = corpus.parse('bach/bwv99')
bach_chorale.show()
The code below can get the chord quality of every chord in a chorale.
### chordify
reduction = bach_chorale.chordify()
for i in reduction.recurse().getElementsByClass('Chord'):
print(i.commonName)
### roman numeral analysis
### show
major triad quartal tetramirror major triad major triad minor triad major-second major tetrachord major triad major triad quartal trichord perfect-fourth major tetrachord major triad incomplete dominant-seventh chord major triad major triad major seventh chord major triad major triad half-diminished seventh chord major triad quartal tetramirror major triad perfect-fourth major tetrachord quartal trichord quartal tetramirror major-second major tetrachord dominant seventh chord major triad major triad major triad quartal tetramirror major triad major triad minor triad major-second major tetrachord major triad major triad quartal trichord perfect-fourth major tetrachord major triad incomplete dominant-seventh chord major triad major triad major seventh chord major triad major triad half-diminished seventh chord major triad quartal tetramirror major triad perfect-fourth major tetrachord quartal trichord quartal tetramirror major-second major tetrachord dominant seventh chord major triad major triad major triad major triad major-second major tetrachord major triad diminished triad major triad minor triad major-second minor tetrachord augmented major tetrachord minor triad minor triad minor triad minor triad minor seventh chord major triad major-second major tetrachord half-diminished seventh chord dominant seventh chord major-second major tetrachord major triad minor triad minor seventh chord minor seventh chord major triad dominant seventh chord major triad minor triad major seventh chord diminished triad major triad major seventh chord major triad dominant seventh chord major triad quartal trichord quartal trichord major triad quartal tetramirror dominant seventh chord major triad
import re
### can we get a Roman numeral analysis?
### get the key...
sapp_key = analysis.discrete.SimpleWeights(bach_chorale)
key = sapp_key.getSolution(bach_chorale)
## reduce
reduction = bach_chorale.chordify()
chords = []
tonics = []
dominants = []
## loop over every chord.
for i in reduction.recurse().getElementsByClass('Chord'):
f = chord.Chord(i)
rf = roman.romanNumeralFromChord(f, key)
chords.append(rf.figure)
roman_figure = str(rf.figure)
if re.search("^ii$", roman_figure):
tonics.append(roman_figure)
elif re.search("^V$", roman_figure):
dominants.append(roman_figure)
total = len(chords)
dominants = len(dominants)
tonics = len(tonics)
print("Dominants:")
print(dominants/total)
print("Tonics:")
print(tonics/total)
# print(rf.figure)
# or print(rf.figureAndKey)
Dominants: 0.10416666666666667 Tonics: 0.0
How might we get all Roman numerals in all Bach Chorales?
# your code here.
# Let's set the google drive up so that we can access those polska files...
# step 1: get all of our chorales from the google drive
# step 2: run a loop over all of those chorales.
# step 3: for each chorale, we need the key, and then we need the roman numerals.
# find total amount of chords
# we want to find all tonics and all dominants.
# if 'V' or 'vii' put into dominant array.
# if I or i put into tonic array.
# tonic/total
# dominant/total
aarden_key = analysis.discrete.AardenEssen(bach_chorale)
key = aarden_key.getSolution(bach_chorale)
## reduce
reduction = bach_chorale.chordify()
for i in reduction.recurse().getElementsByClass('Chord'):
f = chord.Chord(i)
rf = roman.romanNumeralFromChord(f, key)
i.closedPosition(forceOctave=4, inPlace=True)
i.addLyric(rf.figure)
reduction.show()
# ## loop over every chord.
# for i in reduction.recurse().getElementsByClass('Chord'):
# f = chord.Chord(i)
# rf = roman.romanNumeralFromChord(f, key)
# print(rf.figure)
# # print(rf.figure)
# # or print(rf.figureAndKey)
It's not entirely clear how helpful such an annotation would be, though...
Today we will:
context
tool in Humdrum, and write something that's somewhat equivalent in Python.while
loops.But how often are we getting certain types of transitions?
chord_qualities = []
### chordify
reduction = bach_chorale.chordify()
for i in reduction.recurse().getElementsByClass('Chord'):
chord_qualities.append(i.commonName)
print(i.commonName)
### roman numeral analysis
### show
major triad quartal tetramirror major triad major triad minor triad major-second major tetrachord major triad major triad quartal trichord perfect-fourth major tetrachord major triad incomplete dominant-seventh chord major triad major triad major seventh chord major triad major triad half-diminished seventh chord major triad quartal tetramirror major triad perfect-fourth major tetrachord quartal trichord quartal tetramirror major-second major tetrachord dominant seventh chord major triad major triad major triad quartal tetramirror major triad major triad minor triad major-second major tetrachord major triad major triad quartal trichord perfect-fourth major tetrachord major triad incomplete dominant-seventh chord major triad major triad major seventh chord major triad major triad half-diminished seventh chord major triad quartal tetramirror major triad perfect-fourth major tetrachord quartal trichord quartal tetramirror major-second major tetrachord dominant seventh chord major triad major triad major triad major triad major-second major tetrachord major triad diminished triad major triad minor triad major-second minor tetrachord augmented major tetrachord minor triad minor triad minor triad minor triad minor seventh chord major triad major-second major tetrachord half-diminished seventh chord dominant seventh chord major-second major tetrachord major triad minor triad minor seventh chord minor seventh chord major triad dominant seventh chord major triad minor triad major seventh chord diminished triad major triad major seventh chord major triad dominant seventh chord major triad quartal trichord quartal trichord major triad quartal tetramirror dominant seventh chord major triad
import numpy as np
import pandas as pd
values, counts = np.unique(chord_qualities, return_counts=True)
df = pd.DataFrame(list(zip(values, counts)), columns= ['Chord','Counts'])
df.sort_values(by=['Counts'], ascending=False)
Chord | Counts | |
---|---|---|
6 | major triad | 41 |
10 | minor triad | 9 |
7 | major-second major tetrachord | 7 |
12 | quartal tetramirror | 7 |
2 | dominant seventh chord | 6 |
13 | quartal trichord | 6 |
5 | major seventh chord | 4 |
11 | perfect-fourth major tetrachord | 4 |
3 | half-diminished seventh chord | 3 |
9 | minor seventh chord | 3 |
1 | diminished triad | 2 |
4 | incomplete dominant-seventh chord | 2 |
0 | augmented major tetrachord | 1 |
8 | major-second minor tetrachord | 1 |
bi_gram = []
i= 0
while(i< len(chord_qualities)-1):
roman_numerals = f'{chord_qualities[i]} --> {chord_qualities[i+1]}'
bi_gram.append(roman_numerals)
i=i+1
print(bi_gram)
values, counts = np.unique(bi_gram, return_counts=True)
df = pd.DataFrame(list(zip(values, counts)), columns= ['Bigrams', 'Counts'])
df.sort_values(by=['Counts'], ascending=False)
['major triad --> quartal tetramirror', 'quartal tetramirror --> major triad', 'major triad --> major triad', 'major triad --> minor triad', 'minor triad --> major-second major tetrachord', 'major-second major tetrachord --> major triad', 'major triad --> major triad', 'major triad --> quartal trichord', 'quartal trichord --> perfect-fourth major tetrachord', 'perfect-fourth major tetrachord --> major triad', 'major triad --> incomplete dominant-seventh chord', 'incomplete dominant-seventh chord --> major triad', 'major triad --> major triad', 'major triad --> major seventh chord', 'major seventh chord --> major triad', 'major triad --> major triad', 'major triad --> half-diminished seventh chord', 'half-diminished seventh chord --> major triad', 'major triad --> quartal tetramirror', 'quartal tetramirror --> major triad', 'major triad --> perfect-fourth major tetrachord', 'perfect-fourth major tetrachord --> quartal trichord', 'quartal trichord --> quartal tetramirror', 'quartal tetramirror --> major-second major tetrachord', 'major-second major tetrachord --> dominant seventh chord', 'dominant seventh chord --> major triad', 'major triad --> major triad', 'major triad --> major triad', 'major triad --> quartal tetramirror', 'quartal tetramirror --> major triad', 'major triad --> major triad', 'major triad --> minor triad', 'minor triad --> major-second major tetrachord', 'major-second major tetrachord --> major triad', 'major triad --> major triad', 'major triad --> quartal trichord', 'quartal trichord --> perfect-fourth major tetrachord', 'perfect-fourth major tetrachord --> major triad', 'major triad --> incomplete dominant-seventh chord', 'incomplete dominant-seventh chord --> major triad', 'major triad --> major triad', 'major triad --> major seventh chord', 'major seventh chord --> major triad', 'major triad --> major triad', 'major triad --> half-diminished seventh chord', 'half-diminished seventh chord --> major triad', 'major triad --> quartal tetramirror', 'quartal tetramirror --> major triad', 'major triad --> perfect-fourth major tetrachord', 'perfect-fourth major tetrachord --> quartal trichord', 'quartal trichord --> quartal tetramirror', 'quartal tetramirror --> major-second major tetrachord', 'major-second major tetrachord --> dominant seventh chord', 'dominant seventh chord --> major triad', 'major triad --> major triad', 'major triad --> major triad', 'major triad --> major triad', 'major triad --> major-second major tetrachord', 'major-second major tetrachord --> major triad', 'major triad --> diminished triad', 'diminished triad --> major triad', 'major triad --> minor triad', 'minor triad --> major-second minor tetrachord', 'major-second minor tetrachord --> augmented major tetrachord', 'augmented major tetrachord --> minor triad', 'minor triad --> minor triad', 'minor triad --> minor triad', 'minor triad --> minor triad', 'minor triad --> minor seventh chord', 'minor seventh chord --> major triad', 'major triad --> major-second major tetrachord', 'major-second major tetrachord --> half-diminished seventh chord', 'half-diminished seventh chord --> dominant seventh chord', 'dominant seventh chord --> major-second major tetrachord', 'major-second major tetrachord --> major triad', 'major triad --> minor triad', 'minor triad --> minor seventh chord', 'minor seventh chord --> minor seventh chord', 'minor seventh chord --> major triad', 'major triad --> dominant seventh chord', 'dominant seventh chord --> major triad', 'major triad --> minor triad', 'minor triad --> major seventh chord', 'major seventh chord --> diminished triad', 'diminished triad --> major triad', 'major triad --> major seventh chord', 'major seventh chord --> major triad', 'major triad --> dominant seventh chord', 'dominant seventh chord --> major triad', 'major triad --> quartal trichord', 'quartal trichord --> quartal trichord', 'quartal trichord --> major triad', 'major triad --> quartal tetramirror', 'quartal tetramirror --> dominant seventh chord', 'dominant seventh chord --> major triad']
Bigrams | Counts | |
---|---|---|
14 | major triad --> major triad | 13 |
2 | dominant seventh chord --> major triad | 5 |
18 | major triad --> quartal tetramirror | 5 |
16 | major triad --> minor triad | 5 |
22 | major-second major tetrachord --> major triad | 4 |
34 | quartal tetramirror --> major triad | 4 |
13 | major triad --> major seventh chord | 3 |
19 | major triad --> quartal trichord | 3 |
30 | minor triad --> minor triad | 3 |
8 | major seventh chord --> major triad | 3 |
35 | quartal tetramirror --> major-second major tet... | 2 |
10 | major triad --> dominant seventh chord | 2 |
27 | minor triad --> major-second major tetrachord | 2 |
31 | perfect-fourth major tetrachord --> major triad | 2 |
32 | perfect-fourth major tetrachord --> quartal tr... | 2 |
24 | minor seventh chord --> major triad | 2 |
38 | quartal trichord --> quartal tetramirror | 2 |
37 | quartal trichord --> perfect-fourth major tetr... | 2 |
1 | diminished triad --> major triad | 2 |
5 | half-diminished seventh chord --> major triad | 2 |
6 | incomplete dominant-seventh chord --> major triad | 2 |
17 | major triad --> perfect-fourth major tetrachord | 2 |
15 | major triad --> major-second major tetrachord | 2 |
29 | minor triad --> minor seventh chord | 2 |
12 | major triad --> incomplete dominant-seventh chord | 2 |
11 | major triad --> half-diminished seventh chord | 2 |
20 | major-second major tetrachord --> dominant sev... | 2 |
36 | quartal trichord --> major triad | 1 |
33 | quartal tetramirror --> dominant seventh chord | 1 |
0 | augmented major tetrachord --> minor triad | 1 |
28 | minor triad --> major-second minor tetrachord | 1 |
26 | minor triad --> major seventh chord | 1 |
25 | minor seventh chord --> minor seventh chord | 1 |
23 | major-second minor tetrachord --> augmented ma... | 1 |
21 | major-second major tetrachord --> half-diminis... | 1 |
9 | major triad --> diminished triad | 1 |
7 | major seventh chord --> diminished triad | 1 |
4 | half-diminished seventh chord --> dominant sev... | 1 |
3 | dominant seventh chord --> major-second major ... | 1 |
39 | quartal trichord --> quartal trichord | 1 |
So what was the while
functionality in that last bit of code?
There are a number of steps here that might be of interest:
It will repeat this until it gets to the length of the variable (-1).
i= 0
while(i< len(chord_qualities)-1):
roman_numerals = f'{chord_qualities[i]} --> {chord_qualities[i+1]}'
bi_gram.append(roman_numerals)
i=i+1
Here is a basic example of a while
loop:
i = 1
while i < 6:
print(i)
i += 1
1 2 3 4 5
You can also add break statements, to exit out of the loop when needed:
i = 1
while i < 20:
print(i)
if i == 18:
break
i += 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
And you can go the other way too...
count = 10
print("Can you hear me, Major Tom??")
while (count > 0):
print(count)
count = count - 1
print("Floating in my tin cannnnn...")
Can you hear me, Major Tom?? 10 9 8 7 6 5 4 3 2 1 Floating in my tin cannnnn...
On Monday, we looked at the below code that returned the Roman numerals of a chorale (I've changed it a little bit to create an array, and not a print
statement.)
Let's try to get the same type of table, but with Roman numerals. It might be worth considering a function for this. Perhaps a "make_bigram_table" function or something.
### can we get a Roman numeral analysis?
### get the key...
aarden_key = analysis.discrete.AardenEssen(bach_chorale)
key = aarden_key.getSolution(bach_chorale)
## reduce
reduction = bach_chorale.chordify()
rn = []
## loop over every chord.
for i in reduction.recurse().getElementsByClass('Chord'):
f = chord.Chord(i)
rf = roman.romanNumeralFromChord(f, key)
print(rf.figure)
rn.append(rf.figure)
# print(rf.figure)
# or print(rf.figureAndKey)
I ii542 I V6 vi IV742 IV I6 iv52 I752 V V7 I IV IV7 V IV6 vii/o7 I ii542 I6 I752 i54 ii754 I654 V7 V I I ii542 I V6 vi IV742 IV I6 iv52 I752 V V7 I IV IV7 V IV6 vii/o7 I ii542 I6 I752 i54 ii754 I654 V7 V I I IV IV532 II6 #ivo5b3 V vii iii53#2 V+#642 iii6 iii vi vi vi42 II6 II763 #iv/ob6b42 II75#3 V532 II6 iii iii42 vi65 II II75#3 V iii IV65 viio I IV43 V V42 I6 iv54 i54 V iii652 V7 I
def make_bigram_table(dataset, viz=False):
### create an empty variable
bi_gram = []
###start a counter for my while loop.
i= 0
###here's my while loop.
while(i< len(dataset)-1):
roman_numerals = f'{dataset[i]} --> {dataset[i+1]}'
bi_gram.append(roman_numerals)
i=i+1
"""
you might remember this code from last week. It creates a dataframe.
The one thing that's different is that now there's a variable for the max rows,
so it can change depending on however long the dataset is.
"""
pd.set_option('max_rows', len(dataset))
values, counts = np.unique(bi_gram, return_counts=True)
df = pd.DataFrame(list(zip(values, counts)), columns= ['Bigrams', 'Counts'])
"""
here, I've written in a little argument for how to display the data. The default
for the viz argument is false, so it will print out a table by default.
If viz is flipped to True, however, it will give a little histogram.
Here, I'm using Pandas groupby, which can actually do the summing function
we called before. If you have many columns in your data, it's usually best to just work
here within the pandas toolkit.
"""
if viz == False:
display(df.sort_values(by=['Counts'], ascending=False))
else:
df = df.groupby('Bigrams')['Counts'].sum()
df.sort_values()[-15:].plot(kind='bar')
make_bigram_table(rn, viz=True)
What if I just want roman numerals from downbeats? How would I find that?
Recall that we used this beatStrength
function a couple of weeks ago...
for n in littleMelody.flat.notes:
if n.beatStrength == 1:
n.show()
### our code here...
rn =[]
def downbeat_finder(file):
bach_chorale = converter.parse(file)
bach_chorale = bach_chorale.chordify()
aarden_key = analysis.discrete.AardenEssen(bach_chorale)
key = aarden_key.getSolution(bach_chorale)
rn = []
for n in bach_chorale.flat.notes:
if n.beatStrength == 1:
rf = roman.romanNumeralFromChord(n, key)
print(rf.figure)
rn.append(rf.figure)
# # print(rf.figure)
# # or print(rf.figureAndKey)
for i in file_list:
downbeat_finder(i)
I II65 I I V6 II vi65 III65 ii42 I vi I532 I I I vi ii I I vi42 I6 ii I I vi I vi65 IV v6 ii ii6 ii54 I42 IV I ii65 I IV V7 I IV I I II I IV II V IV vi I I I iii ii I IV6 I64 V II6 V I6 v7b3 vi I64 I IV V vi7 V V I ii542 I I V vi ii7 I I V7 V iii V IV VI ii i54 I #vo6 I ii65 bVI bVII i i III viio#63 V i IV6 III6 iv6 iv54 I II v i ii/o65 i i i v64 bVII6 i V6 I V6 I ii542 ii6 V V6 V I V IV ii V I i IV6 i viio#63 V III6 i iv bVII ii/o42 i6 i64 III+6 V6 bVI i i V6 bVI i II6 bVII6 i54 i V6 iio6 I bVII ii7 ii65 iiio6 IV V65 iv54 I6 IV6 I V I vi I6 I V6 V ii I V7 V vii7 V IV532 I ii532 i54 vi VI65 iii ii65 I I I6 vi6 V I6 I I64 I I I6b5 I64 I I IV IV6 V I IV IV6 I IV I ii542 ii6 i54 I vi IV ii65 I I6 V vi7 V vi viio6 II7#3 V IV65 II65 I6 I IV IV65 I6 vi7 vi V vi ii I6 vi7 I6 I64 i ii/o65 i I6 i6 i i IV65 III #ivo6b5b3 V IV6 I i II6 V IV6 i i bVI6 III III iv65 III bVI i6 ii/o65 vi iii I I vi I V6 V I V42 III#42 vi ii65 I I6 I I V6 I732 vi ii65 I vi532 III IV V532 vi532 V6 I ii65 I6 I II v i ii/o65 i i i v bVII i532 III ii/o65 i v6 v i bVI v v i64 IV6 v#54 I65 vio#63 v V6 bVI iio6 IV v64 i6 i6 V V65 i V i iv65 IV #ivob7b53 III6 IV65 bVII ii/o65 bVII6 III i IV6 I65 bVII6 ii/o65 i6 iv iv iv6 V V i IIIb753 bVII i6 I V42 viio6 ii42 I V V II6 V64 V V vi vi vi64 vi IV I64 I I6 vi ii6 I I I V I6 V I iii542 IV6 I i ii/o65 viio#63 V V IV6 i i v ii bVII bVII bVII v III V III bVII V6 V i6 ii i6 V V ii i I i iv V i bVII6 V v bVI6 i i viio IV bVII6 v i532 bVII bvii6 i64 V IV65 bVI ii/o42 bVI I6 bII v/ob642 bVI iv532 v iv7 bVII III6 iv54 iv bvi54 I I vi ii I I vi42 I6 ii I i V6 #ivob7b53 i i II6 v bVI i6 V6 iv V i bvii54 i54 i v/ob642 v bVI6 i i i bVII v42 III i bVII bVII65 i54 i #ivob7b53 bVII i III6 ii/o65 bVII IV65 III+6 V6 II65#3 i bVI7 III bVII6 bVI ii/o65 i bVI6 III iii54 bVII6 iii54 I75#3 iii54 ii/o65 i i i i42 bVII6 i i i V6 iv6 III bVII6 i V IV6 IV75#3 bVII III6 vio#63 v#54 i6 iio6 i54 i V6 IV65 v6 V bVII III bVI III III ii/o42 i i54 bVI i IV65 III i532 i54 i i V I42 I532 V6 I6 V IV7 IV ii54 IV532 iii/ob642 #io5b3 V532 I ii42 I iv54 i bVII6 iv III6 bVI III64 V6 i54 IV65 bVII iv i54 i64 IV III65 vi IV IV I I6 I6 i54 IV IV64 II75#3 IV64 ii IV I I V6 I532 I vi65 IV6 I6 i bVI V i7 ii/o65 V i iv65 viio#63 i64 I ii754 I6 i54 I II6#42 V6 I6 I532 I i54 I6 II#42 I II65 V6 vi I6 IV bVII i54 I532 I I6 I vi i54 V III IV vi54 iii6 V V I vi V III6 vi I6 V ii V ii VI6 IV6 bVII+6 V65 i6 V III6 V i iv65 bVI III64 bVII6 IV65 V6 ii/o65 i6 iv6 bVI7 iii54 #ivob7b53 v64 bVII iv bVII i532 bVII+6 #iii/o7 V6 V42 I V6 I6 I vi vi V IV I iii7 V I6 I6 vi IV I I6 v65 IV I6 iii6 I ii7 I I6 vio6 IV viio6 I IV6 bVII6 I iv V vi/o6#43 V i bVII i iv65 bVII6 IV65 V ii/o65 I I6 vi vi64 ii532 I ii7 I I6 ii ii IV ii65 I6 ii6 I ii65 I I6 vi vi532 vi vi ii65 i V i6 V i iv65 i iv65 bVII6 IV65 V ii/o65 I vi7 vi I64 I vi I6 IV6 I IV vi ii6 i54 vi IV532 vi I I vi I6 I I6 IV i54 vi vi II6 I6 V I6 ii65 I IV532 ii iii/o43 ii I ii iii7 IV532 II6 I6 V I65 VI65 i52 V IV6 I I I V7 V6 V V IV I ii V7 I v54 VI75#3 ii6 i iio6 viio64#2 viio#63 bVII bVI i54 viio#63 V i6 iv6 #ivo6b5b3 i i bVII III6 bVI I bVII i65 iv V65 i i III ii/o65 I v/o65b3 bVII iv65 bVI II65#3 I II6 V6 V64 I ii V6 II65 IV ii I i54 I V6 I532 I vi I ii532 ii IV+6 I6 v5b32 vi iii i54 vi ii42 I ii V V65 V ii IV V6 II65 I V I532 I I532 i54 I vi vi i54 I IV vii/o65 ii7 I I I V6 I vii/o65 ii I IV IV65 I6 vi7 I6 V vi ii iii64 vi7 vi I64 I vi I I6 I V bVII#7#3 I vi V I6 i iv7 iv65 III I6 v#54 i532 i6 III i64 bVII v bVII6 IV i iv6 ii/o65 i IV6 bVII532 III532 III6 bVII i i532 III i V i IV#643 ii/o65 I I I64 V I64 I IV I6 i54 vi65 IV6 ii65 i V6 i viio7 IV6 bvii54 III6 viio#63 IV65 iv43 i iio6 I I I V V532 V V vi65 I I532 I i54 vi65 II65 V ii ii65 bVII bVI532 v vi7 bVI iii54 III i7 IV7#3 III6 i iv IV65 III6 I65 viio#63 bVI6 IV65 bVI532 iii54 bVI iv65 i i i iio6 III6 bVI7 I bVII i6 bVI6 III732 i ii/o65 i54 i ii/o65 i i i bVI732 vio#63 bVI532 bVII iv i V6 I VI6#42 ii IV6 v IV6 I V6 bVII V65 V IV6 I i6 V iv III III IV bVII V I I ii7 II6 vi6 I vi IV65 iv6 I vi IV vi I vi II65 V65 V V6 ii65 IV vi I V6 I64 I IV vi IV65 vi V65 ii65 I I6 IV6 II65 vi65 I ii532 I42 ii II6 VI65 V42 ii65 I6 V6 iii64 ii ii42 vi6 V6 ii7 IV64 I I II65 I6 ii6 I V6 viio6 V6 ii7 ii7 I iii ii532 IV6 vi52 I I6 vi IV6 I i i bVII6 iv6 iv bVII7 i bVI vi ii65 I i54 I I6 vi I vi vi i54 I bVII V I I I V V6 vi vi I vi v I V64 iii IV6 IV ii ii vi I vi I I I ii7 I ii65 V iii/o65b3 ii v65 vi ii7 I ii65 I IV532 ii7 I I VI6 ii V I vi7 ii6 ii V6 i54 ii I I v iv54 V vi I vii6 iii i54 iii II65 v i i iv V bVII III III6 i i iv6 I iii54 i bVII6 III i6 bvi54 bVI III bVI v iv I iv V
--------------------------------------------------------------------------- KeyboardInterrupt Traceback (most recent call last) <ipython-input-133-96e645e2babe> in <module>() 1 for i in file_list: ----> 2 downbeat_finder(i) <ipython-input-132-ac42108090ed> in downbeat_finder(file) 2 rn =[] 3 def downbeat_finder(file): ----> 4 bach_chorale = converter.parse(file) 5 bach_chorale = bach_chorale.chordify() 6 aarden_key = analysis.discrete.AardenEssen(bach_chorale) /usr/local/lib/python3.6/dist-packages/music21/converter/__init__.py in parse(value, *args, **keywords) 1125 elif not isinstance(value, bytes) and os.path.exists(valueStr): 1126 return parseFile(valueStr, number=number, format=m21Format, -> 1127 forceSource=forceSource, **keywords) 1128 elif not isinstance(value, bytes) and os.path.exists(common.cleanpath(valueStr)): 1129 return parseFile(common.cleanpath(valueStr), number=number, format=m21Format, /usr/local/lib/python3.6/dist-packages/music21/converter/__init__.py in parseFile(fp, number, format, forceSource, **keywords) 1005 v = Converter() 1006 fp = common.cleanpath(fp, returnPathlib=True) -> 1007 v.parseFile(fp, number=number, format=format, forceSource=forceSource, **keywords) 1008 return v.stream 1009 /usr/local/lib/python3.6/dist-packages/music21/converter/__init__.py in parseFile(self, fp, number, format, forceSource, storePickle, **keywords) 540 else: 541 environLocal.printDebug("Loading original version") --> 542 self.parseFileNoPickle(fp, number, format, forceSource, **keywords) 543 if writePickle is True and fpPickle is not None and storePickle is True: 544 # save the stream to disk... /usr/local/lib/python3.6/dist-packages/music21/converter/__init__.py in parseFileNoPickle(self, fp, number, format, forceSource, **keywords) 475 self.subConverter.keywords = keywords 476 try: --> 477 self.subConverter.parseFile(fp, number=number, **keywords) 478 except NotImplementedError: 479 raise ConverterFileException('File is not in a correct format: %s' % fp) /usr/local/lib/python3.6/dist-packages/music21/converter/subConverters.py in parseFile(self, filepath, number) 644 ''' 645 from music21 import humdrum --> 646 self.data = humdrum.parseFile(filepath) 647 #self.data.stream.makeNotation() 648 /usr/local/lib/python3.6/dist-packages/music21/humdrum/__init__.py in parseFile(filename) 165 ''' 166 hf = spineParser.HumdrumFile(filename) --> 167 hf.parseFilename() 168 return hf 169 /usr/local/lib/python3.6/dist-packages/music21/humdrum/spineParser.py in parseFilename(self, filename) 789 filename = str(filename) 790 with open(filename, encoding='latin-1') as humFH: --> 791 self.eventList = self.parseFileHandle(humFH) 792 # might raise IOError 793 /usr/local/lib/python3.6/dist-packages/music21/humdrum/spineParser.py in parseFileHandle(self, fileHandle) 801 spineDataCollection.append(line) 802 self.dataStream = spineDataCollection --> 803 return self.parse() 804 805 class HumdrumLine: /usr/local/lib/python3.6/dist-packages/music21/humdrum/spineParser.py in parse(self) 165 return self.parseOpusDataCollections(dataCollections) 166 else: --> 167 return self.parseNonOpus(dataStream) 168 169 /usr/local/lib/python3.6/dist-packages/music21/humdrum/spineParser.py in parseNonOpus(self, dataStream) 186 self.parseProtoSpinesAndEventCollections() 187 self.spineCollection = self.createHumdrumSpines() --> 188 self.spineCollection.createMusic21Streams() 189 self.insertGlobalEvents() 190 for thisSpine in self.spineCollection: /usr/local/lib/python3.6/dist-packages/music21/humdrum/spineParser.py in createMusic21Streams(self) 1654 ''' 1655 self.reclassSpines() -> 1656 self.parseMusic21() 1657 self.performInsertions() 1658 self.moveObjectsToMeasures() /usr/local/lib/python3.6/dist-packages/music21/humdrum/spineParser.py in parseMusic21(self) 1953 ''' 1954 for thisSpine in self.spines: -> 1955 thisSpine.parse() 1956 1957 /usr/local/lib/python3.6/dist-packages/music21/humdrum/spineParser.py in parse(self) 1315 thisObject = self.processChordEvent(eventC) 1316 else: # Note or Rest -> 1317 thisObject = self.processNoteEvent(eventC) 1318 1319 if thisObject is not None: /usr/local/lib/python3.6/dist-packages/music21/humdrum/spineParser.py in processNoteEvent(self, eventC) 1339 note, but stores information about current beam and tuplet state. 1340 ''' -> 1341 eventNote = hdStringToNote(eventC) 1342 1343 self.setBeamsForNote(eventNote) /usr/local/lib/python3.6/dist-packages/music21/humdrum/spineParser.py in hdStringToNote(contents) 2173 elif contents.count('W'): 2174 thisObject.expressions.append(expressions.WholeStepInvertedMordent()) -> 2175 elif contents.count('m'): 2176 thisObject.expressions.append(expressions.HalfStepMordent()) 2177 elif contents.count('M'): KeyboardInterrupt:
make_bigram_table(rn)
Bigrams | Counts |
---|