SpacingBat3 / WebCord

A Discord and SpaceBar :electron:-based client implemented without Discord API.
MIT License
1.88k stars 93 forks source link

Stereo mic support #471

Open IDeathByte opened 11 months ago

IDeathByte commented 11 months ago

Description

It possible to add some injection code or change connection settings for support stereo input devices? In native client we can do one workaround step for enable support https://support.discord.com/hc/en-us/community/posts/360050373871/comments/17341738272791

Edit ~/.config/discord/0.0.*/modules/discord_voice/index.js and find setTransportOptions in the bindConnectionInstance function. Replace the entire line with this:

setTransportOptions: (options) => {
      if(options.audioEncoder)
      {
        options.audioEncoder.params = { channels: 2, };
        options.audioEncoder.channels = 2;
        options.audioEncoder.freq = 48000;
        options.audioEncoder.rate = 384000;
        options.audioEncoder.pacsize = 20;
      }
      if(options.encodingVoiceBitRate) options.encodingVoiceBitRate = 256000;
      return instance.setTransportOptions(options);
    },
SpacingBat3 commented 10 months ago

WebCord works more closely to browsers in terms of audio or screen sharing than to actual Discord client – so tricks that work on Discord internal modules won't work on WebCord. Also, technically is is possible to use screen share audio for stereo mic right now, but I highly doubt that's desired to happen. It might also not be possible to implement the stereo microphone at all if Discord is processing the audio differently for browser clients or due to WebRTC implementation between browsers and Discord, although I haven't took any look if it isn't actually possible to tweak Discord's microphone input via getUserMedia to use stereo input as I suppose they might be using this API for audio input. But I haven't took any deep look into Discord internals, at least for a while, so I dunno much about the actual implementation yet.