annotate makeCello.sh @ 748:ce5c7214f9aa

Introduce mechanism for having different tune images for compact printed output. Sort alternate .abc in subdir 'Compact' under the booke dir. Use that as the graphic for A5 output, assuming it will be vertically more compact. Use Bear Dance as an example, as it has commentary that currently overflows an A5 landscape page. For the moment, transposed Bookes don't transpose and so don't use Compact.
author Jim Hague <jim.hague@acm.org>
date Fri, 13 Oct 2017 15:44:15 +0100
parents cf2fe741a582
children 06fec6764661
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
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
49 mkdir -p $outdir
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.
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 188
diff changeset
52 cp $booke/*.txt $outdir
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
748
ce5c7214f9aa Introduce mechanism for having different tune images for compact printed output.
Jim Hague <jim.hague@acm.org>
parents: 537
diff changeset
56 find $booke -depth 1 -name "*.abc" | sort |
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`
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
60 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
61
188
76f18e0a80bd Have a go at being slightly more intelligent in the cello transposition.
Jim Hague <jim.hague@acm.org>
parents: 155
diff changeset
62 # 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
63 # of the tune.
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
64 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
65 if transposedowntwo $range; then
349
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
66 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
67 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
68
215
3c9d9654d4a1 Add 'clef=bass' into the converted output.
Jim Hague <jim.hague@laicatc.com>
parents: 197
diff changeset
69 sed -e "/^ *K:/s/$/ clef=bass middle=$middle/" $filename > $outdir/$name.abc
155
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
70 done