diff --git a/lib/voice/VoiceConnection.js b/lib/voice/VoiceConnection.js index b2b004ac2..0787a29bd 100644 --- a/lib/voice/VoiceConnection.js +++ b/lib/voice/VoiceConnection.js @@ -276,7 +276,7 @@ class VoiceConnection extends EventEmitter { this.reconnecting = false; this.ready = true; // Send audio to properly establish the socket (e.g. for voice receive) - this.sendAudioFrame(SILENCE_FRAME); + this.sendAudioFrame(SILENCE_FRAME, this.frameSize); /** * Fired when the voice connection turns ready * @event VoiceConnection#ready @@ -638,9 +638,10 @@ class VoiceConnection extends EventEmitter { /** * Send a packet containing an Opus audio frame * @arg {Buffer} frame The Opus audio frame + * @arg {Number} [frameSize] The size (in samples) of the Opus audio frame */ - sendAudioFrame(frame) { - this.timestamp += this.current.options.frameSize; + sendAudioFrame(frame, frameSize = this.frameSize) { + this.timestamp += frameSize; if(this.timestamp >= 4294967295) { this.timestamp -= 4294967295; } @@ -711,7 +712,7 @@ class VoiceConnection extends EventEmitter { if(this.secret) { for(let i = 0; i < 5; i++) { - this.sendAudioFrame(SILENCE_FRAME); + this.sendAudioFrame(SILENCE_FRAME, this.frameSize); } } this.playing = false; @@ -805,7 +806,7 @@ class VoiceConnection extends EventEmitter { return this.stopPlaying(); } - this.sendAudioFrame(this.current.buffer); + this.sendAudioFrame(this.current.buffer, this.current.options.frameSize); this.current.playTime += this.current.options.frameDuration; this.current.timeout = setTimeout(this._send, this.current.startTime + this.current.pausedTime + this.current.playTime - Date.now()); }