view makeBookeTunePages.sh @ 356:6d4b2dab5fcc build-default-158

Corrections from Mick. 1. Add missing two last notes in final bar of B tune. 2. Move 'no chord' marker to start of 2nd repeat in A tune. 3. Mark middle B in last line of Horse's Brawl as Bb. 4. Last note of 4th bar of King of the Fairies should be quaver. 5. 4th bar of B tune should be same as 4th bar of A tune in Plane Tree. 6. Railway has change to Fiery Clock Face.
author Jim Hague <jim.hague@acm.org>
date Mon, 19 Aug 2013 10:09:02 +0100
parents 27f29e8aafea
children b44fbcaeba38
line wrap: on
line source

#!/bin/bash
#
# Generate the LaTeX for the Booke tune pages (tunes.tex) and the index
# of first lines (firstlines.tex). These are generated into the build
# directory.
#
# All EPS and PDF tune graphics must be present already. Run
# makeGraphics.sh to make these.
#

# Restore titles like 'Exploding Potato, The' to the
# expected 'The Exploding Potato'.
fixtitle()
{
    retval=`echo "$1" | sed -e "s/\(.*\), *\(.*\)/\2 \1/"`
}

if [ $# != 1 ]; then
    echo "Usage: makeBookeTunePages.sh <book dir name>"
    exit 1
fi

dir=`pwd`

booke=$dir/$1
builddir=$dir/build
graphicsdir=$dir/graphics/$1
tunesoutput=$builddir/tunes.tex
indexoutput=$builddir/firstlines.tex

mkdir -p $builddir

rm -f $tunesoutput $indexoutput

# Now, for each tune, make the tune graphic and add it, inside a
# centre section, so the document. Then add a TOC entry.
find $booke -name "*.abc" | sort |
    while read filename
    do
        name=`basename $filename .abc`
        title=`$dir/abcfield.py --field T --latex $filename`
        fixtitle "$title"
        title=$retval
        subtitle=`$dir/abcfield.py --index 2 --field T --latex $filename`
        composer=`$dir/abcfield.py --field C --latex $filename`

        changefile=`$dir/abcfield.py --field N --contains "Change:" $filename | sed -e "s/Change: *//"`
        changename=""
        changetitle=""
        if [ -n "$changefile" ]; then
            changename=`basename $changefile .abc`
            changetitle=`$dir/abcfield.py --field T --latex $booke/$changefile`
            fixtitle "$changetitle"
            changetitle=$retval
        fi

        credit=`$dir/abcfield.py --field N --contains "Credit:" $filename | sed -e "s/Credit: *//"`
        echo -E "\showtune{$name}{$title}{$subtitle}{$composer}{$graphicsdir/$name}{$changename}{$changetitle}{$credit}" >> $tunesoutput

        echo -E "\showfirstline{$name}{$title}{$graphicsdir/firstline-$name}" >> $indexoutput
    done