Mercurial > dottes
comparison makeWebAudio.sh @ 567:cb7a4eff9d5b
Have learner tunes play only the melody.
Do this by telling timidity to mute all tracks but the first.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Tue, 06 Sep 2016 20:48:32 +0100 |
parents | f1c4abe4fc75 |
children | ce5c7214f9aa |
comparison
equal
deleted
inserted
replaced
566:912d53652d8d | 567:cb7a4eff9d5b |
---|---|
16 | 16 |
17 mkdir -p $builddir | 17 mkdir -p $builddir |
18 | 18 |
19 # Make MP3 and OGG files for the input .abc. Since we're listening to | 19 # 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) | 20 # a doorbell playing the tunes, go for lowest quality (and hence smallest) |
21 # MP3 and OGG. | 21 # MP3 and OGG. $1 is the input filename, $2 is optional args for timidity. |
22 makeaudiofiles() | 22 makeaudiofiles() |
23 { | 23 { |
24 name=`basename $1 .abc` | 24 name=`basename $1 .abc` |
25 | 25 |
26 abc2midi $1 -o $builddir/${name}.mid | 26 abc2midi $1 -o $builddir/${name}.mid |
27 timidity -OwM -o $builddir/${name}.wav $builddir/${name}.mid | 27 timidity -OwM $2 -o $builddir/${name}.wav $builddir/${name}.mid |
28 lame -m m -V 9 --quiet $builddir/${name}.wav $builddir/${name}.mp3 | 28 lame -m m -V 9 --quiet $builddir/${name}.wav $builddir/${name}.mp3 |
29 # Timidity can generate OGG directly. But we need to generate WAV | 29 # Timidity can generate OGG directly. But we need to generate WAV |
30 # for lame, and oggenc produces smaller output. OGG is needed for | 30 # for lame, and oggenc produces smaller output. OGG is needed for |
31 # Firefox's audio tag. FF doesn't support MP3, some others support | 31 # Firefox's audio tag. FF doesn't support MP3, some others support |
32 # MP3 but not OGG. | 32 # MP3 but not OGG. |
36 } | 36 } |
37 | 37 |
38 # Make audio for a new tempo for the abc file $1, giving the output files | 38 # Make audio for a new tempo for the abc file $1, giving the output files |
39 # the same name with a prefix $2. The new tempo is the original tempo | 39 # the same name with a prefix $2. The new tempo is the original tempo |
40 # (120 used if not specified), multiplied by $3 and divided by $4. | 40 # (120 used if not specified), multiplied by $3 and divided by $4. |
41 # These audio files are for Learner use; I've found that having the | |
42 # chords thumping away can make it hard to distinguish the melody, so | |
43 # arrange for timidity to mute everything except the melody track. | |
41 makeaudiofortempo() | 44 makeaudiofortempo() |
42 { | 45 { |
43 name=`basename $filename .abc` | 46 name=`basename $filename .abc` |
44 newspeedfilename="$2-${name}.abc" | 47 newspeedfilename="$2-${name}.abc" |
45 | 48 |
56 # Calculate new tempo. | 59 # Calculate new tempo. |
57 newtempo=$(( ( $numtempo * $3 ) / $4 )) | 60 newtempo=$(( ( $numtempo * $3 ) / $4 )) |
58 # Insert new tempo and delete old. Old may not exist, | 61 # Insert new tempo and delete old. Old may not exist, |
59 # so do this rather than overwrite. | 62 # so do this rather than overwrite. |
60 sed -e "/^Q:/d" -e "/^K:/aQ: ${notelenprefix}${newtempo}" $1 > $builddir/$newspeedfilename | 63 sed -e "/^Q:/d" -e "/^K:/aQ: ${notelenprefix}${newtempo}" $1 > $builddir/$newspeedfilename |
61 makeaudiofiles $builddir/$newspeedfilename | 64 makeaudiofiles $builddir/$newspeedfilename --mute=0,-1 |
62 rm $builddir/$newspeedfilename | 65 rm $builddir/$newspeedfilename |
63 } | 66 } |
64 | 67 |
65 # Generate audio files and slow speed (currently half speed) audio files. | 68 # Generate audio files and slow speed (currently half speed) audio files. |
66 find $booke -name "*.abc" | sort | | 69 find $booke -name "*.abc" | sort | |
68 do | 71 do |
69 makeaudiofiles $filename | 72 makeaudiofiles $filename |
70 | 73 |
71 # Now make 1/4, 1/2 and 3/4 speed audio. | 74 # Now make 1/4, 1/2 and 3/4 speed audio. |
72 makeaudiofortempo $filename "veryslow" 1 4 | 75 makeaudiofortempo $filename "veryslow" 1 4 |
73 makeaudiofortempo $filename "slow" 1 2 | 76 makeaudiofortempo $filename "slow" 2 4 |
74 makeaudiofortempo $filename "littleslow" 3 4 | 77 makeaudiofortempo $filename "littleslow" 3 4 |
78 makeaudiofortempo $filename "normal" 4 4 | |
75 done | 79 done |