From 449ef19c5601872baa1fc30275dc09c81e9377d8 Mon Sep 17 00:00:00 2001 From: Jim Hague Date: Wed, 19 Feb 2020 10:33:55 +0000 Subject: [PATCH] Revist tempo change code when generating web audio. Now Mac friendly. --- makeWebAudio.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/makeWebAudio.sh b/makeWebAudio.sh index b7785da..3d8a736 100755 --- a/makeWebAudio.sh +++ b/makeWebAudio.sh @@ -60,14 +60,20 @@ makeaudiofortempo() echo "Warning: $1 has no tempo. Using 120." tempo="120" fi - pos=`expr index $tempo '='` - numtempo=${tempo:pos} - notelenprefix=${tempo:0:pos} + numtempo=${tempo##*=} + notelenprefix=${tempo%%=*} + if [ "$notelenprefix" = "$numtempo" ]; then + notelenprefix= + else + notelenprefix="${notelenprefix}=" + fi # Calculate new tempo. newtempo=$(( ( $numtempo * $4 ) / $5 )) + echo "Old tempo $tempo new tempo ${notelenprefix}${newtempo}" # 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 > $tunedir/$newspeedfilename + sed -e "/^Q:/d" -e "/^K:/a\\ +Q: ${notelenprefix}${newtempo}" $1 > $tunedir/$newspeedfilename makeaudiofiles $tunedir/$newspeedfilename $tunedir --mute=0,-1 rm $tunedir/$newspeedfilename }