Mercurial > dottes
comparison makeWebAudio.sh @ 943:d6e2a281cceb build-default-344
Change web page layout.
Put tune contents under 'tunes/<name>' or 'tunes-<instrument>/<name>'.
That way they won't move if the tune gets moved between Bookes.
For now I have not attempted to redirect old URLs.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Mon, 05 Aug 2019 23:25:28 +0100 |
parents | b83b49f2a0a0 |
children | e4d31e094d24 |
comparison
equal
deleted
inserted
replaced
942:a774b3b3cad7 | 943:d6e2a281cceb |
---|---|
10 fi | 10 fi |
11 | 11 |
12 dir=`pwd` | 12 dir=`pwd` |
13 | 13 |
14 booke=$dir/$1 | 14 booke=$dir/$1 |
15 builddir=$dir/web/$1 | 15 basewebdir=$dir/web |
16 | 16 basetunedir=$basewebdir/tunes |
17 mkdir -p $builddir | |
18 | 17 |
19 # Make MP3 and OGG files for the input .abc. Since we're listening to | 18 # Make MP3 and OGG files for the input .abc. Since we're listening to |
20 # a doorbell playing the tunes, go for lowest quality (and hence smallest) | 19 # a doorbell playing the tunes, go for lowest quality (and hence smallest) |
21 # MP3 and OGG. $1 is the input filename, $2 is optional args for timidity. | 20 # MP3 and OGG. $1 is the input filename, $2 is the output directory, |
21 # $3 is optional args for timidity. | |
22 makeaudiofiles() | 22 makeaudiofiles() |
23 { | 23 { |
24 name=`basename $1 .abc` | 24 name=`basename $1 .abc` |
25 tunedir="$2" | |
25 | 26 |
26 abc2midi $1 -o $builddir/${name}.mid | 27 abc2midi $1 -o $tunedir/${name}.tmp.mid |
27 timidity -OwM $2 -o $builddir/${name}.wav $builddir/${name}.mid | 28 mv $tunedir/${name}.tmp.mid $tunedir/${name}.mid |
28 lame -m m -V 9 --quiet $builddir/${name}.wav $builddir/${name}.mp3 | 29 timidity -OwM $3 -o $tunedir/${name}.wav $tunedir/${name}.mid |
30 lame -m m -V 9 --quiet $tunedir/${name}.wav $tunedir/${name}.tmp.mp3 | |
31 mv $tunedir/${name}.tmp.mp3 $tunedir/${name}.mp3 | |
29 # Timidity can generate OGG directly. But we need to generate WAV | 32 # Timidity can generate OGG directly. But we need to generate WAV |
30 # for lame, and oggenc produces smaller output. OGG is needed for | 33 # for lame, and oggenc produces smaller output. OGG is needed for |
31 # Firefox's audio tag. FF doesn't support MP3, some others support | 34 # Firefox's audio tag. FF doesn't support MP3, some others support |
32 # MP3 but not OGG. | 35 # MP3 but not OGG. |
33 oggenc -Q -q 0 -o $builddir/${name}.ogg $builddir/${name}.wav | 36 oggenc -Q -q 0 -o $tunedir/${name}.tmp.ogg $tunedir/${name}.wav |
37 mv $tunedir/${name}.tmp.ogg $tunedir/${name}.ogg | |
34 | 38 |
35 rm $builddir/${name}.wav | 39 rm $tunedir/${name}.wav |
36 } | 40 } |
37 | 41 |
38 # Make audio for a new tempo for the abc file $1, giving the output files | 42 # Make audio for a new tempo for the abc file $1, giving the output |
39 # the same name with a prefix $2. The new tempo is the original tempo | 43 # files the same name with a prefix $3 in output directory $2. The new |
40 # (120 used if not specified), multiplied by $3 and divided by $4. | 44 # tempo is the original tempo (120 used if not specified), multiplied |
41 # These audio files are for Learner use; I've found that having the | 45 # by $4 and divided by $5. These audio files are for Learner use; |
42 # chords thumping away can make it hard to distinguish the melody, so | 46 # I've found that having the chords thumping away can make it hard to |
43 # arrange for timidity to mute everything except the melody track. | 47 # distinguish the melody, so arrange for timidity to mute everything |
48 # except the melody track. | |
44 makeaudiofortempo() | 49 makeaudiofortempo() |
45 { | 50 { |
46 name=`basename $filename .abc` | 51 name=`basename $1 .abc` |
47 newspeedfilename="$2-${name}.abc" | 52 tunedir="$2" |
53 newspeedfilename="$3-${name}.abc" | |
54 mkdir -p $tunedir | |
48 | 55 |
49 # Prepare new speed audio files. | 56 # Prepare new speed audio files. |
50 # The tempo is either a plain number, or <notelen>=<number>. | 57 # The tempo is either a plain number, or <notelen>=<number>. |
51 tempo=`$dir/abcfield.py --field Q $1` | 58 tempo=`$dir/abcfield.py --field Q $1` |
52 if [ -z $tempo ]; then | 59 if [ -z $tempo ]; then |
55 fi | 62 fi |
56 pos=`expr index $tempo '='` | 63 pos=`expr index $tempo '='` |
57 numtempo=${tempo:pos} | 64 numtempo=${tempo:pos} |
58 notelenprefix=${tempo:0:pos} | 65 notelenprefix=${tempo:0:pos} |
59 # Calculate new tempo. | 66 # Calculate new tempo. |
60 newtempo=$(( ( $numtempo * $3 ) / $4 )) | 67 newtempo=$(( ( $numtempo * $4 ) / $5 )) |
61 # Insert new tempo and delete old. Old may not exist, | 68 # Insert new tempo and delete old. Old may not exist, |
62 # so do this rather than overwrite. | 69 # so do this rather than overwrite. |
63 sed -e "/^Q:/d" -e "/^K:/aQ: ${notelenprefix}${newtempo}" $1 > $builddir/$newspeedfilename | 70 sed -e "/^Q:/d" -e "/^K:/aQ: ${notelenprefix}${newtempo}" $1 > $tunedir/$newspeedfilename |
64 makeaudiofiles $builddir/$newspeedfilename --mute=0,-1 | 71 makeaudiofiles $tunedir/$newspeedfilename $tunedir --mute=0,-1 |
65 rm $builddir/$newspeedfilename | 72 rm $tunedir/$newspeedfilename |
66 } | 73 } |
67 | 74 |
68 # Generate audio files and slow speed (currently half speed) audio files. | 75 # Generate audio files and slow speed (currently half speed) audio files. |
69 find $booke -maxdepth 1 -name "*.abc" | sort | | 76 find $booke -maxdepth 1 -name "*.abc" | sort | |
70 while read filename | 77 while read filename |
71 do | 78 do |
72 makeaudiofiles $filename | 79 name=`basename $filename .abc` |
80 tunedir=$basetunedir/$name | |
81 mkdir -p $tunedir | |
82 | |
83 makeaudiofiles $filename $tunedir | |
73 | 84 |
74 # Now make 1/4, 1/2 and 3/4 speed audio. | 85 # Now make 1/4, 1/2 and 3/4 speed audio. |
75 makeaudiofortempo $filename "veryslow" 1 4 | 86 makeaudiofortempo $filename $tunedir "veryslow" 1 4 |
76 makeaudiofortempo $filename "slow" 2 4 | 87 makeaudiofortempo $filename $tunedir "slow" 2 4 |
77 makeaudiofortempo $filename "littleslow" 3 4 | 88 makeaudiofortempo $filename $tunedir "littleslow" 3 4 |
78 makeaudiofortempo $filename "normal" 4 4 | 89 makeaudiofortempo $filename $tunedir "normal" 4 4 |
79 done | 90 done |