annotate makeCello.sh @ 385:30a9bef6c3e1

Added tag build-default-171 for changeset 8d574b900e36
author Jenkins Build Manager <jenkins@cryhavoc.org.uk>
date Sat, 31 Aug 2013 00:20:51 +0100
parents 1073829494e3
children cf2fe741a582
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 # If lowest note is < C, transpose down 1 octave.
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
21 # Otherwise calculate the distance above d for the highest note on a one
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
22 # octave transposition, and the distance below G on a two octave
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
23 # transposition. Find the smallest, and use the corresponding
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
24 # transposition.
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
25 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
26 {
349
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
27 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
28 return 0;
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
29 fi
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
30 if (($3 < 100)); then
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
31 return 1;
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
32 fi
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
33 over=$(($2 - 108))
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
34 under=$((104 - $3))
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
35 if (($over <= $under)); then
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
36 return 1;
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
37 fi
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
38
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
39 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
40 }
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
41
155
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
42 dir=`pwd`
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
43
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
44 booke=$dir/$1
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
45 outdir=$dir/$1-Cello
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
46
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
47 mkdir -p $outdir
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
48
197
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 188
diff changeset
49 # Copy book component items.
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 188
diff changeset
50 cp $booke/*.txt $outdir
8f352063f277 Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents: 188
diff changeset
51
263
7b98278d6e8b Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents: 215
diff changeset
52 echo "Cello" > $outdir/instrument.txt
7b98278d6e8b Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents: 215
diff changeset
53
155
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
54 find $booke -name "*.abc" | sort |
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
55 while read filename
cc2d4925f280 Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
56 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
57 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
58 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
59
188
76f18e0a80bd Have a go at being slightly more intelligent in the cello transposition.
Jim Hague <jim.hague@acm.org>
parents: 155
diff changeset
60 # 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
61 # of the tune.
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
62 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
63 if transposedowntwo $range; then
349
1073829494e3 Try to be cleverer when transposing for cello.
Jim Hague <jim.hague@acm.org>
parents: 322
diff changeset
64 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
65 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
66
215
3c9d9654d4a1 Add 'clef=bass' into the converted output.
Jim Hague <jim.hague@laicatc.com>
parents: 197
diff changeset
67 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
68 done