annotate makeHornInF.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 ecc62b487e57
children 06fec6764661
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
216
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
1 #!/bin/bash
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
2 #
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
3 # Transpose a book for Horn in F.
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
4
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
5 if [ $# != 1 ]; then
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
6 echo "Usage: makeFHorn.sh <book dir name>"
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
7 exit 1
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
8 fi
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
9
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
10 # Transpose down (return 0) if top note was > e (> a for horn).
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
11 transposedown()
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
12 {
351
6bcafbfac674 Now fix logic error in makeHornInF.sh.
Jim Hague <jim.hague@acm.org>
parents: 350
diff changeset
13 (($2 > 109))
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
14 }
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
15
216
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
16 dir=`pwd`
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
17
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
18 booke=$dir/$1
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
19 outdir=$dir/$1-HornInF
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
20
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
21 mkdir -p $outdir
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
22
217
a8a46fd79d5c Fix up problems in Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents: 216
diff changeset
23 # Copy book component items.
a8a46fd79d5c Fix up problems in Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents: 216
diff changeset
24 cp $booke/*.txt $outdir
a8a46fd79d5c Fix up problems in Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents: 216
diff changeset
25
263
7b98278d6e8b Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents: 218
diff changeset
26 echo "Horn in F" > $outdir/instrument.txt
7b98278d6e8b Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents: 218
diff changeset
27
748
ce5c7214f9aa Introduce mechanism for having different tune images for compact printed output.
Jim Hague <jim.hague@acm.org>
parents: 370
diff changeset
28 find $booke -depth 1 -name "*.abc" | sort |
216
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
29 while read filename
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
30 do
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
31 name=`basename $filename .abc`
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
32 range=`./abcrange.py $filename`
216
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
33
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
34 # Transpose concert pitch up a fifth.
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
35 # If there are any notes above 'd' (Horn 'g'), transpose
216
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
36 # down a seventh instead.
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
37 transpose=5
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
38 if transposedown $range; then
216
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
39 transpose=-7
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
40 fi
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
41
370
ecc62b487e57 Some empty "" chords may be causing trouble with Jenkins.
Jim Hague <jim.hague@acm.org>
parents: 351
diff changeset
42 # There's no point in having transposed chords. Remove from the
ecc62b487e57 Some empty "" chords may be causing trouble with Jenkins.
Jim Hague <jim.hague@acm.org>
parents: 351
diff changeset
43 # abc before transposing. Some badly formed chord items can give
ecc62b487e57 Some empty "" chords may be causing trouble with Jenkins.
Jim Hague <jim.hague@acm.org>
parents: 351
diff changeset
44 # erroneous output from abc2abc (like, strings of binary gibberish).
ecc62b487e57 Some empty "" chords may be causing trouble with Jenkins.
Jim Hague <jim.hague@acm.org>
parents: 351
diff changeset
45 sed -e "s/\"[^\"]*\"//g" $filename > $outdir/$name.abc.tmp
ecc62b487e57 Some empty "" chords may be causing trouble with Jenkins.
Jim Hague <jim.hague@acm.org>
parents: 351
diff changeset
46
216
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
47 # Transpose. By default abc2abc will report errors in the output,
218
1a9d937b7765 Force Horn in F output to be in treble clef.
Jim Hague <jim.hague@laicatc.com>
parents: 217
diff changeset
48 # but this messes up output formatting so stop it. Also force all
1a9d937b7765 Force Horn in F output to be in treble clef.
Jim Hague <jim.hague@laicatc.com>
parents: 217
diff changeset
49 # output to be in treble clef; some lower tunes with the odd high
1a9d937b7765 Force Horn in F output to be in treble clef.
Jim Hague <jim.hague@laicatc.com>
parents: 217
diff changeset
50 # note will otherwise appear in bass clef, which is not what this
1a9d937b7765 Force Horn in F output to be in treble clef.
Jim Hague <jim.hague@laicatc.com>
parents: 217
diff changeset
51 # crap horn player wants.
370
ecc62b487e57 Some empty "" chords may be causing trouble with Jenkins.
Jim Hague <jim.hague@acm.org>
parents: 351
diff changeset
52 abc2abc $outdir/$name.abc.tmp -e -t $transpose | \
218
1a9d937b7765 Force Horn in F output to be in treble clef.
Jim Hague <jim.hague@laicatc.com>
parents: 217
diff changeset
53 sed -e "/^ *K:/s/$/ clef=treble/" > $outdir/$name.abc
370
ecc62b487e57 Some empty "" chords may be causing trouble with Jenkins.
Jim Hague <jim.hague@acm.org>
parents: 351
diff changeset
54 rm $outdir/$name.abc.tmp
216
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
55 done