Mercurial > dottes
changeset 399:aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Name them 'veryslow', 'slow' and 'littleslow'.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Mon, 02 Sep 2013 10:15:56 +0100 |
parents | 454505e7a7bb |
children | f1c4abe4fc75 |
files | makeWebAudio.sh |
diffstat | 1 files changed, 31 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/makeWebAudio.sh Mon Sep 02 10:02:16 2013 +0100 +++ b/makeWebAudio.sh Mon Sep 02 10:15:56 2013 +0100 @@ -39,29 +39,41 @@ 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 <notelen>=<number>. + 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 <notelen>=<number>. - 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