annotate makeCello.sh @ 1047:4cfee227da93 build-default-378

Fix notation error.
author Jim Hague <jim.hague@acm.org>
date Sun, 12 Apr 2020 14:43:22 +0100
parents 18f0e45207ef
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
155
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
1 #!/bin/bash
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
2 #
322
b4a0161e8870 Add abcrange.py to return the range of a tune, and use it in instrument transposition.
Jim Hague <jim.hague@acm.org>
parents: 263
diff changeset
3 # Copy a booke to cello-friendly form. Bass clef, transposed down
b4a0161e8870 Add abcrange.py to return the range of a tune, and use it in instrument transposition.
Jim Hague <jim.hague@acm.org>
parents: 263
diff changeset
4 # 1 or 2 octaves.
155
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
5 #
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
6 # It would be easier to do with transpose in dottes.fmt, but I can't get
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
7 # that to work properly for a 2 octave downward transpose.
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
8 #
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
9 # This relies on abcm2ps >= 6.0 but does not check for it.
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
10
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
11 if [ $# != 1 ]; then
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
12 echo "Usage: makeCello.sh <book dir name>"
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
13 exit 1
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
14 fi
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
15
349
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
16 # Return 0 if we should transpose down 2 octaves, 1 if just one
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
17 # octave. $2 is highest note, $3 is lowest note.
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
18 #
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
19 # If range is G to d', transpose down 2 octaves.
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
20 # Otherwise calculate the distance above d for the highest note on a one
537
cf2fe741a582 Try Cello transposition algorithm again.
Jim Hague <jim.hague@acm.org>
parents: 349
diff changeset
21 # octave transposition, and the distance below C on a two octave
349
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
22 # transposition. Find the smallest, and use the corresponding
537
cf2fe741a582 Try Cello transposition algorithm again.
Jim Hague <jim.hague@acm.org>
parents: 349
diff changeset
23 # transposition, preferring 2 octaves in case of a tie.
322
b4a0161e8870 Add abcrange.py to return the range of a tune, and use it in instrument transposition.
Jim Hague <jim.hague@acm.org>
parents: 263
diff changeset
24 transposedowntwo()
b4a0161e8870 Add abcrange.py to return the range of a tune, and use it in instrument transposition.
Jim Hague <jim.hague@acm.org>
parents: 263
diff changeset
25 {
349
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
26 if (($3 >= 104 && $2 <= 115)); then
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
27 return 0;
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
28 fi
537
cf2fe741a582 Try Cello transposition algorithm again.
Jim Hague <jim.hague@acm.org>
parents: 349
diff changeset
29 over=$(($2 - 108))
cf2fe741a582 Try Cello transposition algorithm again.
Jim Hague <jim.hague@acm.org>
parents: 349
diff changeset
30 if (($over < 0)); then
cf2fe741a582 Try Cello transposition algorithm again.
Jim Hague <jim.hague@acm.org>
parents: 349
diff changeset
31 over=0
349
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
32 fi
537
cf2fe741a582 Try Cello transposition algorithm again.
Jim Hague <jim.hague@acm.org>
parents: 349
diff changeset
33 under=$((100 - $3))
cf2fe741a582 Try Cello transposition algorithm again.
Jim Hague <jim.hague@acm.org>
parents: 349
diff changeset
34 if (($under < 0)); then
cf2fe741a582 Try Cello transposition algorithm again.
Jim Hague <jim.hague@acm.org>
parents: 349
diff changeset
35 under=0
cf2fe741a582 Try Cello transposition algorithm again.
Jim Hague <jim.hague@acm.org>
parents: 349
diff changeset
36 fi
cf2fe741a582 Try Cello transposition algorithm again.
Jim Hague <jim.hague@acm.org>
parents: 349
diff changeset
37 if (($over < $under)); then
349
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
38 return 1;
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
39 fi
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
40
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
41 return 0;
322
b4a0161e8870 Add abcrange.py to return the range of a tune, and use it in instrument transposition.
Jim Hague <jim.hague@acm.org>
parents: 263
diff changeset
42 }
b4a0161e8870 Add abcrange.py to return the range of a tune, and use it in instrument transposition.
Jim Hague <jim.hague@acm.org>
parents: 263
diff changeset
43
155
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
44 dir=`pwd`
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
45
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
46 booke=$dir/$1
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
47 outdir=$dir/$1-Cello
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
48
749
06fec6764661 Revise transposition scripts to make Compact.
Jim Hague <jim.hague@acm.org>
parents: 748
diff changeset
49 mkdir -p $outdir/Compact
155
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
50
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 188
diff changeset
51 # Copy book component items.
876
1a838d8dca2a Fix building transposed bookes.
Jim Hague <jim.hague@acm.org>
parents: 749
diff changeset
52 cp $booke/*.txt $booke/*.md $booke/image.jpg $outdir
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 188
diff changeset
53
263
7b98278d6e8b Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents: 215
diff changeset
54 echo "Cello" > $outdir/instrument.txt
7b98278d6e8b Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents: 215
diff changeset
55
1031
18f0e45207ef Sort LC_ALL=C to get Linux sort to order Beginners as expected.
Jim Hague <jim.hague@acm.org>
parents: 876
diff changeset
56 find $booke -name "*.abc" |
155
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
57 while read filename
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
58 do
322
b4a0161e8870 Add abcrange.py to return the range of a tune, and use it in instrument transposition.
Jim Hague <jim.hague@acm.org>
parents: 263
diff changeset
59 name=`basename $filename .abc`
749
06fec6764661 Revise transposition scripts to make Compact.
Jim Hague <jim.hague@acm.org>
parents: 748
diff changeset
60
06fec6764661 Revise transposition scripts to make Compact.
Jim Hague <jim.hague@acm.org>
parents: 748
diff changeset
61 dir=`dirname $filename`
06fec6764661 Revise transposition scripts to make Compact.
Jim Hague <jim.hague@acm.org>
parents: 748
diff changeset
62 basedir=`basename $dir`
06fec6764661 Revise transposition scripts to make Compact.
Jim Hague <jim.hague@acm.org>
parents: 748
diff changeset
63 compact=""
06fec6764661 Revise transposition scripts to make Compact.
Jim Hague <jim.hague@acm.org>
parents: 748
diff changeset
64 if [ "$basedir" = "Compact" ]; then
06fec6764661 Revise transposition scripts to make Compact.
Jim Hague <jim.hague@acm.org>
parents: 748
diff changeset
65 compact="Compact/"
06fec6764661 Revise transposition scripts to make Compact.
Jim Hague <jim.hague@acm.org>
parents: 748
diff changeset
66 fi
06fec6764661 Revise transposition scripts to make Compact.
Jim Hague <jim.hague@acm.org>
parents: 748
diff changeset
67
322
b4a0161e8870 Add abcrange.py to return the range of a tune, and use it in instrument transposition.
Jim Hague <jim.hague@acm.org>
parents: 263
diff changeset
68 range=`./abcrange.py $filename`
b4a0161e8870 Add abcrange.py to return the range of a tune, and use it in instrument transposition.
Jim Hague <jim.hague@acm.org>
parents: 263
diff changeset
69
188
76f18e0a80bd Have a go at being slightly more intelligent in the cello transposition.
Jim Hague <jim.hague@acm.org>
parents: 155
diff changeset
70 # Move down either one octave or two, depending on the range
349
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
71 # of the tune.
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
72 middle="D"
322
b4a0161e8870 Add abcrange.py to return the range of a tune, and use it in instrument transposition.
Jim Hague <jim.hague@acm.org>
parents: 263
diff changeset
73 if transposedowntwo $range; then
349
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
74 middle="d"
188
76f18e0a80bd Have a go at being slightly more intelligent in the cello transposition.
Jim Hague <jim.hague@acm.org>
parents: 155
diff changeset
75 fi
322
b4a0161e8870 Add abcrange.py to return the range of a tune, and use it in instrument transposition.
Jim Hague <jim.hague@acm.org>
parents: 263
diff changeset
76
749
06fec6764661 Revise transposition scripts to make Compact.
Jim Hague <jim.hague@acm.org>
parents: 748
diff changeset
77 sed -e "/^ *K:/s/$/ clef=bass middle=$middle/" $filename > $outdir/$compact$name.abc
155
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
78 done