-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild
executable file
·76 lines (71 loc) · 2.65 KB
/
build
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
#!/usr/bin/env ruby
repo_dir = File.expand_path(File.dirname(__FILE__))
Dir.chdir(repo_dir)
def verbose(command)
puts "--> #{command}"
system(command) or raise("Failed: #{command}")
end
verbose('jslint --indent 2 --sloppy --stupid --evil reverb.js')
verbose('uglifyjs reverb.js --compress > reverb.min.js')
demo = File.read('index.html')
generated = "<!--BEGIN GENERATED-->\n"
Dir.glob('Library/*.m4a') {|file|
next if file.start_with?('Library/Sample')
url = 'http://reverbjs.org/' + file
name = File.basename(file, File.extname(file))
description = File.read('Library/' + name + '.attribution.txt')
x = ''
x += "<h2>#{name} "
x += '<a href="javascript:testReverb('
x += "'#{url}', 'scale'"
x += ');">'
x += "(synth)"
x += "</a> "
x += '<a href="javascript:testReverb('
x += "'#{url}', 'piece'"
x += ');">'
x += "(piano)"
x += "</a> "
x += '<a href="javascript:testReverb('
x += "'#{url}', 'stop'"
x += ');">'
x += "(stop)"
x += "</a>"
x += "</h2>\n"
x += "<h3>Attribution</h3>"
x += "<p>"
x += description.gsub("\n", "<br/>") + "\n"
x += "</p>\n"
x += "<h3>Usage</h3>\n"
x += "<pre><code>"
x += '<script src="http://reverbjs.org/reverb.js"></script>' + "\n"
x += '<script>' + "\n"
x += '// 1) Setup your audio context (once) and extend with Reverb.js.' + "\n"
x += 'var audioContext = new (window.AudioContext || window.webkitAudioContext)();' + "\n"
x += 'reverbjs.extend(audioContext);' + "\n"
x += '' + "\n"
x += '// 2) Load the impulse response; upon load, connect it to the audio output.' + "\n"
x += 'var reverbUrl = "' + url + '";' + "\n"
x += 'var reverbNode = audioContext.createReverbFromUrl(reverbUrl, function() {' + "\n"
x += ' reverbNode.connect(audioContext.destination);' + "\n"
x += '});' + "\n"
x += '' + "\n"
x += '// 3) Load a test sound; upon load, connect it to the reverb node.' + "\n"
x += 'var sourceUrl = "http://reverbjs.org/Library/SampleBachCMinorPrelude.m4a";' + "\n"
x += 'var sourceNode = audioContext.createSourceFromUrl(sourceUrl, function() {' + "\n"
x += ' sourceNode.connect(reverbNode);' + "\n"
x += '});' + "\n"
x += '</script>' + "\n"
x += '<a href="javascript:sourceNode.start()">Test</a>' + "\n"
x += "</code></pre>\n"
generated += x
}
generated += "<!--END GENERATED-->"
reverbjs = "<!--BEGIN REVERBJS-->\n"
reverbjs += "<script type=\"text/javascript\">\n"
reverbjs += File.read('reverb.js')
reverbjs += "</script>"
reverbjs += "<!--END REVERBJS-->"
demo = demo.gsub(/[<].--BEGIN GENERATED.*END GENERATED--[>]/m) {generated}
demo = demo.gsub(/[<].--BEGIN REVERBJS.*END REVERBJS--[>]/m) {reverbjs}
File.write('index.html', demo)