Mercurial > dottes
annotate makeWebAudio.sh @ 748:ce5c7214f9aa
Introduce mechanism for having different tune images for compact printed output.
Sort alternate .abc in subdir 'Compact' under the booke dir. Use that as
the graphic for A5 output, assuming it will be vertically more compact.
Use Bear Dance as an example, as it has commentary that currently
overflows an A5 landscape page.
For the moment, transposed Bookes don't transpose and so don't use Compact.
author | Jim Hague <jim.hague@acm.org> |
---|---|
date | Fri, 13 Oct 2017 15:44:15 +0100 |
parents | cb7a4eff9d5b |
children | b83b49f2a0a0 |
rev | line source |
---|---|
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
1 #!/bin/bash |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
2 # |
223
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
197
diff
changeset
|
3 # Make audio required for the website but not for the book. |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
4 # They go into web/<book>. |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
5 # |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
6 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
7 if [ $# != 1 ]; then |
223
0ef955669a9a
Make transposed tunes use the original audio.
Jim Hague <jim.hague@acm.org>
parents:
197
diff
changeset
|
8 echo "Usage: makeWebAudio.sh <book dir name>" |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
9 exit 1 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
10 fi |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
11 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
12 dir=`pwd` |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
13 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
14 booke=$dir/$1 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
15 builddir=$dir/web/$1 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
16 |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
17 mkdir -p $builddir |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
18 |
400
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
399
diff
changeset
|
19 # Make MP3 and OGG files for the input .abc. Since we're listening to |
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
399
diff
changeset
|
20 # a doorbell playing the tunes, go for lowest quality (and hence smallest) |
567
cb7a4eff9d5b
Have learner tunes play only the melody.
Jim Hague <jim.hague@acm.org>
parents:
400
diff
changeset
|
21 # MP3 and OGG. $1 is the input filename, $2 is optional args for timidity. |
394
ae9c05d2aafd
Make slow speed web audio files.
Jim Hague <jim.hague@acm.org>
parents:
393
diff
changeset
|
22 makeaudiofiles() |
ae9c05d2aafd
Make slow speed web audio files.
Jim Hague <jim.hague@acm.org>
parents:
393
diff
changeset
|
23 { |
ae9c05d2aafd
Make slow speed web audio files.
Jim Hague <jim.hague@acm.org>
parents:
393
diff
changeset
|
24 name=`basename $1 .abc` |
ae9c05d2aafd
Make slow speed web audio files.
Jim Hague <jim.hague@acm.org>
parents:
393
diff
changeset
|
25 |
400
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
399
diff
changeset
|
26 abc2midi $1 -o $builddir/${name}.mid |
567
cb7a4eff9d5b
Have learner tunes play only the melody.
Jim Hague <jim.hague@acm.org>
parents:
400
diff
changeset
|
27 timidity -OwM $2 -o $builddir/${name}.wav $builddir/${name}.mid |
400
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
399
diff
changeset
|
28 lame -m m -V 9 --quiet $builddir/${name}.wav $builddir/${name}.mp3 |
394
ae9c05d2aafd
Make slow speed web audio files.
Jim Hague <jim.hague@acm.org>
parents:
393
diff
changeset
|
29 # Timidity can generate OGG directly. But we need to generate WAV |
ae9c05d2aafd
Make slow speed web audio files.
Jim Hague <jim.hague@acm.org>
parents:
393
diff
changeset
|
30 # for lame, and oggenc produces smaller output. OGG is needed for |
ae9c05d2aafd
Make slow speed web audio files.
Jim Hague <jim.hague@acm.org>
parents:
393
diff
changeset
|
31 # Firefox's audio tag. FF doesn't support MP3, some others support |
ae9c05d2aafd
Make slow speed web audio files.
Jim Hague <jim.hague@acm.org>
parents:
393
diff
changeset
|
32 # MP3 but not OGG. |
400
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
399
diff
changeset
|
33 oggenc -Q -q 0 -o $builddir/${name}.ogg $builddir/${name}.wav |
394
ae9c05d2aafd
Make slow speed web audio files.
Jim Hague <jim.hague@acm.org>
parents:
393
diff
changeset
|
34 |
400
f1c4abe4fc75
First go at adding the tune learner page.
Jim Hague <jim.hague@acm.org>
parents:
399
diff
changeset
|
35 rm $builddir/${name}.wav |
394
ae9c05d2aafd
Make slow speed web audio files.
Jim Hague <jim.hague@acm.org>
parents:
393
diff
changeset
|
36 } |
ae9c05d2aafd
Make slow speed web audio files.
Jim Hague <jim.hague@acm.org>
parents:
393
diff
changeset
|
37 |
399
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
38 # Make audio for a new tempo for the abc file $1, giving the output files |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
39 # the same name with a prefix $2. The new tempo is the original tempo |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
40 # (120 used if not specified), multiplied by $3 and divided by $4. |
567
cb7a4eff9d5b
Have learner tunes play only the melody.
Jim Hague <jim.hague@acm.org>
parents:
400
diff
changeset
|
41 # These audio files are for Learner use; I've found that having the |
cb7a4eff9d5b
Have learner tunes play only the melody.
Jim Hague <jim.hague@acm.org>
parents:
400
diff
changeset
|
42 # chords thumping away can make it hard to distinguish the melody, so |
cb7a4eff9d5b
Have learner tunes play only the melody.
Jim Hague <jim.hague@acm.org>
parents:
400
diff
changeset
|
43 # arrange for timidity to mute everything except the melody track. |
399
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
44 makeaudiofortempo() |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
45 { |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
46 name=`basename $filename .abc` |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
47 newspeedfilename="$2-${name}.abc" |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
48 |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
49 # Prepare new speed audio files. |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
50 # The tempo is either a plain number, or <notelen>=<number>. |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
51 tempo=`$dir/abcfield.py --field Q $1` |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
52 if [ -z $tempo ]; then |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
53 echo "Warning: $1 has no tempo. Using 120." |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
54 tempo="120" |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
55 fi |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
56 pos=`expr index $tempo '='` |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
57 numtempo=${tempo:pos} |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
58 notelenprefix=${tempo:0:pos} |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
59 # Calculate new tempo. |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
60 newtempo=$(( ( $numtempo * $3 ) / $4 )) |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
61 # Insert new tempo and delete old. Old may not exist, |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
62 # so do this rather than overwrite. |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
63 sed -e "/^Q:/d" -e "/^K:/aQ: ${notelenprefix}${newtempo}" $1 > $builddir/$newspeedfilename |
567
cb7a4eff9d5b
Have learner tunes play only the melody.
Jim Hague <jim.hague@acm.org>
parents:
400
diff
changeset
|
64 makeaudiofiles $builddir/$newspeedfilename --mute=0,-1 |
399
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
65 rm $builddir/$newspeedfilename |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
66 } |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
67 |
394
ae9c05d2aafd
Make slow speed web audio files.
Jim Hague <jim.hague@acm.org>
parents:
393
diff
changeset
|
68 # Generate audio files and slow speed (currently half speed) audio files. |
748
ce5c7214f9aa
Introduce mechanism for having different tune images for compact printed output.
Jim Hague <jim.hague@acm.org>
parents:
567
diff
changeset
|
69 find $booke -depth 1 -name "*.abc" | sort | |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
70 while read filename |
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
71 do |
394
ae9c05d2aafd
Make slow speed web audio files.
Jim Hague <jim.hague@acm.org>
parents:
393
diff
changeset
|
72 makeaudiofiles $filename |
ae9c05d2aafd
Make slow speed web audio files.
Jim Hague <jim.hague@acm.org>
parents:
393
diff
changeset
|
73 |
399
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
74 # Now make 1/4, 1/2 and 3/4 speed audio. |
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
75 makeaudiofortempo $filename "veryslow" 1 4 |
567
cb7a4eff9d5b
Have learner tunes play only the melody.
Jim Hague <jim.hague@acm.org>
parents:
400
diff
changeset
|
76 makeaudiofortempo $filename "slow" 2 4 |
399
aeef7b1ca0ad
Make 1/4, 1/2 and 3/4 speed audio for tunes.
Jim Hague <jim.hague@acm.org>
parents:
394
diff
changeset
|
77 makeaudiofortempo $filename "littleslow" 3 4 |
567
cb7a4eff9d5b
Have learner tunes play only the melody.
Jim Hague <jim.hague@acm.org>
parents:
400
diff
changeset
|
78 makeaudiofortempo $filename "normal" 4 4 |
43
d92717f8130c
First go at producing a very simple website.
Jim Hague <jim.hague@laicatc.com>
parents:
diff
changeset
|
79 done |