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.
This commit is contained in:
+13
-3
@@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copy a booke to cello-friendly form. Bass clef, transposed down 2 octaves.
|
||||
# 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.
|
||||
@@ -12,6 +13,12 @@ if [ $# != 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Transpose down (return 0) if bottom note was < C.
|
||||
transposedowntwo()
|
||||
{
|
||||
return $(($3 >= 100))
|
||||
}
|
||||
|
||||
dir=`pwd`
|
||||
|
||||
booke=$dir/$1
|
||||
@@ -27,13 +34,16 @@ echo "Cello" > $outdir/instrument.txt
|
||||
find $booke -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. If there are any notes below middle C, transpose
|
||||
# down one octave. The default is to transpose down two octaves.
|
||||
middle="d"
|
||||
if grep -v "^[A-Z]:" $filename | sed -e 's/"[^"]*"//g' | grep -q "[A-Z],"; then
|
||||
if transposedowntwo $range; then
|
||||
middle="D"
|
||||
fi
|
||||
name=`basename $filename .abc`
|
||||
|
||||
sed -e "/^ *K:/s/$/ clef=bass middle=$middle/" $filename > $outdir/$name.abc
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user