Skip to content

Commit 6c923a1

Browse files
committed
Bach metadata
With thanks to - https://www.bach-chorales.com/BachChoraleTable.htm - the wiki equivalent, - @johentsch
1 parent b5f7f08 commit 6c923a1

375 files changed

Lines changed: 5275 additions & 1515 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Code/Resources/metadata.py

Lines changed: 752 additions & 14 deletions
Large diffs are not rendered by default.

Code/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def write_json(
5959
Write the metadata in json format to the specified path
6060
"""
6161
with open(json_path, "w") as json_file:
62-
json.dump(this_data, json_file, indent=4)
62+
json.dump(this_data, json_file, indent=4, sort_keys=True)
6363

6464

6565
# ------------------------------------------------------------------------------

Code/create_sub-corpus.py

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -100,35 +100,67 @@ def corelli_op3n4() -> None:
100100

101101
# Early Choral
102102

103-
def bach_chorales(move_analyses: bool = False) -> None:
103+
def bach_chorales(
104+
move_analyses: bool = False,
105+
music21_as_url: bool = False
106+
) -> None:
104107
"""
105108
Build the chorales sub-corpus.
106-
Scores = MG external repo
107-
Analyses = DT.
109+
110+
A tricky one.
111+
We organise locally by the Riemenschneider numbering
112+
as this is the format for most of the sources and remote content:
113+
- DT analyses,
114+
- MG external corpus of mxl scores,
115+
- and krn scores
116+
117+
music21 is more complex.
118+
The files broadly follow the bwv numbering, with modifications,
119+
so the exact string file names are included here.
120+
Additionally, there are sometimes duplicates and variants,
121+
so the type for each is a tuple.
122+
Where there is only one entry there is a trailing comma in the form `(<entry>,)`.
123+
Where there are two, the first entry is the one preferred for consistency:
124+
_without_ instruments and _with_ text.
108125
109126
Args:
110127
move_analyses: If True, move DT analyses from local copy to WiR.
128+
music21_as_url: If True, make the `remote_score_music21`
129+
entry a full URL to the music21 score online.
130+
If False, make it instead the shorter string that's used to parse this score
131+
from a local copy of the music21 corpus using `music21.corpus.parse(<string>)`.
111132
Returns: None
112133
"""
113134

114135
source = metadata.bach_chorales
115136
parent_dir_path = make_parent_dirs(source["path_within_WiR"])
116137
dt_source = DT_BASE / source["analysis_source"] # "Bach Chorales"
117138

118-
for riemenschneider_number in range(1, source["items"] + 1): # range(371)
139+
for item in source["items"]:
119140

120141
md = dict()
121142

122-
num = str(riemenschneider_number).zfill(3)
143+
for i in range(len(source["item_keys"])):
144+
md[source["item_keys"][i]] = item[i] # Riemenschneider etc.
123145

124-
new_dir = parent_dir_path / num
125-
make_dir(new_dir)
146+
print(md["Riemenschneider"])
147+
148+
r_string = str(md["Riemenschneider"]).zfill(3) # e.g., "001"
149+
150+
new_dir = parent_dir_path / r_string
151+
# make_dir(new_dir)
126152

127-
md[source["item_keys"]] = riemenschneider_number,
128-
md["remote_score_mxl"] = source["remote_score_mxl"] + num + "/short_score.mxl"
129153
md["composer"] = get_composer(source)
130-
r_string = f"riemenschneider{num}.txt"
131-
md["analysis_source"] = f"{source['analysis_source']}/{r_string}"
154+
155+
md["remote_score_mxl"] = source["remote_score_mxl"] + r_string + "/short_score.mxl"
156+
md["analysis_source"] = f"{source['analysis_source']}/riemenschneider{r_string}.txt"
157+
md["remote_score_krn"] = source["remote_score_krn"] + f"chor{r_string}.krn"
158+
159+
if music21_as_url:
160+
md["remote_score_music21"] = source["remote_score_music21"] + md["music21"][0]
161+
else:
162+
md["remote_score_music21"] = "bach/" + md["music21"][0]
163+
132164
write_json(md, new_dir / "remote.json")
133165

134166
if move_analyses:
@@ -176,8 +208,11 @@ def goudimel(move_analyses: bool = True) -> None:
176208

177209
def madrigals(move_analyses: bool = True) -> None:
178210
"""
179-
Build the madrgials sub-corpus.
180-
Scores = music21 external repo
211+
Build the madrigals sub-corpus.
212+
Scores = music21 external repo:
213+
`remote_score_mxl` points to the full URL to the music21 score online.
214+
`remote_score_music21` is the shorter string that's used to parse this score
215+
from a local copy of the music21 corpus using `music21.corpus.parse(<string>)`.
181216
Analyses = DT.
182217
183218
Args:
@@ -206,16 +241,19 @@ def madrigals(move_analyses: bool = True) -> None:
206241
md["book"] = book
207242
md["number"] = number
208243
md["composer"] = get_composer(source)
244+
245+
# DT, not music21:
209246
md["analysis_source"] = source["analysis_source"] + f"/{m21_dt_string}.txt"
247+
248+
# music21, not DT:
249+
md["remote_score_music21"] = f"monteverdi/{m21_dt_string}.mxl"
210250
md["remote_score_mxl"] = source["remote_score_mxl"] + f"{m21_dt_string}.mxl"
211251

212252
if move_analyses:
213253
analysis_src = madrigals_DT / f"{m21_dt_string}.txt"
214254
analysis_dst = num_dir / "analysis.txt"
215255
shutil.copy(analysis_src, analysis_dst)
216256

217-
print(book, number)
218-
print(md)
219257
write_json(md, num_dir / "remote.json")
220258

221259

@@ -225,7 +263,7 @@ def madrigals(move_analyses: bool = True) -> None:
225263

226264
def tempered_II(move_analyses: bool = True) -> None:
227265
"""
228-
Build the Goudimel chorale sub-corpus.
266+
Build the WTC sub-corpus.
229267
Scores = Krn remote
230268
Analyses = DT.
231269
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
{
2-
"Riemenschneider": [
3-
1
2+
"BWV": "269",
3+
"CPE": 1,
4+
"Riemenschneider": 1,
5+
"Zahn": "5269",
6+
"analysis_source": "Bach Chorales/riemenschneider001.txt",
7+
"composer": "Bach, Johann Sebastian",
8+
"music21": [
9+
"bwv269.mxl"
410
],
11+
"remote_score_krn": "https://raw.githubusercontent.com/craigsapp/bach-370-chorales/master/kern/chor001.krn",
12+
"remote_score_music21": "bach/bwv269.mxl",
513
"remote_score_mxl": "https://raw.githubusercontent.com/MarkGotham/Chorale-Corpus/Bach,_Johann_Sebastian/Chorales/001/short_score.mxl",
6-
"composer": "Bach, Johann Sebastian",
7-
"analysis_source": "Bach Chorales/riemenschneider001.txt"
14+
"text": "Aus meines Herzens Grunde",
15+
"tune": "Aus meines Herzens Grunde"
816
}
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
{
2-
"Riemenschneider": [
3-
2
2+
"BWV": "347",
3+
"CPE": 2,
4+
"Riemenschneider": 2,
5+
"Zahn": "5354b",
6+
"analysis_source": "Bach Chorales/riemenschneider002.txt",
7+
"composer": "Bach, Johann Sebastian",
8+
"music21": [
9+
"bwv347.mxl"
410
],
11+
"remote_score_krn": "https://raw.githubusercontent.com/craigsapp/bach-370-chorales/master/kern/chor002.krn",
12+
"remote_score_music21": "bach/bwv347.mxl",
513
"remote_score_mxl": "https://raw.githubusercontent.com/MarkGotham/Chorale-Corpus/Bach,_Johann_Sebastian/Chorales/002/short_score.mxl",
6-
"composer": "Bach, Johann Sebastian",
7-
"analysis_source": "Bach Chorales/riemenschneider002.txt"
14+
"text": "Ich dank dir, lieber Herre",
15+
"tune": "Ich dank dir, lieber Herre"
816
}
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
{
2-
"Riemenschneider": [
3-
3
2+
"BWV": "153.1",
3+
"CPE": 3,
4+
"Riemenschneider": 3,
5+
"Zahn": "4431",
6+
"analysis_source": "Bach Chorales/riemenschneider003.txt",
7+
"composer": "Bach, Johann Sebastian",
8+
"music21": [
9+
"bwv153.1.mxl"
410
],
11+
"remote_score_krn": "https://raw.githubusercontent.com/craigsapp/bach-370-chorales/master/kern/chor003.krn",
12+
"remote_score_music21": "bach/bwv153.1.mxl",
513
"remote_score_mxl": "https://raw.githubusercontent.com/MarkGotham/Chorale-Corpus/Bach,_Johann_Sebastian/Chorales/003/short_score.mxl",
6-
"composer": "Bach, Johann Sebastian",
7-
"analysis_source": "Bach Chorales/riemenschneider003.txt"
14+
"text": "Schau, lieber Gott, wie meine Feind (1)",
15+
"tune": "Ach Gott, vom Himmel sieh darein"
816
}
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
{
2-
"Riemenschneider": [
3-
4
2+
"BWV": "86.6",
3+
"CPE": 4,
4+
"Riemenschneider": 4,
5+
"Zahn": "4430",
6+
"analysis_source": "Bach Chorales/riemenschneider004.txt",
7+
"composer": "Bach, Johann Sebastian",
8+
"music21": [
9+
"bwv86.6.mxl"
410
],
11+
"remote_score_krn": "https://raw.githubusercontent.com/craigsapp/bach-370-chorales/master/kern/chor004.krn",
12+
"remote_score_music21": "bach/bwv86.6.mxl",
513
"remote_score_mxl": "https://raw.githubusercontent.com/MarkGotham/Chorale-Corpus/Bach,_Johann_Sebastian/Chorales/004/short_score.mxl",
6-
"composer": "Bach, Johann Sebastian",
7-
"analysis_source": "Bach Chorales/riemenschneider004.txt"
14+
"text": "Es ist das Heil uns kommen her (11)",
15+
"tune": "Es ist das Heil uns kommen her"
816
}
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
{
2-
"Riemenschneider": [
3-
5
2+
"BWV": "267",
3+
"CPE": 5,
4+
"Riemenschneider": 5,
5+
"Zahn": "7663",
6+
"analysis_source": "Bach Chorales/riemenschneider005.txt",
7+
"composer": "Bach, Johann Sebastian",
8+
"music21": [
9+
"bwv267.mxl"
410
],
11+
"remote_score_krn": "https://raw.githubusercontent.com/craigsapp/bach-370-chorales/master/kern/chor005.krn",
12+
"remote_score_music21": "bach/bwv267.mxl",
513
"remote_score_mxl": "https://raw.githubusercontent.com/MarkGotham/Chorale-Corpus/Bach,_Johann_Sebastian/Chorales/005/short_score.mxl",
6-
"composer": "Bach, Johann Sebastian",
7-
"analysis_source": "Bach Chorales/riemenschneider005.txt"
14+
"text": "An Wasserfl\u00fcssen Babylon (for B308)",
15+
"tune": "An Wasserfl\u00fcssen Babylon"
816
}
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
{
2-
"Riemenschneider": [
3-
6
2+
"BWV": "281",
3+
"CPE": 7,
4+
"Riemenschneider": 6,
5+
"Zahn": "132",
6+
"analysis_source": "Bach Chorales/riemenschneider006.txt",
7+
"composer": "Bach, Johann Sebastian",
8+
"music21": [
9+
"bwv281.mxl"
410
],
11+
"remote_score_krn": "https://raw.githubusercontent.com/craigsapp/bach-370-chorales/master/kern/chor006.krn",
12+
"remote_score_music21": "bach/bwv281.mxl",
513
"remote_score_mxl": "https://raw.githubusercontent.com/MarkGotham/Chorale-Corpus/Bach,_Johann_Sebastian/Chorales/006/short_score.mxl",
6-
"composer": "Bach, Johann Sebastian",
7-
"analysis_source": "Bach Chorales/riemenschneider006.txt"
14+
"text": "Christus, der ist mein Leben",
15+
"tune": "Christus, der ist mein Leben"
816
}
Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
{
2-
"Riemenschneider": [
3-
7
2+
"BWV": "17.7",
3+
"CPE": 6,
4+
"Riemenschneider": 7,
5+
"Zahn": "8244",
6+
"analysis_source": "Bach Chorales/riemenschneider007.txt",
7+
"composer": "Bach, Johann Sebastian",
8+
"music21": [
9+
"bwv17.7.mxl"
410
],
11+
"remote_score_krn": "https://raw.githubusercontent.com/craigsapp/bach-370-chorales/master/kern/chor007.krn",
12+
"remote_score_music21": "bach/bwv17.7.mxl",
513
"remote_score_mxl": "https://raw.githubusercontent.com/MarkGotham/Chorale-Corpus/Bach,_Johann_Sebastian/Chorales/007/short_score.mxl",
6-
"composer": "Bach, Johann Sebastian",
7-
"analysis_source": "Bach Chorales/riemenschneider007.txt"
14+
"text": "Nun lob, mein Seel, den Herren (3)",
15+
"tune": "Nun lob, mein Seel, den Herren"
816
}

0 commit comments

Comments
 (0)