a5b76de484
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.
71 lines
1.7 KiB
Bash
Executable File
71 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copy a booke to cello-friendly form. Bass clef, transposed down
|
|
# 1 or 2 octaves.
|
|
#
|
|
# It would be easier to do with transpose in dottes.fmt, but I can't get
|
|
# that to work properly for a 2 octave downward transpose.
|
|
#
|
|
# This relies on abcm2ps >= 6.0 but does not check for it.
|
|
|
|
if [ $# != 1 ]; then
|
|
echo "Usage: makeCello.sh <book dir name>"
|
|
exit 1
|
|
fi
|
|
|
|
# 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.
|
|
# Otherwise calculate the distance above d for the highest note on a one
|
|
# octave transposition, and the distance below C on a two octave
|
|
# transposition. Find the smallest, and use the corresponding
|
|
# transposition, preferring 2 octaves in case of a tie.
|
|
transposedowntwo()
|
|
{
|
|
if (($3 >= 104 && $2 <= 115)); then
|
|
return 0;
|
|
fi
|
|
over=$(($2 - 108))
|
|
if (($over < 0)); then
|
|
over=0
|
|
fi
|
|
under=$((100 - $3))
|
|
if (($under < 0)); then
|
|
under=0
|
|
fi
|
|
if (($over < $under)); then
|
|
return 1;
|
|
fi
|
|
|
|
return 0;
|
|
}
|
|
|
|
dir=`pwd`
|
|
|
|
booke=$dir/$1
|
|
outdir=$dir/$1-Cello
|
|
|
|
mkdir -p $outdir
|
|
|
|
# Copy book component items.
|
|
cp $booke/*.txt $outdir
|
|
|
|
echo "Cello" > $outdir/instrument.txt
|
|
|
|
find $booke -depth 1 -name "*.abc" | sort |
|
|
while read filename
|
|
do
|
|
name=`basename $filename .abc`
|
|
range=`./abcrange.py $filename`
|
|
|
|
# Move down either one octave or two, depending on the range
|
|
# of the tune.
|
|
middle="D"
|
|
if transposedowntwo $range; then
|
|
middle="d"
|
|
fi
|
|
|
|
sed -e "/^ *K:/s/$/ clef=bass middle=$middle/" $filename > $outdir/$name.abc
|
|
done
|