Mercurial > dottes
comparison makeWebAudio.sh @ 394:ae9c05d2aafd
Make slow speed web audio files.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Sun, 01 Sep 2013 23:13:06 +0100 |
parents | c5d404bf68a3 |
children | aeef7b1ca0ad |
comparison
equal
deleted
inserted
replaced
393:c5d404bf68a3 | 394:ae9c05d2aafd |
---|---|
14 booke=$dir/$1 | 14 booke=$dir/$1 |
15 builddir=$dir/web/$1 | 15 builddir=$dir/web/$1 |
16 | 16 |
17 mkdir -p $builddir | 17 mkdir -p $builddir |
18 | 18 |
19 # Now, for each tune, make the tune bitmap and sound. Do this to temp | 19 # Make MP3 and OGG files for the input .abc. In case we're generating |
20 # files and rename into place to make updates as atomic as possible. | 20 # to a live site (which we won't be), do this to temp files and rename |
21 # into place to make updates as atomic as possible. | |
22 makeaudiofiles() | |
23 { | |
24 name=`basename $1 .abc` | |
25 tmpname=${name}.tmp | |
26 | |
27 abc2midi $1 -o $builddir/${tmpname}.mid | |
28 timidity -OwM -o $builddir/${tmpname}.wav $builddir/${tmpname}.mid | |
29 lame -m m -V 9 --quiet $builddir/${tmpname}.wav $builddir/${tmpname}.mp3 | |
30 # Timidity can generate OGG directly. But we need to generate WAV | |
31 # for lame, and oggenc produces smaller output. OGG is needed for | |
32 # Firefox's audio tag. FF doesn't support MP3, some others support | |
33 # MP3 but not OGG. | |
34 oggenc -Q -q 0 -o $builddir/${tmpname}.ogg $builddir/${tmpname}.wav | |
35 | |
36 mv $builddir/${tmpname}.mid $builddir/${name}.mid | |
37 mv $builddir/${tmpname}.mp3 $builddir/${name}.mp3 | |
38 mv $builddir/${tmpname}.ogg $builddir/${name}.ogg | |
39 rm $builddir/${tmpname}.wav | |
40 } | |
41 | |
42 # Generate audio files and slow speed (currently half speed) audio files. | |
21 find $booke -name "*.abc" | sort | | 43 find $booke -name "*.abc" | sort | |
22 while read filename | 44 while read filename |
23 do | 45 do |
46 makeaudiofiles $filename | |
47 | |
24 name=`basename $filename .abc` | 48 name=`basename $filename .abc` |
25 tmpname=${name}.tmp | 49 slowspeedfilename="slowspeed-${name}.abc" |
26 | 50 |
27 abc2midi $filename -o $builddir/${tmpname}.mid | 51 # Prepare slow speed audio files. |
28 timidity -OwM -o $builddir/${tmpname}.wav $builddir/${tmpname}.mid | 52 # The tempo is either a plain number, or <notelen>=<number>. |
29 lame -m m -V 9 --quiet $builddir/${tmpname}.wav $builddir/${tmpname}.mp3 | 53 tempo=`$dir/abcfield.py --field Q $filename` |
30 # Timidity can generate OGG directly. But we need to generate WAV | 54 if [ -z $tempo ]; then |
31 # for lame, and oggenc produces smaller output. OGG is needed for | 55 echo "Warning: $filename has no tempo. Using 120." |
32 # Firefox's audio tag. FF doesn't support MP3, some others support | 56 tempo="120" |
33 # MP3 but not OGG. | 57 fi |
34 oggenc -Q -q 0 -o $builddir/${tmpname}.ogg $builddir/${tmpname}.wav | 58 pos=`expr index $tempo '='` |
35 | 59 numtempo=${tempo:pos} |
36 mv $builddir/${tmpname}.mid $builddir/${name}.mid | 60 notelenprefix=${tempo:0:pos} |
37 mv $builddir/${tmpname}.mp3 $builddir/${name}.mp3 | 61 # Make new tempo half original speed. |
38 mv $builddir/${tmpname}.ogg $builddir/${name}.ogg | 62 newtempo=$(( $numtempo / 2 )) |
39 rm $builddir/${tmpname}.wav | 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 | |
40 done | 67 done |