Created
May 6, 2012 03:39
-
-
Save jlank/2609217 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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