Added stereo support

This commit is contained in:
Amish Shah
2015-12-05 21:19:38 +00:00
parent d122184b6b
commit e16211c4fb
7 changed files with 167 additions and 35 deletions

View File

@@ -103,6 +103,7 @@ var VoiceConnection = (function (_EventEmitter) {
};
VoiceConnection.prototype.playStream = function playStream(stream) {
var channels = arguments.length <= 1 || arguments[1] === undefined ? 2 : arguments[1];
var self = this;
@@ -130,7 +131,7 @@ var VoiceConnection = (function (_EventEmitter) {
}
try {
var buffer = stream.read(1920);
var buffer = stream.read(1920 * channels);
if (!buffer) {
if (onWarning) {
@@ -145,8 +146,8 @@ var VoiceConnection = (function (_EventEmitter) {
}
}
if (buffer.length !== 1920) {
var newBuffer = new Buffer(1920).fill(0);
if (buffer.length !== 1920 * channels) {
var newBuffer = new Buffer(1920 * channels).fill(0);
buffer.copy(newBuffer);
buffer = newBuffer;
}
@@ -238,7 +239,7 @@ var VoiceConnection = (function (_EventEmitter) {
return new Promise(function (resolve, reject) {
_this.encoder.encodeFile(stream)["catch"](error).then(function (data) {
self.streamProc = data.proc;
var intent = self.playStream(data.stream);
var intent = self.playStream(data.stream, 2);
resolve(intent);
callback(null, intent);
});