From fc1d7cfc8866cf6803a6e429c9d80c962d06a3a3 Mon Sep 17 00:00:00 2001 From: Jim Hague Date: Mon, 2 Sep 2013 10:15:56 +0100 Subject: [PATCH] Make 1/4, 1/2 and 3/4 speed audio for tunes. Name them 'veryslow', 'slow' and 'littleslow'. --- makeWebAudio.sh | 50 ++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/makeWebAudio.sh b/makeWebAudio.sh index 9bf017c..42139e7 100755 --- a/makeWebAudio.sh +++ b/makeWebAudio.sh @@ -39,29 +39,41 @@ makeaudiofiles() rm $builddir/${tmpname}.wav } +# Make audio for a new tempo for the abc file $1, giving the output files +# the same name with a prefix $2. The new tempo is the original tempo +# (120 used if not specified), multiplied by $3 and divided by $4. +makeaudiofortempo() +{ + name=`basename $filename .abc` + newspeedfilename="$2-${name}.abc" + + # Prepare new speed audio files. + # The tempo is either a plain number, or =. + tempo=`$dir/abcfield.py --field Q $1` + if [ -z $tempo ]; then + echo "Warning: $1 has no tempo. Using 120." + tempo="120" + fi + pos=`expr index $tempo '='` + numtempo=${tempo:pos} + notelenprefix=${tempo:0:pos} + # Calculate new tempo. + newtempo=$(( ( $numtempo * $3 ) / $4 )) + # Insert new tempo and delete old. Old may not exist, + # so do this rather than overwrite. + sed -e "/^Q:/d" -e "/^K:/aQ: ${notelenprefix}${newtempo}" $1 > $builddir/$newspeedfilename + makeaudiofiles $builddir/$newspeedfilename + rm $builddir/$newspeedfilename +} + # Generate audio files and slow speed (currently half speed) audio files. find $booke -name "*.abc" | sort | while read filename do makeaudiofiles $filename - name=`basename $filename .abc` - slowspeedfilename="slowspeed-${name}.abc" - - # Prepare slow speed audio files. - # The tempo is either a plain number, or =. - tempo=`$dir/abcfield.py --field Q $filename` - if [ -z $tempo ]; then - echo "Warning: $filename has no tempo. Using 120." - tempo="120" - fi - pos=`expr index $tempo '='` - numtempo=${tempo:pos} - notelenprefix=${tempo:0:pos} - # Make new tempo half original speed. - newtempo=$(( $numtempo / 2 )) - # Insert new tempo and delete old. Old may not exist, - # so do this rather than overwrite. - sed -e "/^Q:/d" -e "/^K:/aQ: ${notelenprefix}${newtempo}" $filename > $builddir/$slowspeedfilename - makeaudiofiles $builddir/$slowspeedfilename + # Now make 1/4, 1/2 and 3/4 speed audio. + makeaudiofortempo $filename "veryslow" 1 4 + makeaudiofortempo $filename "slow" 1 2 + makeaudiofortempo $filename "littleslow" 3 4 done