-
Notifications
You must be signed in to change notification settings - Fork 7
/
start.js
65 lines (57 loc) · 1.22 KB
/
start.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
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
var spawn = require("child_process").spawn;
var chuckApp = "Looper/looper-class.ck";
var nodeApp = "Controller/app.js";
var buffer = 2048;
var priorities = {
jackd: "-10",
chuck: "-15",
node: "15"
};
var options = {
jackd: [
"-r",
"-P80",
"-p8",
"-dalsa",
// "-dhw:1,0",
"-i1",
"-o2",
"-n3",
"-r44100",
("-p" + buffer),
"-s",
"-S",
"-znone"
],
node: [
__dirname + "/" + nodeApp
],
chuck: [
("--adaptive" + buffer),
// ("--bufsize" + buffer)
"--srate44100",
"--in1",
__dirname + "/" + chuckApp
]
};
var niceSpawn = function(priority, args) {
var spawnArgs = [ "-n", priority ].concat(args);
var spawned = spawn("nice", spawnArgs);
[ "stdout", "stderr" ].forEach(function(key) {
spawned[key].on("data", function(data) {
console.log(data.toString());
});
});
};
// start jack
niceSpawn(priorities.jackd, [ "jackd" ].concat(options.jackd));
// start chuck and controller after timeout
setTimeout(function() {
niceSpawn(priorities.node, [ "node" ].concat(options.node));
niceSpawn(priorities.chuck, [ "chuck" ].concat(options.chuck));
}, 4000);
process.on("SIGINT", function() {
// force kill if didn't exit clearly
spawn("killall", [ "jackd", "chuck" ]);
process.exit();
});