comparison makeHornInF.sh @ 322:b4a0161e8870

Add abcrange.py to return the range of a tune, and use it in instrument transposition. This lets us transpose on boundaries that aren't octave boundaries.
author Jim Hague <jim.hague@acm.org>
date Thu, 18 Jul 2013 15:27:57 +0100
parents 7b98278d6e8b
children b8ea9cfb3546
comparison
equal deleted inserted replaced
321:b61c39beac5f 322:b4a0161e8870
4 4
5 if [ $# != 1 ]; then 5 if [ $# != 1 ]; then
6 echo "Usage: makeFHorn.sh <book dir name>" 6 echo "Usage: makeFHorn.sh <book dir name>"
7 exit 1 7 exit 1
8 fi 8 fi
9
10 # Transpose down (return 0) if top note was > e (> a for horn).
11 transposedown()
12 {
13 return $(($2 <= 109))
14 }
9 15
10 dir=`pwd` 16 dir=`pwd`
11 17
12 booke=$dir/$1 18 booke=$dir/$1
13 outdir=$dir/$1-HornInF 19 outdir=$dir/$1-HornInF
21 27
22 find $booke -name "*.abc" | sort | 28 find $booke -name "*.abc" | sort |
23 while read filename 29 while read filename
24 do 30 do
25 name=`basename $filename .abc` 31 name=`basename $filename .abc`
26 tmpfile=$outdir/$name.abc.tmp 32 range=`./abcrange.py $filename`
27
28 # Strip out guitar chords first. This has the advantage of removing
29 # text with arbitary lower case characters too.
30 sed -e "s/\"[^\"]*\"//g" $filename > $tmpfile
31 33
32 # Transpose concert pitch up a fifth. 34 # Transpose concert pitch up a fifth.
33 # If there are any notes at or above C above middle C, transpose 35 # If there are any notes above 'd' (Horn 'g'), transpose
34 # down a seventh instead. 36 # down a seventh instead.
35 transpose=5 37 transpose=5
36 if grep -v "^[A-Z]:" $tmpfile | sed -e 's/"[^"]*"//g' | grep -q "[a-g]"; then 38 if transposedown $range; then
37 transpose=-7 39 transpose=-7
38 fi 40 fi
39 41
40 # Transpose. By default abc2abc will report errors in the output, 42 # Transpose. By default abc2abc will report errors in the output,
41 # but this messes up output formatting so stop it. Also force all 43 # but this messes up output formatting so stop it. Also force all
42 # output to be in treble clef; some lower tunes with the odd high 44 # output to be in treble clef; some lower tunes with the odd high
43 # note will otherwise appear in bass clef, which is not what this 45 # note will otherwise appear in bass clef, which is not what this
44 # crap horn player wants. 46 # crap horn player wants.
45 abc2abc $tmpfile -e -t $transpose | \ 47 abc2abc $filename -e -t $transpose | \
46 sed -e "/^ *K:/s/$/ clef=treble/" > $outdir/$name.abc 48 sed -e "/^ *K:/s/$/ clef=treble/" > $outdir/$name.abc
47 rm $tmpfile
48 done 49 done