2012-06-05 19:34:54 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2013-07-18 15:27:57 +01:00
|
|
|
# Copy a booke to cello-friendly form. Bass clef, transposed down
|
|
|
|
# 1 or 2 octaves.
|
2012-06-05 19:34:54 +01:00
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
2013-08-13 00:51:43 +01:00
|
|
|
# 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
|
2015-12-13 22:47:24 +00:00
|
|
|
# octave transposition, and the distance below C on a two octave
|
2013-08-13 00:51:43 +01:00
|
|
|
# transposition. Find the smallest, and use the corresponding
|
2015-12-13 22:47:24 +00:00
|
|
|
# transposition, preferring 2 octaves in case of a tie.
|
2013-07-18 15:27:57 +01:00
|
|
|
transposedowntwo()
|
|
|
|
{
|
2013-08-13 00:51:43 +01:00
|
|
|
if (($3 >= 104 && $2 <= 115)); then
|
|
|
|
return 0;
|
|
|
|
fi
|
|
|
|
over=$(($2 - 108))
|
2015-12-13 22:47:24 +00:00
|
|
|
if (($over < 0)); then
|
|
|
|
over=0
|
|
|
|
fi
|
|
|
|
under=$((100 - $3))
|
|
|
|
if (($under < 0)); then
|
|
|
|
under=0
|
|
|
|
fi
|
|
|
|
if (($over < $under)); then
|
2013-08-13 00:51:43 +01:00
|
|
|
return 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0;
|
2013-07-18 15:27:57 +01:00
|
|
|
}
|
|
|
|
|
2012-06-05 19:34:54 +01:00
|
|
|
dir=`pwd`
|
|
|
|
|
|
|
|
booke=$dir/$1
|
|
|
|
outdir=$dir/$1-Cello
|
|
|
|
|
|
|
|
mkdir -p $outdir
|
|
|
|
|
2013-02-17 00:27:07 +00:00
|
|
|
# Copy book component items.
|
|
|
|
cp $booke/*.txt $outdir
|
|
|
|
|
2013-06-21 20:00:54 +01:00
|
|
|
echo "Cello" > $outdir/instrument.txt
|
|
|
|
|
2017-10-13 15:44:15 +01:00
|
|
|
find $booke -depth 1 -name "*.abc" | sort |
|
2012-06-05 19:34:54 +01:00
|
|
|
while read filename
|
|
|
|
do
|
2013-07-18 15:27:57 +01:00
|
|
|
name=`basename $filename .abc`
|
|
|
|
range=`./abcrange.py $filename`
|
|
|
|
|
2013-02-04 13:50:20 +00:00
|
|
|
# Move down either one octave or two, depending on the range
|
2013-08-13 00:51:43 +01:00
|
|
|
# of the tune.
|
|
|
|
middle="D"
|
2013-07-18 15:27:57 +01:00
|
|
|
if transposedowntwo $range; then
|
2013-08-13 00:51:43 +01:00
|
|
|
middle="d"
|
2013-02-04 13:50:20 +00:00
|
|
|
fi
|
2013-07-18 15:27:57 +01:00
|
|
|
|
2013-02-20 12:48:02 +00:00
|
|
|
sed -e "/^ *K:/s/$/ clef=bass middle=$middle/" $filename > $outdir/$name.abc
|
2012-06-05 19:34:54 +01:00
|
|
|
done
|