Revist tempo change code when generating web audio.

Now Mac friendly.
This commit is contained in:
Jim Hague 2020-02-19 10:33:55 +00:00
parent 202b1d7176
commit 449ef19c56
1 changed files with 10 additions and 4 deletions

View File

@ -60,14 +60,20 @@ makeaudiofortempo()
echo "Warning: $1 has no tempo. Using 120." echo "Warning: $1 has no tempo. Using 120."
tempo="120" tempo="120"
fi fi
pos=`expr index $tempo '='` numtempo=${tempo##*=}
numtempo=${tempo:pos} notelenprefix=${tempo%%=*}
notelenprefix=${tempo:0:pos} if [ "$notelenprefix" = "$numtempo" ]; then
notelenprefix=
else
notelenprefix="${notelenprefix}="
fi
# Calculate new tempo. # Calculate new tempo.
newtempo=$(( ( $numtempo * $4 ) / $5 )) newtempo=$(( ( $numtempo * $4 ) / $5 ))
echo "Old tempo $tempo new tempo ${notelenprefix}${newtempo}"
# 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 > $tunedir/$newspeedfilename sed -e "/^Q:/d" -e "/^K:/a\\
Q: ${notelenprefix}${newtempo}" $1 > $tunedir/$newspeedfilename
makeaudiofiles $tunedir/$newspeedfilename $tunedir --mute=0,-1 makeaudiofiles $tunedir/$newspeedfilename $tunedir --mute=0,-1
rm $tunedir/$newspeedfilename rm $tunedir/$newspeedfilename
} }