philhk / Vencord

The cutest Discord client mod
GNU General Public License v3.0
58 stars 24 forks source link

Enable audio bitrate to reach a maximum of 512 kbps #11

Closed ucjd closed 11 months ago

ucjd commented 11 months ago

Discord Account

hisyageru

What happens when the bug or crash occurs?

bad bitrate = bad review 💀

What is the expected behaviour?

the stereo not sounding horrible

How do you recreate this bug or crash?

  1. turn on bettermicrophone
  2. join a call 3.there you go! shitty sereo.

Errors

stereo bitrate is the erorr u better fix that pal

Request Agreement

philhk commented 11 months ago

It's barely even noticeable, and I'm not sure if Discord supports such a high bitrate. By 'supports,' I mean that Discord likely denies incoming packets after a certain amount of data per second, and 512 kbps could be too high. You are already sending 640 kbps with a bitrate of 320 kbps when using stereo because it's sending the bits per channel. But sure I can still update it maybe I'm wrong.

philhk commented 11 months ago

Added in commit 7b91e60.

ucjd commented 11 months ago

it still sounds weird, im not gonna lie, i can show u the betterdiscord plugin for stereo and it sounds way different, i dont know why but here, "/**

@else@*/

module.exports = (() => { const config = {"main":"index.js","info":{"name":"StereoSound","authors":[{"name":"bep","discord_id":"147077474222604288","github_username":"bepvte"}],"authorLink":"https://github.com/bepvte","version":"0.0.6","description":"Adds stereo sound to your own microphone's output. Requires a capable stereo microphone.","github":"https://github.com/bepvte/bd-addons","github_raw":"https://raw.githubusercontent.com/bepvte/bd-addons/main/plugins/StereoSound.plugin.js"},"changelog":[{"title":"Changes","items":["Adjusted warning toast behavior"]}],"defaultConfig":[{"type":"switch","id":"enableToasts","name":"Enable Toasts","note":"Allows the plugin to let you know it is working, and also warn you about voice settings","value":true}]};

return !global.ZeresPluginLibrary ? class {
    constructor() {this._config = config;}
    getName() {return config.info.name;}
    getAuthor() {return config.info.authors.map(a => a.name).join(", ");}
    getDescription() {return config.info.description;}
    getVersion() {return config.info.version;}
    load() {
        BdApi.showConfirmationModal("Library Missing", `The library plugin needed for ${config.info.name} is missing. Please click Download Now to install it.`, {
            confirmText: "Download Now",
            cancelText: "Cancel",
            onConfirm: () => {
                require("request").get("https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js", async (error, response, body) => {
                    if (error) return require("electron").shell.openExternal("https://betterdiscord.net/ghdl?url=https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js");
                    await new Promise(r => require("fs").writeFile(require("path").join(BdApi.Plugins.folder, "0PluginLibrary.plugin.js"), body, r));
                });
            }
        });
    }
    start() {}
    stop() {}
} : (([Plugin, Api]) => {
    const plugin = (Plugin, Library) => {

const { WebpackModules, Patcher, Toasts } = Library;

return class StereoSound extends Plugin { onStart() { this.settingsWarning(); const voiceModule = WebpackModules.getByPrototypes("updateVideoQuality"); Patcher.after(voiceModule.prototype, "updateVideoQuality", this.replacement.bind(this)); } settingsWarning() { const voiceSettingsStore = WebpackModules.getByProps("getEchoCancellation"); if ( voiceSettingsStore.getNoiseSuppression() || voiceSettingsStore.getNoiseCancellation() || voiceSettingsStore.getEchoCancellation() ) { if (this.settings.enableToasts) { Toasts.show( "Please disable echo cancellation, noise reduction, and noise suppression for StereoSound", { type: "warning", timeout: 5000 } ); } // This would not work, noise reduction would be stuck to on // const voiceSettings = WebpackModules.getByProps("setNoiseSuppression"); // 2nd arg is for analytics // voiceSettings.setNoiseSuppression(false, {}); // voiceSettings.setEchoCancellation(false, {}); // voiceSettings.setNoiseCancellation(false, {}); return true; } else return false; } replacement(thisObj, _args, ret) { const setTransportOptions = thisObj.conn.setTransportOptions; thisObj.conn.setTransportOptions = function (obj) { if (obj.audioEncoder) { obj.audioEncoder.params = { stereo: "2", }; obj.audioEncoder.channels = 2; } if (obj.fec) { obj.fec = false; } if (obj.encodingVoiceBitRate < 512000 ) { //128 obj.encodingVoiceBitRate = 512000 }

    setTransportOptions.call(thisObj, obj);
  };
  if (!this.settingsWarning()) {
    if (this.settings.enableToasts) {
      Toasts.info("Stereo calling enabled");
    }
  }
  return ret;
}
onStop() {
  Patcher.unpatchAll();
}
getSettingsPanel() {
  const panel = this.buildSettingsPanel();
  return panel.getElement();
}

}; }; return plugin(Plugin, Api); })(global.ZeresPluginLibrary.buildPlugin(config)); })();

/@end@/" i literally dont know whats wrong with ur stereo but u can use this one as an example.