-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStereoSoundXirus.plugin.js
64 lines (53 loc) · 1.6 KB
/
StereoSoundXirus.plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* @name SturdyStereo
* @version 0.0.1
* @author xirus
*/
class SturdyStereo {
_patcher = null;
constructor() {
this._patcher = null;
}
start() {
this._patcher = new Patcher(this);
this._patcher.applyPatch();
}
stop() {
if (this._patcher) {
this._patcher.revertPatch();
this._patcher = null;
}
}
}
class Patcher {
constructor(sturdyStereo) {
this.sturdyStereo = sturdyStereo;
this.webpack = BdApi.Webpack;
this.patcher = BdApi.Patcher;
this.voiceModule = this.webpack.getModule(this.webpack.Filters.byPrototypeFields("updateVideoQuality"));
}
applyPatch() {
this.patcher.after("SturdyStereo", this.voiceModule.prototype, "updateVideoQuality", (thisObj, _args, ret) => {
if (thisObj) {
thisObj.voiceBitrate = 384000;
thisObj.minimumJitterBufferLevel = 384000;
const setTransportOptions = thisObj.conn.setTransportOptions;
thisObj.conn.setTransportOptions = obj => {
if (obj.audioEncoder) {
obj.audioEncoder.params = { stereo: "1" };
obj.audioEncoder.channels = 2;
obj.audioEncoder.freq = 48000;
obj.audioEncoder.rate = 384000;
obj.audioEncoder.pacsize = 960;
}
obj.ducking = obj.idleJitterBufferFlush = obj.echoCancellation = obj.noiseSuppression = obj.automaticGainControl = obj.noiseCancellation = false;
setTransportOptions.call(thisObj, obj);
};
return ret;
}
});
}
revertPatch() {
this.patcher.unpatch("SturdyStereo", this.voiceModule.prototype, "updateVideoQuality");
}
}