forked from OpenRCT2/OpenMusic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeninja.sh
executable file
·171 lines (137 loc) · 5.89 KB
/
geninja.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/env bash
source musictools/config.sh
ADDEDSONGS=""
BASEDIR=$(pwd)
mkdir -p $RELEASEDIR
mkdir -p $SONGNAMEDIR/fairground_style
mkdir -p $SONGNAMEDIR/other_styles
mkdir -p $OUTDIR/midiprepare
cat > build.ninja << _EOF_
builddir=$OUTDIR
OUTDIR=$OUTDIR
RELEASEDIR=$RELEASEDIR
SONGNAMEDIR=$SONGNAMEDIR
SOUNDFONTSDIR=$SOUNDFONTSDIR
BASEDIR=$BASEDIR
GENINDEX_DIR=musictools/genindex
SAMPLING_RATE=$SAMPLING_RATE
NORMALIZE_GAIN=$NORMALIZE_GAIN
PREPARE_PARAMS_ORGAN=-s -f 19 -t 0 -f 16 -t 1 -f 20 -t 2 -f 18 -t 3 -n
PREPARE_PARAMS_GLOCKENSPIEL=-s -f 11 -t 8 -n
PREPARE_PARAMS_MAP_PERCUSSION=-m 48
PREPARE_PARAMS_PERCUSSION=-s -p \$PREPARE_PARAMS_MAP_PERCUSSION -n
SOUNDFONT_ORGAN="$SOUNDFONTSDIR/$SOUNDFONT_ORGAN"
SOUNDFONT_GENERALUSER="$SOUNDFONTSDIR/$SOUNDFONT_GENERALUSER"
SOUNDFONT_FLUIDR3="$SOUNDFONTSDIR/$SOUNDFONT_FLUIDR3"
SOUNDFONT_K18="$SOUNDFONTSDIR/$SOUNDFONT_K18"
CALF_REVERB_PLUGIN="$CALF_REVERB_PLUGIN"
DEFAULT_FLUIDSYNTH_GAIN=0.5
rule midi_pdf
command = lilypond -dno-point-and-click -ddelete-intermediate-files --pdf \$\$filename \$main_file && mv \$\$(basename -s .ly \$main_file).pdf \$OUTDIR/release && mv \$\$(basename -s .ly \$main_file).midi \$OUTDIR
rule cmake
command = cmake -B\$\$(dirname \$out) -H\$in && cd \$\$(dirname \$out) && make
rule midiprepare
command = \$OUTDIR/midiprepare/midiprepare \$split_params -v -o \$out \$in
rule render
command = fluidsynth -nli -r \$SAMPLING_RATE -R 0 -T wav -F \$out -g \$DEFAULT_FLUIDSYNTH_GAIN \$soundfont \$in
rule combine
command = sox --show-progress --combine mix \$in --comment "" \$out
rule convert
command = sox --show-progress \$in --comment "" \$out
rule apply_lv2
command = lv2file -i \$in -o \$out \$plugin_options \$plugin
rule normalize
command = sox --show-progress \$in --comment "" \$out gain -n \$NORMALIZE_GAIN
rule spectrogram
command = sox \$in -n spectrogram -x 1920 -y 513 -z 100 -o \$out -t \$\$(basename -s .flac \$in) -c OpenRCT2-OpenMusic
rule copy
command = cp \$in \$out
rule render_opus
command = opusenc \$in \$out
rule write_song_name
command = touch \$out
rule generate_index
command = cd \$RELEASEDIR && cp \$BASEDIR/\$GENINDEX_DIR/style.css . && \$BASEDIR/\$GENINDEX_DIR/genindex.sh \$BASEDIR
rule dependency_graph
command = ninja -t graph | dot -Tsvg -o\$out
build \$OUTDIR/midiprepare/midiprepare: cmake musictools/midiprepare || musictools/midiprepare/main.c
build \$RELEASEDIR/depgraph.svg: dependency_graph
build \$RELEASEDIR/acknowledgements.txt: copy $BASEDIR/acknowledgements.txt
build \$RELEASEDIR/copying.txt: copy $BASEDIR/COPYING
_EOF_
for song in ${ORGAN_SONGS[*]}; do
SONGFILES=""
for file in fairground_style/${song}/*ly; do
SONGFILES="${SONGFILES}$file "
done
cat >> build.ninja << _EOF_
build \$OUTDIR/${song}.midi \$RELEASEDIR/${song}.pdf: midi_pdf ${SONGFILES}
main_file=fairground_style/${song}/${song}.ly
build \$OUTDIR/${song}_organ.mid: midiprepare \$OUTDIR/${song}.midi || \$OUTDIR/midiprepare/midiprepare
split_params=\$PREPARE_PARAMS_ORGAN
build \$OUTDIR/${song}_glockenspiel.mid: midiprepare \$OUTDIR/${song}.midi || \$OUTDIR/midiprepare/midiprepare
split_params=\$PREPARE_PARAMS_GLOCKENSPIEL
build \$OUTDIR/${song}_percussion.mid: midiprepare \$OUTDIR/${song}.midi || \$OUTDIR/midiprepare/midiprepare
split_params=\$PREPARE_PARAMS_PERCUSSION
build \$OUTDIR/${song}_organ.wav: render \$OUTDIR/${song}_organ.mid
soundfont=\$SOUNDFONT_ORGAN
DEFAULT_FLUIDSYNTH_GAIN=0.45
build \$OUTDIR/${song}_glockenspiel.wav: render \$OUTDIR/${song}_glockenspiel.mid
soundfont=\$SOUNDFONT_FLUIDR3
DEFAULT_FLUIDSYNTH_GAIN=0.35
build \$OUTDIR/${song}_percussion.wav: render \$OUTDIR/${song}_percussion.mid
soundfont=\$SOUNDFONT_GENERALUSER
DEFAULT_FLUIDSYNTH_GAIN=0.45
build \$OUTDIR/${song}.wav: combine \$OUTDIR/${song}_organ.wav \$OUTDIR/${song}_glockenspiel.wav \$OUTDIR/${song}_percussion.wav
build \$OUTDIR/${song}_reverb.wav: apply_lv2 \$OUTDIR/${song}.wav
plugin=\$CALF_REVERB_PLUGIN
plugin_options=-p decay_time:$REVERB_DECAY
build \$OUTDIR/${song}.flac: normalize \$OUTDIR/${song}_reverb.wav
build \$RELEASEDIR/${song}.opus: render_opus \$OUTDIR/${song}.flac
build \$RELEASEDIR/${song}.png: spectrogram \$OUTDIR/${song}.flac
build \$SONGNAMEDIR/fairground_style/${song}: write_song_name || \$OUTDIR/${song}.flac
_EOF_
if [ "$RELEASE_FLAC" != "0" ];
then
cat >> build.ninja << _EOF_
build \$RELEASEDIR/${song}.flac: copy \$OUTDIR/${song}.flac
_EOF_
fi
ADDEDSONGS="${ADDEDSONGS}$SONGNAMEDIR/fairground_style/$song $RELEASEDIR/${song}.opus "
done
for song in ${OTHER_SONGS[*]}; do
SONGFILES=""
for file in other_styles/${song}/*ly; do
SONGFILES="${SONGFILES}$file "
done
SOUNDFONT="SOUNDFONT_GENERALUSER"
if [ "$song" == "ragtime" ]
then
SOUNDFONT="SOUNDFONT_K18"
fi
cat >> build.ninja << _EOF_
build \$OUTDIR/${song}.midi \$RELEASEDIR/${song}.pdf: midi_pdf ${SONGFILES}
main_file=other_styles/${song}/${song}.ly
build \$OUTDIR/${song}_postprepare.mid: midiprepare \$OUTDIR/${song}.midi || \$OUTDIR/midiprepare/midiprepare
split_params=\$PREPARE_PARAMS_MAP_PERCUSSION
build \$OUTDIR/${song}.wav: render \$OUTDIR/${song}_postprepare.mid
soundfont=\$$SOUNDFONT
build \$OUTDIR/${song}_reverb.wav: apply_lv2 \$OUTDIR/${song}.wav
plugin=\$CALF_REVERB_PLUGIN
plugin_options=-p decay_time:$REVERB_DECAY
build \$OUTDIR/${song}.flac: normalize \$OUTDIR/${song}_reverb.wav
build \$RELEASEDIR/${song}.opus: render_opus \$OUTDIR/${song}.flac
build \$RELEASEDIR/${song}.png: spectrogram \$OUTDIR/${song}.flac
build \$SONGNAMEDIR/other_styles/${song}: write_song_name || \$OUTDIR/${song}.flac
_EOF_
if [ "$RELEASE_FLAC" != "0" ];
then
cat >> build.ninja << _EOF_
build \$RELEASEDIR/${song}.flac: copy \$OUTDIR/${song}.flac
_EOF_
fi
ADDEDSONGS="${ADDEDSONGS}$SONGNAMEDIR/other_styles/$song $RELEASEDIR/${song}.opus "
done
cat >> build.ninja << _EOF_
build \$RELEASEDIR/index.html: generate_index $ADDEDSONGS \$GENINDEX_DIR/style.css \$GENINDEX_DIR/genindex.sh
_EOF_