Make 1/4, 1/2 and 3/4 speed audio for tunes.

Name them 'veryslow', 'slow' and 'littleslow'.
This commit is contained in:
Jim Hague 2013-09-02 10:15:56 +01:00
parent 652808a894
commit fc1d7cfc88
1 changed files with 31 additions and 19 deletions

View File

@ -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 <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