-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patherr_01.js
More file actions
35 lines (26 loc) · 747 Bytes
/
err_01.js
File metadata and controls
35 lines (26 loc) · 747 Bytes
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
// exercise callbacks;
var Sound;
var paths= ['./build/default/sound', './build/release/sound', 'sound'];
while (paths.length) {
var p= paths.pop();
try { Sound= require(p) } catch (e) { continue }
console.log("Módulo de sonido encontrado en: '"+ p+ "'");
break;
}
var quit= setTimeout(Date.now, 1e9); // don't quit
var howMany= 9999;
function cb () {
process.stdout.write('\ncb['+ this.id+ ']');
}
var buffer= new Buffer(44100);
var i= buffer.length;
while (i--) buffer[i]= Math.floor(256*Math.random());
var i= howMany;
function next () {
var snd= Sound.create(buffer);
process.stdout.write('\n['+ snd.id+ '].play(cb)');
snd.play(cb);
snd= null;
if (--i) setTimeout(next, Math.floor(1000*Math.random()));
};
next();