Change web page layout.

Put tune contents under 'tunes/<name>' or 'tunes-<instrument>/<name>'.
That way they won't move if the tune gets moved between Bookes.

For now I have not attempted to redirect old URLs.
This commit is contained in:
Jim Hague 2019-08-05 23:25:28 +01:00
parent e0539cb350
commit aa97e0f688
9 changed files with 135 additions and 119 deletions

View File

@ -1 +1 @@
RedirectMatch permanent "(.*)/MazurkaAvignon\.html$" "$1/MazurkaAuvergne.html" RedirectMatch permanent "(.*)/MazurkaAvignon\.html$" "tunes/MazurkaAuvergne/index.html"

View File

@ -175,7 +175,7 @@ def convertMarkdown(t, latex):
if latex: if latex:
res = re.sub(r'\\href{(.*?).abc}', r'\\hyperlink{\1}', res) res = re.sub(r'\\href{(.*?).abc}', r'\\hyperlink{\1}', res)
else: else:
res = re.sub(r'href="(.*?).abc"', r'href="\1.html"', res) res = re.sub(r'href="(.*?).abc"', r'href="../\1/index.html"', res)
return res.strip() return res.strip()
# Implement a custom Markdown shorthand for referencing ABC files. # Implement a custom Markdown shorthand for referencing ABC files.

View File

@ -4,7 +4,7 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cry Havoc tunes - learning ${title}</title> <title>Cry Havoc tunes - learning ${title}</title>
<link rel="stylesheet" href="../css/dottes.css" /> <link rel="stylesheet" href="../../css/dottes.css" />
<link href='http://fonts.googleapis.com/css?family=Pirata+One|Open+Sans' <link href='http://fonts.googleapis.com/css?family=Pirata+One|Open+Sans'
rel='stylesheet' type='text/css'> rel='stylesheet' type='text/css'>
@ -13,13 +13,13 @@
<div class="container"> <div class="container">
<a href="/"> <a href="/">
<div class="header-strip banner"> <div class="header-strip banner">
<img src="../img/banner.png" alt="Havoc banner image"> <img src="../../img/banner.png" alt="Havoc banner image">
</div> </div>
</a> </a>
<div class="dottes-body"> <div class="dottes-body">
<div class="dottes-tune-display"> <div class="dottes-tune-display">
<img src="../img/learner.png" alt="Learner tune image"> <img src="../../img/learner.png" alt="Learner tune image">
Work out the melody or play along Work out the melody or play along
with these audio players. They play the melody repeatedly. There's with these audio players. They play the melody repeatedly. There's
a variety of speeds to choose from. You can also download the a variety of speeds to choose from. You can also download the
@ -59,18 +59,18 @@
</div> </div>
<div class="dottes-tune-learner-play"> <div class="dottes-tune-learner-play">
<audio controls loop> <audio controls loop>
<source src="../${masterbooke}/normal-${name}.mp3" type="audio/mpeg" /> <source src="../../${mastertunedir}/${name}/normal-${name}.mp3" type="audio/mpeg" />
<source src="../${masterbooke}/normal-${name}.ogg" type="audio/ogg" /> <source src="../../${mastertunedir}/${name}/normal-${name}.ogg" type="audio/ogg" />
</audio> </audio>
</div> </div>
<div class="dottes-tune-learner-download"> <div class="dottes-tune-learner-download">
<ul class="tune-data-list"> <ul class="tune-data-list">
<li><a class="dottes-link-tune dottes-midi" download <li><a class="dottes-link-tune dottes-midi" download
href="../${masterbooke}/${name}.mid">MIDI</a></li> href="../../${mastertunedir}/${name}/${name}.mid">MIDI</a></li>
<li><a class="dottes-link-tune dottes-mp3" download <li><a class="dottes-link-tune dottes-mp3" download
href="../${masterbooke}/${name}.mp3">MP3</a></li> href="../../${mastertunedir}/${name}/${name}.mp3">MP3</a></li>
<li><a class="dottes-link-tune dottes-ogg" download <li><a class="dottes-link-tune dottes-ogg" download
href="../${masterbooke}/${name}.ogg">OGG</a></li> href="../../${mastertunedir}/${name}/${name}.ogg">OGG</a></li>
</ul> </ul>
</div> </div>
</div> </div>
@ -80,18 +80,18 @@
</div> </div>
<div class="dottes-tune-learner-play"> <div class="dottes-tune-learner-play">
<audio controls loop> <audio controls loop>
<source src="../${masterbooke}/littleslow-${name}.mp3" type="audio/mpeg" /> <source src="../../${mastertunedir}/${name}/littleslow-${name}.mp3" type="audio/mpeg" />
<source src="../${masterbooke}/littleslow-${name}.ogg" type="audio/ogg" /> <source src="../../${mastertunedir}/${name}/littleslow-${name}.ogg" type="audio/ogg" />
</audio> </audio>
</div> </div>
<div class="dottes-tune-learner-download"> <div class="dottes-tune-learner-download">
<ul class="tune-data-list"> <ul class="tune-data-list">
<li><a class="dottes-link-tune dottes-mp3" download <li><a class="dottes-link-tune dottes-mp3" download
href="../${masterbooke}/littleslow-${name}.mid">MIDI</a></li> href="../../${mastertunedir}/${name}/littleslow-${name}.mid">MIDI</a></li>
<li><a class="dottes-link-tune dottes-mp3" download <li><a class="dottes-link-tune dottes-mp3" download
href="../${masterbooke}/littleslow-${name}.mp3">MP3</a></li> href="../../${mastertunedir}/${name}/littleslow-${name}.mp3">MP3</a></li>
<li><a class="dottes-link-tune dottes-ogg" download <li><a class="dottes-link-tune dottes-ogg" download
href="../${masterbooke}/littleslow-${name}.ogg">OGG</a></li> href="../../${mastertunedir}/${name}/littleslow-${name}.ogg">OGG</a></li>
</ul> </ul>
</div> </div>
</div> </div>
@ -101,18 +101,18 @@
</div> </div>
<div class="dottes-tune-learner-play"> <div class="dottes-tune-learner-play">
<audio controls loop> <audio controls loop>
<source src="../${masterbooke}/slow-${name}.mp3" type="audio/mpeg" /> <source src="../../${mastertunedir}/${name}/slow-${name}.mp3" type="audio/mpeg" />
<source src="../${masterbooke}/slow-${name}.ogg" type="audio/ogg" /> <source src="../../${mastertunedir}/${name}/slow-${name}.ogg" type="audio/ogg" />
</audio> </audio>
</div> </div>
<div class="dottes-tune-learner-download"> <div class="dottes-tune-learner-download">
<ul class="tune-data-list"> <ul class="tune-data-list">
<li><a class="dottes-link-tune dottes-mp3" download <li><a class="dottes-link-tune dottes-mp3" download
href="../${masterbooke}/slow-${name}.mid">MIDI</a></li> href="../../${mastertunedir}/${name}/slow-${name}.mid">MIDI</a></li>
<li><a class="dottes-link-tune dottes-mp3" download <li><a class="dottes-link-tune dottes-mp3" download
href="../${masterbooke}/slow-${name}.mp3">MP3</a></li> href="../../${mastertunedir}/${name}/slow-${name}.mp3">MP3</a></li>
<li><a class="dottes-link-tune dottes-ogg" download <li><a class="dottes-link-tune dottes-ogg" download
href="../${masterbooke}/slow-${name}.ogg">OGG</a></li> href="../../${mastertunedir}/${name}/slow-${name}.ogg">OGG</a></li>
</ul> </ul>
</div> </div>
</div> </div>
@ -122,18 +122,18 @@
</div> </div>
<div class="dottes-tune-learner-play"> <div class="dottes-tune-learner-play">
<audio controls loop> <audio controls loop>
<source src="../${masterbooke}/veryslow-${name}.mp3" type="audio/mpeg" /> <source src="../../${mastertunedir}/${name}/veryslow-${name}.mp3" type="audio/mpeg" />
<source src="../${masterbooke}/veryslow-${name}.ogg" type="audio/ogg" /> <source src="../../${mastertunedir}/${name}/veryslow-${name}.ogg" type="audio/ogg" />
</audio> </audio>
</div> </div>
<div class="dottes-tune-learner-download"> <div class="dottes-tune-learner-download">
<ul class="tune-data-list"> <ul class="tune-data-list">
<li><a class="dottes-link-tune dottes-mp3" download <li><a class="dottes-link-tune dottes-mp3" download
href="../${masterbooke}/veryslow-${name}.mid">MIDI</a></li> href="../../${mastertunedir}/${name}/veryslow-${name}.mid">MIDI</a></li>
<li><a class="dottes-link-tune dottes-mp3" download <li><a class="dottes-link-tune dottes-mp3" download
href="../${masterbooke}/veryslow-${name}.mp3">MP3</a></li> href="../../${mastertunedir}/${name}/veryslow-${name}.mp3">MP3</a></li>
<li><a class="dottes-link-tune dottes-ogg" download <li><a class="dottes-link-tune dottes-ogg" download
href="../${masterbooke}/veryslow-${name}.ogg">OGG</a></li> href="../../${mastertunedir}/${name}/veryslow-${name}.ogg">OGG</a></li>
</ul> </ul>
</div> </div>
</div> </div>
@ -144,20 +144,20 @@
<div class="dottes-tune-footer-learner-next-column"></div> <div class="dottes-tune-footer-learner-next-column"></div>
<div class="dottes-tune-footer-learner-row"> <div class="dottes-tune-footer-learner-row">
<div class="dottes-tune-footer-learner-prev"> <div class="dottes-tune-footer-learner-prev">
<a href="${prevpage}">${prevfulltitle}</a> <a href="../${prevpage}/learner.html">${prevfulltitle}</a>
</div> </div>
<div class="dottes-tune-footer-learner-booke"> <div class="dottes-tune-footer-learner-booke">
<a class="dottes-tune-icon-link" href="${name}.html"> <a class="dottes-tune-icon-link" href="index.html">
<img class="dottes-tune-header-image" src="../img/music.png" <img class="dottes-tune-header-image" src="../../img/music.png"
alt="Tune dottes page" title="Go to dottes page for ${fulltitle}"> alt="Tune dottes page" title="Go to dottes page for ${fulltitle}">
</a> </a>
<a class="dottes-tune-icon-link" href="index.html"> <a class="dottes-tune-icon-link" href="../../${booke}/index.html">
<img class="dottes-tune-header-image" src="../img/book.png" <img class="dottes-tune-header-image" src="../../img/book.png"
alt="Tune booke index" title="Go to tune booke index"> alt="Tune booke index" title="Go to tune booke index">
</a> </a>
</div> </div>
<div class="dottes-tune-footer-learner-next"> <div class="dottes-tune-footer-learner-next">
<a href="${nextpage}">${nextfulltitle}</a> <a href="../${nextpage}/learner.html">${nextfulltitle}</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -4,7 +4,7 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cry Havoc tunes - ${title}</title> <title>Cry Havoc tunes - ${title}</title>
<link rel="stylesheet" href="../css/dottes.css" /> <link rel="stylesheet" href="../../css/dottes.css" />
<link href='http://fonts.googleapis.com/css?family=Pirata+One|Open+Sans' <link href='http://fonts.googleapis.com/css?family=Pirata+One|Open+Sans'
rel='stylesheet' type='text/css'> rel='stylesheet' type='text/css'>
@ -13,7 +13,7 @@
<div class="container"> <div class="container">
<a href="/"> <a href="/">
<div class="header-strip banner"> <div class="header-strip banner">
<img src="../img/banner.png" alt="Havoc banner image"> <img src="../../img/banner.png" alt="Havoc banner image">
</div> </div>
</a> </a>
@ -55,11 +55,11 @@
<li><a class="dottes-link-tune dottes-pdf" download <li><a class="dottes-link-tune dottes-pdf" download
href="${name}.pdf">PDF</a></li> href="${name}.pdf">PDF</a></li>
<li><a class="dottes-link-tune dottes-midi" download <li><a class="dottes-link-tune dottes-midi" download
href="../${masterbooke}/${name}.mid">MIDI</a></li> href="../../${mastertunedir}/${name}/${name}.mid">MIDI</a></li>
<li><a class="dottes-link-tune dottes-mp3" download <li><a class="dottes-link-tune dottes-mp3" download
href="../${masterbooke}/${name}.mp3">MP3</a></li> href="../../${mastertunedir}/${name}/${name}.mp3">MP3</a></li>
<li><a class="dottes-link-tune dottes-ogg" download <li><a class="dottes-link-tune dottes-ogg" download
href="../${masterbooke}/${name}.ogg">OGG</a></li> href="../../${mastertunedir}/${name}/${name}.ogg">OGG</a></li>
<li><a class="dottes-link-tune dottes-abc" download <li><a class="dottes-link-tune dottes-abc" download
href="${name}.abc">ABC</a></li> href="${name}.abc">ABC</a></li>
<li><a class="dottes-link-tune dottes-xml" download <li><a class="dottes-link-tune dottes-xml" download
@ -68,8 +68,8 @@
</div> </div>
<div class="dottes-tune-footer-play"> <div class="dottes-tune-footer-play">
<audio controls> <audio controls>
<source src="../${masterbooke}/${name}.mp3" type="audio/mpeg" /> <source src="../../${mastertunedir}/${name}/${name}.mp3" type="audio/mpeg" />
<source src="../${masterbooke}/${name}.ogg" type="audio/ogg" /> <source src="../../${mastertunedir}/${name}/${name}.ogg" type="audio/ogg" />
</audio> </audio>
</div> </div>
<div class="dottes-tune-footer-last"> <div class="dottes-tune-footer-last">
@ -78,20 +78,20 @@
</div> </div>
<div class="dottes-tune-footer-row"> <div class="dottes-tune-footer-row">
<div class="dottes-tune-footer-prev"> <div class="dottes-tune-footer-prev">
<a href="${prevpage}">${prevfulltitle}</a> <a href="../${prevpage}/index.html">${prevfulltitle}</a>
</div> </div>
<div class="dottes-tune-footer-booke"> <div class="dottes-tune-footer-booke">
<a class="dottes-tune-icon-link" href="learner-${name}.html"> <a class="dottes-tune-icon-link" href="learner.html">
<img class="dottes-tune-header-image" src="../img/learner.png" <img class="dottes-tune-header-image" src="../../img/learner.png"
alt="Learner tune page" title="Go to learner page for ${fulltitle}"> alt="Learner tune page" title="Go to learner page for ${fulltitle}">
</a> </a>
<a class="dottes-tune-icon-link" href="index.html"> <a class="dottes-tune-icon-link" href="../../${booke}/index.html">
<img class="dottes-tune-header-image" src="../img/book.png" <img class="dottes-tune-header-image" src="../../img/book.png"
alt="Tune booke index" title="Go to tune booke index"> alt="Tune booke index" title="Go to tune booke index">
</a> </a>
</div> </div>
<div class="dottes-tune-footer-next"> <div class="dottes-tune-footer-next">
<a href="${nextpage}">${nextfulltitle}</a> <a href="../${nextpage}/index.html">${nextfulltitle}</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,15 +1,15 @@
<div class="dottes-tune-list-item"> <div class="dottes-tune-list-item">
<div class="dottes-tune-list-item-link"> <div class="dottes-tune-list-item-link">
<a class="dottes-tune-link" href="${name}.html">${fulltitle}</a> <a class="dottes-tune-link" href="../${tunedir}/index.html">${fulltitle}</a>
</div> </div>
<div class="dottes-tune-list-item-learner-link"> <div class="dottes-tune-list-item-learner-link">
<a class="dottes-tune-link" href="learner-${name}.html"> <a class="dottes-tune-link" href="../${tunedir}/learner.html">
<img class="dottes-tune-table-image" src="../img/learner.png" alt="Learner page" title="Learner page for ${fulltitle}"> <img class="dottes-tune-table-image" src="../img/learner.png" alt="Learner page" title="Learner page for ${fulltitle}">
</a> </a>
</div> </div>
<div class="dottes-tune-list-item-image"> <div class="dottes-tune-list-item-image">
<a href="${name}.html"> <a href="../${tunedir}/index.html">
<img class="dottes-tune-table-image" src="firstline-${name}.png" <img class="dottes-tune-table-image" src="../${tunedir}/firstline-${name}.png"
alt="${fulltitle} first line" title="${fulltitle} first line"> alt="${fulltitle} first line" title="${fulltitle} first line">
</a> </a>
</div> </div>

View File

@ -48,7 +48,7 @@ makeATransposedBooke()
makeBookePrint "$1" makeBookePrint "$1"
# Web output. Uses audio from main booke. # Web output. Uses audio from main booke.
./makeWebGraphics.sh "$1" ./makeWebGraphics.sh "$1" "$3"
./makeWeb.sh "$1" "$2" "$3" ./makeWeb.sh "$1" "$2" "$3"
} }

View File

@ -18,7 +18,10 @@ booke=$1
masterbooke=$2 masterbooke=$2
bookedir=$dir/$1 bookedir=$dir/$1
masterbookedir=$dir/$2 masterbookedir=$dir/$2
webdir=$dir/web/$1 basewebdir=$dir/web
mastertunedir=tunes
basetunedir=$mastertunedir
bookewebdir=$dir/web/$1
graphicsdir=$dir/graphics/$1 graphicsdir=$dir/graphics/$1
output=index.html output=index.html
tunelist=tunelist.html tunelist=tunelist.html
@ -38,34 +41,35 @@ fi
if [ -n "$instrument" ]; then if [ -n "$instrument" ]; then
title="${title} ($instrument)" title="${title} ($instrument)"
subtitle="${subtitle} ($instrument)" subtitle="${subtitle} ($instrument)"
basetunedir="${basetunedir}-${instrument}"
fi fi
mkdir -p $webdir mkdir -p $bookewebdir
sed -e "s/@BUILD@/$buildno/" -e "s/@SUBTITLE@/$subtitle/" \ sed -e "s/@BUILD@/$buildno/" -e "s/@SUBTITLE@/$subtitle/" \
-e "s/@TITLE@/$title/" -e "s/@BOOK@/$booke/" dottes.html > $webdir/$output -e "s/@TITLE@/$title/" -e "s/@BOOK@/$booke/" dottes.html > $bookewebdir/$output
for item in intro for item in intro
do do
rm -f $webdir/$item.html rm -f $bookewebdir/$item.html
if [ -r $bookedir/$item.md ]; then if [ -r $bookedir/$item.md ]; then
pandoc --from=markdown --to=html --output=$webdir/$item.html $bookedir/$item.md pandoc --from=markdown --to=html --output=$bookewebdir/$item.html $bookedir/$item.md
else else
touch $webdir/$item.html touch $bookewebdir/$item.html
fi fi
done done
# Copy in any htaccess. # Copy in any htaccess.
if [ -r $masterbookedir/htaccess ]; then if [ -r $masterbookedir/htaccess ]; then
cp $masterbookedir/htaccess $webdir/.htaccess cp $masterbookedir/htaccess $bookewebdir/.htaccess
fi fi
# Copy in the book PDFs. Like the graphics, Midi etc. these are assumed # Copy in the book PDFs. Like the graphics, Midi etc. these are assumed
# to be already generated. # to be already generated.
cp $1-*.pdf $webdir cp $1-*.pdf $bookewebdir
# Now, for each tune, make the tune page. # Now, for each tune, make the tune page.
rm -f $webdir/$tunelist rm -f $bookewebdir/$tunelist
declare -a filenames declare -a filenames
filenames=(`find $bookedir -maxdepth 1 -name "*.abc" | sort`) filenames=(`find $bookedir -maxdepth 1 -name "*.abc" | sort`)
nofiles=${#filenames[@]} nofiles=${#filenames[@]}
@ -73,22 +77,15 @@ for (( i=0; i < ${nofiles}; i++ ))
do do
filename=${filenames[$i]} filename=${filenames[$i]}
name=`basename $filename .abc` name=`basename $filename .abc`
tunedir=$basetunedir/$name
tunewebdir=$basewebdir/$tunedir
mkdir -p $tunewebdir
# Copy the ABC into the web. # Copy the ABC into the web.
cp $filename $webdir cp $filename $tunewebdir
# Generate MusicXML into the web. # Generate MusicXML into the web.
python $abc2xml $filename > ${webdir}/${name}.xml python $abc2xml $filename > ${tunewebdir}/${name}.xml
# If we are not the master booke, link the mp3s in from the
# master page in a desperate attempt to make IE8 work.
# The Jenkins archive will dereference the soft link, it seems,
# but I guess I can live with copies of the MP3 for now.
if [ "$booke" != "$masterbooke" ]; then
pushd ${webdir} > /dev/null
ln -f -s ../${masterbooke}/*${name}.mp3 .
popd > /dev/null
fi
# Get date and time of last change to tune. # Get date and time of last change to tune.
lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc` lastchanged=`hg log --limit 1 --template "{date|shortdate}" $masterbookedir/${name}.abc`
@ -101,34 +98,35 @@ do
if [ $i -gt 0 ]; then if [ $i -gt 0 ]; then
prev=${filenames[$((i - 1))]} prev=${filenames[$((i - 1))]}
prevpage=`basename $prev .abc`.html prevpage=`basename $prev .abc`
prevarg="--prev $prev" prevarg="--prev $prev"
fi fi
if [ $i -lt $((nofiles - 1)) ]; then if [ $i -lt $((nofiles - 1)) ]; then
next=${filenames[$((i + 1))]} next=${filenames[$((i + 1))]}
nextpage=`basename $next .abc`.html nextpage=`basename $next .abc`
nextarg="--next $next" nextarg="--next $next"
fi fi
# Generate the tune web page. # Generate the tune web page.
tunepage=${name}.html
learnerpage=learner-${name}.html
$dir/abctemplate.py \ $dir/abctemplate.py \
--value "masterbooke=${masterbooke}" \ --value "booke=${booke}" \
--value "mastertunedir=${mastertunedir}" \
--value "lastchanged=${lastchanged}" \ --value "lastchanged=${lastchanged}" \
--value "prevpage=${prevpage}" \ --value "prevpage=${prevpage}" \
--value "nextpage=${nextpage}" \ --value "nextpage=${nextpage}" \
${prevarg} ${nextarg} \ ${prevarg} ${nextarg} \
--template dottes.html.tune \ --template dottes.html.tune \
$filename > $webdir/$tunepage $filename > $tunewebdir/index.html
$dir/abctemplate.py \ $dir/abctemplate.py \
--value "masterbooke=${masterbooke}" \ --value "booke=${booke}" \
--value "mastertunedir=${mastertunedir}" \
--value "lastchanged=${lastchanged}" \ --value "lastchanged=${lastchanged}" \
--value "prevpage=${prevpage}" \ --value "prevpage=${prevpage}" \
--value "nextpage=${nextpage}" \ --value "nextpage=${nextpage}" \
${prevarg} ${nextarg} \ ${prevarg} ${nextarg} \
--template dottes.html.learnertune \ --template dottes.html.learnertune \
$filename > $webdir/$learnerpage $filename > $tunewebdir/learner.html
$dir/abctemplate.py --template dottes.html.tuneindex $filename >> $webdir/$tunelist $dir/abctemplate.py \
--value "tunedir=${tunedir}" \
--template dottes.html.tuneindex $filename >> $bookewebdir/$tunelist
done done

View File

@ -12,39 +12,46 @@ fi
dir=`pwd` dir=`pwd`
booke=$dir/$1 booke=$dir/$1
builddir=$dir/web/$1 basewebdir=$dir/web
basetunedir=$basewebdir/tunes
mkdir -p $builddir
# Make MP3 and OGG files for the input .abc. Since we're listening to # Make MP3 and OGG files for the input .abc. Since we're listening to
# a doorbell playing the tunes, go for lowest quality (and hence smallest) # a doorbell playing the tunes, go for lowest quality (and hence smallest)
# MP3 and OGG. $1 is the input filename, $2 is optional args for timidity. # MP3 and OGG. $1 is the input filename, $2 is the output directory,
# $3 is optional args for timidity.
makeaudiofiles() makeaudiofiles()
{ {
name=`basename $1 .abc` name=`basename $1 .abc`
tunedir="$2"
abc2midi $1 -o $builddir/${name}.mid abc2midi $1 -o $tunedir/${name}.tmp.mid
timidity -OwM $2 -o $builddir/${name}.wav $builddir/${name}.mid mv $tunedir/${name}.tmp.mid $tunedir/${name}.mid
lame -m m -V 9 --quiet $builddir/${name}.wav $builddir/${name}.mp3 timidity -OwM $3 -o $tunedir/${name}.wav $tunedir/${name}.mid
lame -m m -V 9 --quiet $tunedir/${name}.wav $tunedir/${name}.tmp.mp3
mv $tunedir/${name}.tmp.mp3 $tunedir/${name}.mp3
# Timidity can generate OGG directly. But we need to generate WAV # Timidity can generate OGG directly. But we need to generate WAV
# for lame, and oggenc produces smaller output. OGG is needed for # for lame, and oggenc produces smaller output. OGG is needed for
# Firefox's audio tag. FF doesn't support MP3, some others support # Firefox's audio tag. FF doesn't support MP3, some others support
# MP3 but not OGG. # MP3 but not OGG.
oggenc -Q -q 0 -o $builddir/${name}.ogg $builddir/${name}.wav oggenc -Q -q 0 -o $tunedir/${name}.tmp.ogg $tunedir/${name}.wav
mv $tunedir/${name}.tmp.ogg $tunedir/${name}.ogg
rm $builddir/${name}.wav rm $tunedir/${name}.wav
} }
# Make audio for a new tempo for the abc file $1, giving the output files # Make audio for a new tempo for the abc file $1, giving the output
# the same name with a prefix $2. The new tempo is the original tempo # files the same name with a prefix $3 in output directory $2. The new
# (120 used if not specified), multiplied by $3 and divided by $4. # tempo is the original tempo (120 used if not specified), multiplied
# These audio files are for Learner use; I've found that having the # by $4 and divided by $5. These audio files are for Learner use;
# chords thumping away can make it hard to distinguish the melody, so # I've found that having the chords thumping away can make it hard to
# arrange for timidity to mute everything except the melody track. # distinguish the melody, so arrange for timidity to mute everything
# except the melody track.
makeaudiofortempo() makeaudiofortempo()
{ {
name=`basename $filename .abc` name=`basename $1 .abc`
newspeedfilename="$2-${name}.abc" tunedir="$2"
newspeedfilename="$3-${name}.abc"
mkdir -p $tunedir
# Prepare new speed audio files. # Prepare new speed audio files.
# The tempo is either a plain number, or <notelen>=<number>. # The tempo is either a plain number, or <notelen>=<number>.
@ -57,23 +64,27 @@ makeaudiofortempo()
numtempo=${tempo:pos} numtempo=${tempo:pos}
notelenprefix=${tempo:0:pos} notelenprefix=${tempo:0:pos}
# Calculate new tempo. # Calculate new tempo.
newtempo=$(( ( $numtempo * $3 ) / $4 )) newtempo=$(( ( $numtempo * $4 ) / $5 ))
# Insert new tempo and delete old. Old may not exist, # Insert new tempo and delete old. Old may not exist,
# so do this rather than overwrite. # so do this rather than overwrite.
sed -e "/^Q:/d" -e "/^K:/aQ: ${notelenprefix}${newtempo}" $1 > $builddir/$newspeedfilename sed -e "/^Q:/d" -e "/^K:/aQ: ${notelenprefix}${newtempo}" $1 > $tunedir/$newspeedfilename
makeaudiofiles $builddir/$newspeedfilename --mute=0,-1 makeaudiofiles $tunedir/$newspeedfilename $tunedir --mute=0,-1
rm $builddir/$newspeedfilename rm $tunedir/$newspeedfilename
} }
# Generate audio files and slow speed (currently half speed) audio files. # Generate audio files and slow speed (currently half speed) audio files.
find $booke -maxdepth 1 -name "*.abc" | sort | find $booke -maxdepth 1 -name "*.abc" | sort |
while read filename while read filename
do do
makeaudiofiles $filename name=`basename $filename .abc`
tunedir=$basetunedir/$name
mkdir -p $tunedir
makeaudiofiles $filename $tunedir
# Now make 1/4, 1/2 and 3/4 speed audio. # Now make 1/4, 1/2 and 3/4 speed audio.
makeaudiofortempo $filename "veryslow" 1 4 makeaudiofortempo $filename $tunedir "veryslow" 1 4
makeaudiofortempo $filename "slow" 2 4 makeaudiofortempo $filename $tunedir "slow" 2 4
makeaudiofortempo $filename "littleslow" 3 4 makeaudiofortempo $filename $tunedir "littleslow" 3 4
makeaudiofortempo $filename "normal" 4 4 makeaudiofortempo $filename $tunedir "normal" 4 4
done done

View File

@ -1,21 +1,25 @@
#!/bin/bash #!/bin/bash
# #
# Make graphics required for the website but not for the book. # Make graphics required for the website but not for the book.
# They go into web/<book>. # They go into web/tunes/<tunename>, or web/tunes-<instrument>/<tunename>.
# #
if [ $# != 1 ]; then if [[ $# -lt 1 ]]; then
echo "Usage: makeWebGraphics.sh <book dir name>" echo "Usage: makeWebGraphics.sh <book dir name> [<instrument name>]"
exit 1 exit 1
fi fi
dir=`pwd` dir=`pwd`
booke=$dir/$1 booke=$dir/$1
builddir=$dir/web/$1 basewebdir=$dir/web
basetunedir=$basewebdir/tunes
graphicsdir=$dir/graphics/$1 graphicsdir=$dir/graphics/$1
instrument=$2
mkdir -p $builddir if [ -n "$instrument" ]; then
basetunedir="${basetunedir}-${instrument}"
fi
# Now, for each tune, make the main tune and tune first line bitmaps. # Now, for each tune, make the main tune and tune first line bitmaps.
# Do this to temp files and rename into place to make updates as # Do this to temp files and rename into place to make updates as
@ -24,16 +28,19 @@ find $booke -maxdepth 1 -name "*.abc" | sort |
while read filename while read filename
do do
name=`basename $filename .abc` name=`basename $filename .abc`
tmpname=${name}.tmp tunedir=$basetunedir/$name
convert -colors 256 -quality 90 -density 200 $graphicsdir/${name}.pdf $builddir/${tmpname}.png mkdir -p $tunedir
convert -colors 256 -quality 90 -density 200 $graphicsdir/firstline-${name}.pdf $builddir/firstline-${tmpname}.png
mv $builddir/${tmpname}.png $builddir/${name}.png tmpname=${name}.tmp
mv $builddir/firstline-${tmpname}.png $builddir/firstline-${name}.png convert -colors 256 -quality 90 -density 200 $graphicsdir/${name}.pdf $tunedir/${tmpname}.png
convert -colors 256 -quality 90 -density 200 $graphicsdir/firstline-${name}.pdf $tunedir/firstline-${tmpname}.png
mv $tunedir/${tmpname}.png $tunedir/${name}.png
mv $tunedir/firstline-${tmpname}.png $tunedir/firstline-${name}.png
# Make the web downloadable PDF with the tune title. # Make the web downloadable PDF with the tune title.
abcm2ps -E -F singletuneweb -O $builddir/$name.eps $filename abcm2ps -E -F singletuneweb -O $tunedir/$name.eps $filename
# And make the corresponding PDF. # And make the corresponding PDF.
epstopdf --outfile=$builddir/$name.pdf $builddir/${name}001.eps epstopdf --outfile=$tunedir/$name.pdf $tunedir/${name}001.eps
rm $builddir/${name}001.eps rm $tunedir/${name}001.eps
done done