mirror of
https://github.com/danbulant/discord.js
synced 2026-06-23 00:31:52 +00:00
Add ability to disable volume transform
This commit is contained in:
parent
6490d1b911
commit
3696b4a810
2 changed files with 7 additions and 2 deletions
|
|
@ -432,7 +432,8 @@ class VoiceConnection extends EventEmitter {
|
|||
* Options that can be passed to stream-playing methods:
|
||||
* @typedef {Object} StreamOptions
|
||||
* @property {number} [seek=0] The time to seek to
|
||||
* @property {number} [volume=1] The volume to play at
|
||||
* @property {number|boolean} [volume=1] The volume to play at. Set this to false to disable volume transforms for
|
||||
* this stream to improve performance.
|
||||
* @property {number} [passes=1] How many times to send the voice packet to reduce packet loss
|
||||
* @property {number} [plp] Expected packet loss percentage
|
||||
* @property {boolean} [fec] Enabled forward error correction
|
||||
|
|
|
|||
|
|
@ -55,8 +55,12 @@ class AudioPlayer extends EventEmitter {
|
|||
|
||||
playPCMStream(stream, options, streams = {}) {
|
||||
this.destroyDispatcher();
|
||||
const volume = streams.volume = new prism.VolumeTransformer16LE(null, { volume: 0.2 });
|
||||
const opus = streams.opus = new prism.opus.Encoder({ channels: 2, rate: 48000, frameSize: 960 });
|
||||
if (options && options.volume === false) {
|
||||
stream.pipe(opus);
|
||||
return this.playOpusStream(opus, options, streams);
|
||||
}
|
||||
const volume = streams.volume = new prism.VolumeTransformer16LE(null, { volume: options ? options.volume : 1 });
|
||||
stream.pipe(volume).pipe(opus);
|
||||
return this.playOpusStream(opus, options, streams);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue