/
test02.js
32 lines (23 loc) · 851 Bytes
/
test02.js
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
// tests proper destruction/absence of leaks when there's unreferenced sound objects that are still play()ing.
function noise (v,i,o) {
o[i]= Math.floor(256*Math.random());
}
function saw (v,i,o) {
o[i]= i%256;
}
var buffers= [];
var i= 50;
while (i--) {
var buf= new Buffer(4096+ 4*Math.floor(1024*Math.random()));
[].forEach.call(buf, i%2 ? noise : saw);
buffers.push(buf);
}
var Sound= require('./build/default/sound');
(function loop () {
process.nextTick(loop);
Sound.create(buffers[Math.floor(buffers.length*Math.random())]).loop(2).play();
Sound.create(buffers[Math.floor(buffers.length*Math.random())]).loop(2).play();
Sound.create(buffers[Math.floor(buffers.length*Math.random())]).loop(2).play();
Sound.create(buffers[Math.floor(buffers.length*Math.random())]).loop(2).play();
process.stdout.write('.');
})();