forked from txbyw/tobys-audio-expert
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
89 lines (75 loc) · 3.97 KB
/
index.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const {
Plugin
} = require('powercord/entities');
const {
getModule
} = require('powercord/webpack');
const Settings = require('./components/Settings.jsx');
module.exports = class StereoCord extends Plugin {
startPlugin() {
powercord.api.settings.registerSettings('tobys-audio-expert', {
category: this.entityID,
label: 'Tobys Audio Expert',
render: Settings
});
var isStereoModeEnabled = this.settings.get('useStereoMode');
var microphoneBitrateSetting = this.settings.get('microphoneBitrateChanger');
if(microphoneBitrateSetting === undefined) { this.props.updateSetting('microphoneBitrateChanger', 256000)}
this.runTheAudioExpert(isStereoModeEnabled, microphoneBitrateSetting);
}
runTheAudioExpert(isStereoModeEnabled, microphoneBitrateSetting) {
console.log("Stereo Mode: " + isStereoModeEnabled);
console.log("Microphone Bitrate: " + microphoneBitrateSetting);
((i) => {
window.webpackJsonp.push([
[i], {
[i]: (n, b, d) => {
for (let key in d.c) {
if (d.c[key].exports) {
const module = d.c[key].exports.default || d.c[key].exports;
if (typeof(module) === 'function' && 'prototype' in module) {
const descriptors = Object.getOwnPropertyDescriptors(module.prototype);
if ('setSelfDeaf' in descriptors) {
const initialize = module.prototype.initialize;
module.prototype.initialize = function() {
initialize.call(this, ...arguments);
const setTransportOptions = this.conn.setTransportOptions;
this.conn.setTransportOptions = function(obj) {
if (obj.audioEncoder) {
if (isStereoModeEnabled) {
obj.audioEncoder.params = {
stereo: '2'
};
obj.audioEncoder.channels = 2;
} else {
obj.audioEncoder.params = {
stereo: '1'
};
obj.audioEncoder.channels = 1;
}
}
if (obj.fec) {
obj.fec = false;
}
if (obj.encodingVoiceBitRate < microphoneBitrateSetting) {
obj.encodingVoiceBitRate = microphoneBitrateSetting;
}
setTransportOptions.call(this, obj);
}
}
}
}
}
}
},
},
[
[i],
],
]);
})(Math.random());
}
pluginWillUnload() {
getModule(['getVoiceEngine'], false).getVoiceEngine().VoiceConnection = this.VoiceConnection;
}
};