-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
640 lines (532 loc) · 18.8 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
## scarlatti-keyboard-sonatas Makefile
##
## Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu>
## Creation Date: Tue Jun 3 16:52:17 PDT 2014
## Last Modified: Tue Jun 3 16:52:20 PDT 2014
## Filename: Makefile
## Syntax: GNU/BSD makefile
##
## Description: Makefile for basic processing Humdrum data files
## for the piano sonatas of Dominico Scarlatti.
##
## To run this makefile, type "make" (without quotes) to see a list
## of the makefile actions which can be done.
##
# targets which don't actually refer to files:
.PHONY : abc kernscores lilypond mei midi midi-norep musedata musicxml notearray pdf-abc pdf-lilypond pdf-musedata reference-edition
all:
@echo ''
@echo 'Run this makefile with one of the following labels:'
@echo ' "[0;32mmake update[0m" : download any new changes from online repository.'
@echo ' "[0;32mmake reference[0m" : download PDF scans of reference editions.'
@echo ' "[0;32mmake clean[0m" : delete data directories created by this makefile.'
@echo ''
@echo 'Commands requiring the Humdrum Toolkit to be installed:'
@echo ' "[0;32mmake census[0m" : run the census command on all files.'
@echo ''
@echo 'Commands requiring Humdrum Extras to be installed.'
@echo ' "[0;32mmake abc[0m" : convert to ABC+ files.'
@echo ' "[0;32mmake kernscores[0m" : download equivalent from kernscores.'
@echo ' "[0;32mmake mei[0m" : convert to MEI files.'
@echo ' "[0;32mmake midi[0m" : convert to MIDI files (full repeats)'
@echo ' "[0;32mmake midi-norep[0m" : convert to MIDI files (no repeats)'
@echo ' "[0;32mmake musedata[0m" : convert to MuseData files.'
@echo ' "[0;32mmake musicxml[0m" : convert to MusicXML files.'
@echo ' "[0;32mmake notearray[0m" : create notearray files.'
@echo ' "[0;32mmake searchindex[0m" : create themax search index.'
@echo ''
@echo 'Commands requiring other software to be installed.'
@echo ' "[0;32mmake pdf-abc[0m" : convert to PDF files with abcm2ps.'
@echo ' "[0;32mmake pdf-lilypond[0m": convert to PDF files with lilypond.'
@echo ' "[0;32mmake pdf-musedata[0m": convert to PDF files with muse2ps.'
@echo ''
############################################################################
##
## General make commands:
##
##############################
#
# make update -- Download any changes in the Github repositories for
# each composer. To download for the first time, type:
# git clone https://github.com/craigsapp/scarlatti-keyboard-sonatas
#
update: github-pull
pull: github-pull
github: github-pull
githubupdate: github-pull
githubpull: github-pull
github-pull: git-check git-repository-check
git pull
##############################
#
# make kernscores -- Download scores from the kernScores website
# (http://kern.humdrum.org). In theory these are the same as the
# files in the kern directory.
#
kernscores: humdrum-extras-check
mkdir -p kernscores; (cd kernscores && humsplit h://scarlatti/sonatas)
@echo "[0;32m"
@echo "*** Downloaded data from kernScores website into '[0;31mkernscores[0;32m' directory."
@echo "[0m"
##############################
##
## make reference-edition -- Download scans of the source edition for the
## encodings from the kernScore website.
##
pdf: reference-edition
pdfs: reference-edition
webpdf: reference-edition
webpdfs: reference-edition
reference: reference-edition
reference-pdf: reference-edition
reference-edition:
-mkdir reference-edition
ifeq ($(shell which wget),)
ifeq ($(shell which curl),)
# No wget or curl, so don't know how to download
@echo "[0;31m"
@echo "*** Error: don't know how to download from the internet."
@echo "*** Install wget or curl on your computer and try again."
@echo "[0m"
else
# Don't have wget but have curl
for file in kern/*.krn; do \
TBASE=`basename $$file .krn`; \
echo "Downloading reference-edition/$$TBASE.pdf"; \
curl \
"http://kern.humdrum.org/data?l=scarlatti/sonatas&file=$$TBASE.krn&format=pdf" \
-o reference-edition/$$TBASE.pdf >& /dev/null; \
done
@echo "[0;32m"
@echo "*** Download PDF files in '[0;31mreference-edition[0;32m' directory."
@echo "[0m"
endif
else
# Have wget
for file in kern/*.krn; do \
TBASE=`basename $$file .krn`; \
echo "Downloading reference-edition/$$TBASE.pdf"; \
wget -w 3 \
"http://kern.humdrum.org/data?l=scarlatti/sonatas&file=$$TBASE.krn&format=pdf" \
-O reference-edition/$$TBASE.pdf >& /dev/null; \
done
@echo "[0;32m"
@echo "*** Download PDF files in '[0;31mreference-edition[0;32m' directory."
@echo "[0m"
endif
##############################
#
# make clean -- Remove all automatically generated or downloaded data files.
# Make sure that you have not added your own content into the directories
# in which these derivative files are located; otherwise, these will be
# deleted as well.
#
clean:
-rm -rf abc
-rm -rf kernscores
-rm -rf lilypond
-rm -rf mei
-rm -rf midi
-rm -rf midi-norep
-rm -rf musedata
-rm -rf musicxml
-rm -rf notearray
-rm -rf pdf-abc
-rm -rf pdf-lilypond
-rm -rf pdf-musedata
-rm -rf reference-edition
-rm searchindex.dat
############################################################################
##
## Humdrum Extras related make commands:
##
##############################
#
# make midi -- Create midi files for music, expanding repeats.
#
midi: humdrum-extras-check
mkdir -p midi
for file in kern/*.krn; \
do \
TBASE=`basename $$file .krn`; \
echo Creating midi/$$TBASE.mid; \
thrux $$file | hum2mid -o midi/$$TBASE.mid; \
done
@echo "[0;32m"
@echo "*** Created midi data in '[0;31mmidi[0;32m' directory."
@echo "[0m"
##############################
#
# make midi-norep -- Create midi files for music, taking only second
# endings (performance sequence with minimal repeats).
#
norep: midi-norep
midinorep: midi-norep
midi-norep: humdrum-extras-check
mkdir -p midi-norep
for file in kern/*.krn; \
do \
TBASE=`basename $$file .krn`; \
echo Creating midi/$$TBASE.mid; \
thrux -v norep $$file | hum2mid -o midi-norep/$$TBASE.mid; \
done
@echo "[0;32m"
@echo "*** Created midi data in '[0;31mmidi-norep[0;32m' directory."
@echo "[0m"
##############################
#
# make notearray -- Create notearray files (useful for processing data
# in matlab). Output is stored in a directory called "notearray".
#
notearray: humdrum-extras-check
mkdir -p notearray
for file in kern/*.krn; \
do \
TBASE=`basename $$file .krn`; \
echo Creating notearray/$$TBASE.dat; \
notearray -jicale --mel $$file \
> notearray/$$TBASE.dat; \
done
@echo "[0;32m"
@echo "*** Created notearray data in '[0;31mnotearray[0;32m' directory."
@echo "[0m"
##############################
#
# make abc -- Create ABC+ files (useful for printing with abcm2ps).
# Output is stored in a directory called "abc".
#
abc: humdrum-extras-check
mkdir -p abc
for file in kern/*.krn; \
do \
TBASE=`basename $$file .krn`; \
echo Creating abc/$$TBASE.abc; \
hum2abc $$file > abc/$$TBASE.abc; \
done
@echo "[0;32m"
@echo "*** Created abc data in '[0;31mabc[0;32m' directory."
@echo "[0m"
##############################
#
# make pdf-abc -- Create PDF files with abcm2ps.
# Output is stored in a directory called "pdf-abc".
#
pdf-abc: abcm2ps-check ps2pdf-check humdrum-extras-check
mkdir -p pdf-abc
for file in kern/*.krn; \
do \
TBASE=`basename $$file .krn`; \
echo Creating pdf-abc/$$TBASE.pdf; \
hum2abc $$file | \
abcm2ps - -O - | \
ps2pdf -sPAPERSIZE=letter - > pdf-abc/$$TBASE.pdf; \
done
@echo "[0;32m"
@echo "*** Created PDF data in '[0;31mpdf-abc[0;32m' directory."
@echo "[0m"
##############################
#
# make musedata -- Create musedata files (useful for printing with muse2ps).
# Output is stored in a directory called "musedata".
#
musedata: humextra-check
mkdir -p musedata
for file in kern/*.krn; \
do \
TBASE=`basename $$file .krn`; \
echo Creating musedata/$$TBASE.msd; \
autostem $$file | hum2muse \
> musedata/`basename $$file .krn`.msd; \
done
@echo "[0;32m"
@echo "*** Created musedata data in '[0;31mmusedata[0;32m' directory."
@echo "[0m"
##############################
#
# make pdf-musedata -- Create PDF files of graphical notation using muse2ps:
# http://muse2ps.ccarh.org
# https://github.com/musedata/muse2ps
# Output is stored in a directory called "pdf-musedata".
#
# To print with this method, you need to install muse2ps from the above
# website, as well as the GhostScript package. In linux, the ps2pdf
# program can be installed with "yum install ghostscript", or
# "apt-get install ghostscript". In OS X if you have installed homebrew:
# "brew install ghostscript", or "port install ghostscript" if you are
# using MacPorts.
#
pdf-musedata: ps2pdf-check muse2ps-check humdrum-extras-check
mkdir -p pdf-musedata
for file in kern/*.krn; \
do \
TBASE=`basename $$file .krn`; \
echo Creating pdf-musedata/$$TBASE.pdf; \
autostem $$file | hum2muse | muse2ps =z16j \
| ps2pdf -sPAPERSIZE=letter - \
> pdf-musedata/$$TBASE.pdf; \
done
@echo "[0;32m"
@echo "*** Created PDF files in '[0;31mpdf-musedata[0;32m' directory."
@echo "[0m"
##############################
#
# make mei -- Create MEI files (useful for printing with verovio).
# Output is stored in a directory called "mei".
#
MEI: mei
mei: humdrum-extras-check
mkdir -p mei
for file in kern/*.krn; \
do \
TBASE=`basename $$file .krn`; \
echo Creating mei/$$TBASE.mei; \
autostem $$file | hum2mei > mei/$$TBASE.mei; \
done
@echo "[0;32m"
@echo "*** Created MEI data in '[0;31mmei[0;32m' directory."
@echo "[0m"
##############################
#
# make musicxml -- Create MusicXML files, which are useful for processing with
# various programs/systems. Output is stored in a directory called "musicxml".
#
musicxml: humdrum-extras-check
mkdir -p musicxml
for file in kern/*.krn; \
do \
TBASE=`basename $$file .krn`; \
echo Creating musicxml/$$TBASE.xml; \
autostem $$file | hum2xml > musicxml/$$TBASE.xml; \
done
@echo "[0;32m"
@echo "*** Created MusicXML data in '[0;31mmusicxml[0;32m' directory."
@echo "[0m"
##############################
#
# make lilypond -- Create lilypond files.
# Output is stored in a directory called "lilypond".
#
lilypond: humdrum-extras-check
mkdir -p lilypond
for file in kern/*.krn; \
do \
TBASE=`basename $$file .krn`; \
echo Creating lilypond/$$TBASE.ly; \
autostem $$file | hum2xml | musicxml2ly - -o- \
> lilypond/$$TBASE.ly; \
done
@echo "[0;32m"
@echo "*** Created lilypond data in '[0;31mlilypond[0;32m' directory."
@echo "[0m"
##############################
#
# make pdf-lilypond -- Create lilypond files.
# Output is stored in a directory called "lilypond".
#
pdf-lilypond: humdrum-extras-check lilypond-check
mkdir -p pdf-lilypond
for file in kern/*.krn; \
do \
TBASE=`basename $$file .krn`; \
echo Creating pdf-lilypond/%%TBASE.pdf; \
autostem $$file | hum2xml | musicxml2ly - -o- \
| lilypond -f pdf -o pdf-lilypond/$$TBASE - ; \
done
@echo "[0;32m"
@echo "*** Created PDF data in '[0;31mpdf-lilypond[0;32m' directory."
@echo "[0m"
##############################
#
# make searchindex -- Create a themax search index file. The searchindex.dat
# file can be used with the themax program to search for melodic/rhythmic
# patterns in the data, such as searching for two successive rising
# perfect fourths:
#
# Counting the number of occurrences within the data (all voices):
# themax -I "+P4 +P4" searchindex.dat --total
#
# Count the number of matches by each voice separately:
# grep ::1 searchindex.dat | themax -I "+P4 +P4" --count
# (finds 53 matches in the bass part)
# grep ::2 searchindex.dat | themax -I "+P4 +P4" --count
# (finds 9 matches in the tenor part)
# grep ::3 searchindex.dat | themax -I "+P4 +P4" --count
# (finds 0 matches in the alto part)
# grep ::4 searchindex.dat | themax -I "+P4 +P4" --count
# (finds 2 matches in the soprano part)
#
# Counting the number of matches in a file:
# themax -I "+P4 +P4" searchindex.dat --count
#
# Showing the note-number location of the matches:
# themax -I "+P4 +P4" searchindex.dat --loc
#
# Resolve note-number locations to measure/beat locations:
# themax -I "+P4 +P4" searchindex.dat --loc | theloc
#
# Extract measures which contain the matches in a particular work:
# tindex kern/sonata01-1.krn | themax -I "+P4 +P4" --loc | theloc --mark | myank --marks
#
#
search: searchindex
search-index: searchindex
searchindex: humdrum-extras-check
tindex kern/*.krn > searchindex.dat
@echo "[0;32m"
@echo "*** Try the command:"
@echo "*** [0;31mthemax -P \"e- d f e- d c\" searchindex.dat --loc | theloc[0;32m"
@echo "*** To search for a melodic fragment from the start of sonata no. 4."
@echo "*** The result should be:"
@echo "*** [0;31mkern/sonata04-1.krn::1 41=14B7-46=15B5.5[0;32m"
@echo "*** [0;31mkern/sonata04-1.krn::2 12=6B1-17=6B8.5 866=194B1-871=194B8.5[0;32m"
@echo "*** [0;31mkern/sonata04-3.krn::2 65=20B3.5-70=21B3[0;32m"
@echo "*** [0;31mkern/sonata05-3.krn::2 19=3B2-24=3B4.5 423=60B2-428=60B4.5[0;32m"
@echo "*** [0;31mkern/sonata08-1.krn::2 87=9B1.625-92=9B1.9375[0;32m"
@echo "*** [0;31mkern/sonata08-3.krn::2 172=35B2.66667-177=36B1.5 313=57B2.66667-318=58B2.83333[0;32m"
@echo "*** [0;31mkern/sonata11-2.krn::1 326=43B7.75-331=43B11.5[0;32m"
@echo "*** [0;31mkern/sonata11-2.krn::2 173=44B8.5-178=44B12.25[0;32m"
@echo "*** [0;31mkern/sonata19-1.krn::2 110=25B2.25-115=26B1.5 223=45B2.25-228=46B2.75 420=88B2.75-425=89B2.5[0;32m"
@echo "*** [0;31mkern/sonata31-3.krn::2 371=154B5.5-376=155B2.5[0;32m"
@echo "***"
@echo "*** The string [0;32m41=14B7-46=15B5.5[0;32m in the first match line means that"
@echo "*** the match starts at note 32 of the part at measure 17, beat 7"
@echo "*** and goes to note 46 in measure 15, beat 5.5 (should make compound meter beats)."
@echo "[0m"
############################################################################
##
## standard Humdrum Toolkit related make commands:
##
##############################
#
# make census -- Count notes in all score for all composers.
#
census: humdrum-toolkit-check
census -k kern/*.krn
############################################################################
##
## Check to see if various software packages are installed.
##
##############################
##
## make git-check -- Check to see if the git program is available.
## If not, then make suggestions for how to install.
##
git-check:
ifeq ($(shell which git),)
@echo "[0;31m"
@echo "*** Error: You must first install the git program."
@echo "*** In Linux, try:"
@echo "*** [0;32sudo yum install git0;31m"
@echo "*** or"
@echo "*** [0;32sudo apt-get install git0;31m"
@echo "*** In OS X, install Homebrew ([0;31mhttps://brew.sh[0;31m) and then type:"
@echo "*** [0;32brew install git0;31m"
@echo "[0m"
exit 1
endif
##############################
##
## make git-repository-check -- Check to see if the directory is part of
## a git repository.
##
git-repository-check:
ifeq ($(wildcard .git),)
@echo "[0;31m"
@echo "*** Error: To automatically update, you need to have installed"
@echo "*** this directory with the git command:"
@echo "*** [0;32mgit clone https://github.com/craigsapp/scarlatti-keyboard-sonatas[0;31m"
@echo "[0m"
exit 1
endif
##############################
##
## make ps2pdf-check -- Check to see if the ps2pdf program, which is a script
## in the GhostScript software package, is available. If not, then make
## suggestions for how to install.
##
ps2pdf-check:
ifeq ($(shell which ps2pdf),)
@echo "[0;31m"
@echo "*** Error: You must first install ps2pdf from the GhostScript package".
@echo "*** In Linux, try:"
@echo "*** [0;32sudo yum install ghostscript0;31m"
@echo "*** or"
@echo "*** [0;32sudo apt-get install ghostscript0;31m"
@echo "*** In OS X, install Homebrew ([0;31mhttps://brew.sh[0;31m) and then type:"
@echo "*** [0;32brew install ghostscript0;31m"
@echo "[0m"
exit 1
endif
##############################
##
## make abcm2ps-check -- Check to see if the abcm2ps program is available.
## If not, then make suggestions for how to install.
##
abcm2ps-check:
ifeq ($(shell which abcm2ps),)
@echo "[0;31m"
@echo "*** Error: You must first install abcm2ps from:"
@echo "*** [0;32mhttp://moinejf.free.fr[0;31m"
@echo "[0m"
exit 1
endif
##############################
##
## make muse2ps-check -- Check to see if the muse2ps program is available.
## If not, then make suggestions for how to install.
##
muse2ps-check:
ifeq ($(shell which muse2ps),)
@echo "[0;31m"
@echo "*** Error: You must first install muse2ps from:"
@echo "*** [0;32mhttp://muse2ps.ccarh.org[0;31m"
@echo "[0m"
exit 1
endif
##############################
##
## make lilypond-check -- Check to see if the lilypond program is available.
## If not, then make suggestions for how to install.
##
lilypond-check:
ifeq ($(shell which lilypond),)
@echo "[0;31m"
@echo "*** Error: You must first install lilypond."
@echo "*** In Linux, try:"
@echo "*** [0;32sudo yum install lilypond0;31m"
@echo "*** or"
@echo "*** [0;32sudo apt-get install lilypond0;31m"
@echo "*** In OS X, install Homebrew ([0;31mhttps://brew.sh[0;31m) and then type:"
@echo "*** [0;32brew install lilypond0;31m"
@echo "[0m"
exit 1
endif
##############################
##
## make humdrum-toolkit-check -- Check to see if the Humdrum Toolkit package
## is available. If not, then make suggestions for how to install.
##
humdrum-toolkit-check:
ifeq ($(shell which humdrum),)
@echo "[0;31m"
@echo "*** Error: You must first install the Humdrum Toolkit. See:"
@echo "*** [0;32mhttps://github.com/humdrum-tools/humdrum-tools[0;31m"
@echo "[0m"
exit 1
endif
##############################
##
## make humdrum-extras-check -- Check to see if the Humdrum Extras package
## is available. If not, then make suggestions for how to install.
##
humextra-check: humdrum-extras-check
humdrumextra-check: humdrum-extras-check
humdrum-extra-check: humdrum-extras-check
humdrum-extras-check:
ifeq ($(shell which keycor),)
@echo "[0;31m"
@echo "*** Error: You must first install the Humdrum Extras. See:"
@echo "*** [0;32mhttps://github.com/humdrum-tools/humdrum-tools[0;31m"
@echo "[0m"
exit 1
endif