Mercurial > dottes
comparison makeWebAudio.sh @ 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 | ae9c05d2aafd |
children | f1c4abe4fc75 |
comparison
equal
deleted
inserted
replaced
398:454505e7a7bb | 399:aeef7b1ca0ad |
---|---|
37 mv $builddir/${tmpname}.mp3 $builddir/${name}.mp3 | 37 mv $builddir/${tmpname}.mp3 $builddir/${name}.mp3 |
38 mv $builddir/${tmpname}.ogg $builddir/${name}.ogg | 38 mv $builddir/${tmpname}.ogg $builddir/${name}.ogg |
39 rm $builddir/${tmpname}.wav | 39 rm $builddir/${tmpname}.wav |
40 } | 40 } |
41 | 41 |
42 # Make audio for a new tempo for the abc file $1, giving the output files | |
43 # the same name with a prefix $2. The new tempo is the original tempo | |
44 # (120 used if not specified), multiplied by $3 and divided by $4. | |
45 makeaudiofortempo() | |
46 { | |
47 name=`basename $filename .abc` | |
48 newspeedfilename="$2-${name}.abc" | |
49 | |
50 # Prepare new speed audio files. | |
51 # The tempo is either a plain number, or <notelen>=<number>. | |
52 tempo=`$dir/abcfield.py --field Q $1` | |
53 if [ -z $tempo ]; then | |
54 echo "Warning: $1 has no tempo. Using 120." | |
55 tempo="120" | |
56 fi | |
57 pos=`expr index $tempo '='` | |
58 numtempo=${tempo:pos} | |
59 notelenprefix=${tempo:0:pos} | |
60 # Calculate new tempo. | |
61 newtempo=$(( ( $numtempo * $3 ) / $4 )) | |
62 # Insert new tempo and delete old. Old may not exist, | |
63 # so do this rather than overwrite. | |
64 sed -e "/^Q:/d" -e "/^K:/aQ: ${notelenprefix}${newtempo}" $1 > $builddir/$newspeedfilename | |
65 makeaudiofiles $builddir/$newspeedfilename | |
66 rm $builddir/$newspeedfilename | |
67 } | |
68 | |
42 # Generate audio files and slow speed (currently half speed) audio files. | 69 # Generate audio files and slow speed (currently half speed) audio files. |
43 find $booke -name "*.abc" | sort | | 70 find $booke -name "*.abc" | sort | |
44 while read filename | 71 while read filename |
45 do | 72 do |
46 makeaudiofiles $filename | 73 makeaudiofiles $filename |
47 | 74 |
48 name=`basename $filename .abc` | 75 # Now make 1/4, 1/2 and 3/4 speed audio. |
49 slowspeedfilename="slowspeed-${name}.abc" | 76 makeaudiofortempo $filename "veryslow" 1 4 |
50 | 77 makeaudiofortempo $filename "slow" 1 2 |
51 # Prepare slow speed audio files. | 78 makeaudiofortempo $filename "littleslow" 3 4 |
52 # The tempo is either a plain number, or <notelen>=<number>. | |
53 tempo=`$dir/abcfield.py --field Q $filename` | |
54 if [ -z $tempo ]; then | |
55 echo "Warning: $filename has no tempo. Using 120." | |
56 tempo="120" | |
57 fi | |
58 pos=`expr index $tempo '='` | |
59 numtempo=${tempo:pos} | |
60 notelenprefix=${tempo:0:pos} | |
61 # Make new tempo half original speed. | |
62 newtempo=$(( $numtempo / 2 )) | |
63 # Insert new tempo and delete old. Old may not exist, | |
64 # so do this rather than overwrite. | |
65 sed -e "/^Q:/d" -e "/^K:/aQ: ${notelenprefix}${newtempo}" $filename > $builddir/$slowspeedfilename | |
66 makeaudiofiles $builddir/$slowspeedfilename | |
67 done | 79 done |