forked from andrewrk/node-waveform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (29 loc) · 773 Bytes
/
index.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
var path = require('path');
var execFile = require('child_process').execFile;
var waveformBin = path.resolve(__dirname, "build", "Release", "waveform");
var flagNames = {
'scan': true,
'wjs-plain': true,
};
module.exports = function(audiofile, options, callback) {
var cmdline = [audiofile];
for (var optName in options) {
if (flagNames[optName]) {
cmdline.push('--' + optName);
} else {
var value = options[optName];
cmdline.push('--' + optName);
cmdline.push(value);
}
}
execFile(waveformBin, cmdline, function(err, stdout, stderr) {
if (err) {
err.stdout = stdout;
err.stderr = stderr;
err.stack += new Error().stack;
callback(err);
} else {
callback(null, stdout);
}
});
};