annotate makeHornInF.sh @ 313:aa803fd1c3a6

Use a abcm2pc format file to format the single lines.
author Jim Hague <jim.hague@acm.org>
date Fri, 12 Jul 2013 14:25:05 +0100
parents 7b98278d6e8b
children b4a0161e8870
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
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
10 dir=`pwd`
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
11
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
12 booke=$dir/$1
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
13 outdir=$dir/$1-HornInF
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
14
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
15 mkdir -p $outdir
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
16
217
a8a46fd79d5c Fix up problems in Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents: 216
diff changeset
17 # Copy book component items.
a8a46fd79d5c Fix up problems in Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents: 216
diff changeset
18 cp $booke/*.txt $outdir
a8a46fd79d5c Fix up problems in Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents: 216
diff changeset
19
263
7b98278d6e8b Add instrument name into title page for transpositions.
Jim Hague <jim.hague@acm.org>
parents: 218
diff changeset
20 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
21
216
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
22 find $booke -name "*.abc" | sort |
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
23 while read filename
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
24 do
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
25 name=`basename $filename .abc`
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
26 tmpfile=$outdir/$name.abc.tmp
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
27
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
28 # Strip out guitar chords first. This has the advantage of removing
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
29 # text with arbitary lower case characters too.
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
30 sed -e "s/\"[^\"]*\"//g" $filename > $tmpfile
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
31
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
32 # Transpose concert pitch up a fifth.
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
33 # If there are any notes at or above C above middle C, transpose
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
34 # down a seventh instead.
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
35 transpose=5
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
36 if grep -v "^[A-Z]:" $tmpfile | sed -e 's/"[^"]*"//g' | grep -q "[a-g]"; then
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
37 transpose=-7
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
38 fi
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
39
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
40 # 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
41 # 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
42 # 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
43 # 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
44 # crap horn player wants.
1a9d937b7765 Force Horn in F output to be in treble clef.
Jim Hague <jim.hague@laicatc.com>
parents: 217
diff changeset
45 abc2abc $tmpfile -e -t $transpose | \
1a9d937b7765 Force Horn in F output to be in treble clef.
Jim Hague <jim.hague@laicatc.com>
parents: 217
diff changeset
46 sed -e "/^ *K:/s/$/ clef=treble/" > $outdir/$name.abc
216
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
47 rm $tmpfile
64b84dea3337 Add Horn in F transposition.
Jim Hague <jim.hague@laicatc.com>
parents:
diff changeset
48 done