Skip to content

Instantly share code, notes, and snippets.

@jlank
Created May 6, 2012 03:39
Show Gist options
  • Save jlank/2609217 to your computer and use it in GitHub Desktop.
Save jlank/2609217 to your computer and use it in GitHub Desktop.
var spawn = require('child_process').spawn,
temp = require('temp');
Audio.prototype.slowDown = function rb(options, input, cb) {
var speed = options.speed,
s = (this.isNumeric(speed) ? Math.pow(speed, -1) :
this.error('speed needs a number')),
slow = null;
console.log('if this prints it will work');
temp.open('rbIN', function (err, infile) {
if (err) {
return cb(err, null);
}
input.pipe(fs.createWriteStream(infile.path));
input.on('end', function (data) {
temp.open('rbOUT', function (err, outfile) {
if (err) {
return cb(err, null);
}
slow = spawn('rubberband', ['-t', s, infile.path, outfile.path]);
slow.on('exit', function (code) {
if (code) {
return cb('error, exit code: ' + code, null);
}
if (!code) {
console.log('successful write out to: ' + outfile.path);
//return cb(null, fs.createReadStream(outfile.path));
}
});
});
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment