Mercurial > dottes
annotate makeCello.sh @ 336:72a63db1cc43
Automated merge with ssh://hg.cryhavoc.org.uk/dottes
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Mon, 12 Aug 2013 11:53:32 +0100 |
parents | b4a0161e8870 |
children | 1073829494e3 |
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 |
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
|
16 # Transpose down (return 0) if bottom note was < C. |
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
|
17 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
|
18 { |
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
|
19 return $(($3 >= 100)) |
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
|
20 } |
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
|
21 |
155
cc2d4925f280
Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
22 dir=`pwd` |
cc2d4925f280
Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
23 |
cc2d4925f280
Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
24 booke=$dir/$1 |
cc2d4925f280
Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
25 outdir=$dir/$1-Cello |
cc2d4925f280
Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
26 |
cc2d4925f280
Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
27 mkdir -p $outdir |
cc2d4925f280
Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
28 |
197
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
188
diff
changeset
|
29 # Copy book component items. |
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
188
diff
changeset
|
30 cp $booke/*.txt $outdir |
8f352063f277
Finish first version of newly tarted up website.
Jim Hague <jim.hague@acm.org>
parents:
188
diff
changeset
|
31 |
263
7b98278d6e8b
Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents:
215
diff
changeset
|
32 echo "Cello" > $outdir/instrument.txt |
7b98278d6e8b
Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents:
215
diff
changeset
|
33 |
155
cc2d4925f280
Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
34 find $booke -name "*.abc" | sort | |
cc2d4925f280
Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
35 while read filename |
cc2d4925f280
Produce a cello-friendly Booke.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
36 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
|
37 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
|
38 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
|
39 |
188
76f18e0a80bd
Have a go at being slightly more intelligent in the cello transposition.
Jim Hague <jim.hague@acm.org>
parents:
155
diff
changeset
|
40 # Move down either one octave or two, depending on the range |
76f18e0a80bd
Have a go at being slightly more intelligent in the cello transposition.
Jim Hague <jim.hague@acm.org>
parents:
155
diff
changeset
|
41 # of the tune. If there are any notes below middle C, transpose |
76f18e0a80bd
Have a go at being slightly more intelligent in the cello transposition.
Jim Hague <jim.hague@acm.org>
parents:
155
diff
changeset
|
42 # down one octave. The default is to transpose down two octaves. |
76f18e0a80bd
Have a go at being slightly more intelligent in the cello transposition.
Jim Hague <jim.hague@acm.org>
parents:
155
diff
changeset
|
43 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
|
44 if transposedowntwo $range; then |
188
76f18e0a80bd
Have a go at being slightly more intelligent in the cello transposition.
Jim Hague <jim.hague@acm.org>
parents:
155
diff
changeset
|
45 middle="D" |
76f18e0a80bd
Have a go at being slightly more intelligent in the cello transposition.
Jim Hague <jim.hague@acm.org>
parents:
155
diff
changeset
|
46 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
|
47 |
215
3c9d9654d4a1
Add 'clef=bass' into the converted output.
Jim Hague <jim.hague@laicatc.com>
parents:
197
diff
changeset
|
48 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
|
49 done |