# HG changeset patch # User Jim Hague # Date 1376351503 -3600 # Node ID 1073829494e390944d8cb6e6887bd15810cb50a8 # Parent b8ea9cfb3546a4d59f210d700ac5a48ea2e29f84 Try to be cleverer when transposing for cello. Jane says: Am most comfortable between the bottom G (the bottom line of the bass clef) and top D (the note above middle C), but can play from bottom C upwards (the C string is a bit growly) and at a push can get as high as the A above middle C. Implement the following rule: 1. If range is G to d', transpose down 2 octaves. 2. If lowest note is < C, transpose down 1 octave. 3. Otherwise calculate the distance above d for the highest note on a one octave transposition, and the distance below G on a two octave transposition. Find the smallest, and use the corresponding transposition. diff -r b8ea9cfb3546 -r 1073829494e3 makeCello.sh --- a/makeCello.sh Tue Aug 13 00:50:02 2013 +0100 +++ b/makeCello.sh Tue Aug 13 00:51:43 2013 +0100 @@ -13,10 +13,30 @@ exit 1 fi -# Transpose down (return 0) if bottom note was < C. +# Return 0 if we should transpose down 2 octaves, 1 if just one +# octave. $2 is highest note, $3 is lowest note. +# +# If range is G to d', transpose down 2 octaves. +# If lowest note is < C, transpose down 1 octave. +# Otherwise calculate the distance above d for the highest note on a one +# octave transposition, and the distance below G on a two octave +# transposition. Find the smallest, and use the corresponding +# transposition. transposedowntwo() { - return $(($3 >= 100)) + if (($3 >= 104 && $2 <= 115)); then + return 0; + fi + if (($3 < 100)); then + return 1; + fi + over=$(($2 - 108)) + under=$((104 - $3)) + if (($over <= $under)); then + return 1; + fi + + return 0; } dir=`pwd` @@ -38,11 +58,10 @@ range=`./abcrange.py $filename` # Move down either one octave or two, depending on the range - # of the tune. If there are any notes below middle C, transpose - # down one octave. The default is to transpose down two octaves. - middle="d" + # of the tune. + middle="D" if transposedowntwo $range; then - middle="D" + middle="d" fi sed -e "/^ *K:/s/$/ clef=bass middle=$middle/" $filename > $outdir/$name.abc