mumble-discord-bridge icon indicating copy to clipboard operation
mumble-discord-bridge copied to clipboard

Discord audio volume balancing

Open Stieneee opened this issue 3 years ago • 4 comments

Stieneee avatar Feb 03 '21 19:02 Stieneee

Do you have any ideas how this could be implemented? This is a feature I'd very much be interested in, but I'm not sure how it could be implemented... Would it be possible to have the mumble side create a puppet user for each discord user?

OpaqueReptile avatar Aug 29 '21 22:08 OpaqueReptile

Yes, multiple mumble connections would be possible.

I have been considering a solution in which we simply apply a gain to PCM audio data after the bridges decode the opus data before mixing. (Have a look at this diagram if you need additional context. https://github.com/Stieneee/mumble-discord-bridge/blob/main/docs/audio-flow.drawio.png) I did try applying a simple gain in the early days but it never seemed quite right. Ultimately I found that asking people to adjust their mic sensitivity in discord was a low-tech way of solving the problem.

I think both options have their pros and cons. The gain option is simpler but we would have to figure out an interface to adjust the volume per stream. (Maybe just a command interface through the chat).

The multiple mumble options would be interesting as you could then use mumbles local audio adjustment interface to control the volume. The trade-off with these options would be that you now have more stateful connections and buffer streams to manage.

If you want to take a stab at implementing either option I would be happy to provide feedback as you progress. Either option will certainly be a welcomed improvement.

Stieneee avatar Aug 31 '21 04:08 Stieneee

I think I'd prefer the multiple mumble connection/puppet user approach. It's more elegant from a UX standpoint and reduces likelihood of weird gain issues like you mentioned.

I've been trying to wrap my head around how the bridge is moving audio around and learning how the heck opus works. Your diagram was very helpful - I've recreated it with some modifications for how I think the bridge would work going with the multi-user option (additions in green):

mumble-discord-bridge_multiple_puppets

Will definitely take a stab at implementing this sometime soon.

OpaqueReptile avatar Aug 31 '21 19:08 OpaqueReptile

Ya, I think it is totally worth a shot. It will be really awesome to see who is connected to discord by looking at the mumble list.

I would definitely like to look into stereo audio at some point.

Learn about opus while working on this was certainly interesting. For this project, however, once you understand to decode and decode it additional knowledge is not really needed. If we are passing the opus data straight through we might be able to skip the opus decode/encode for audio flowing discord to mumble as the primary reason we needed to decode it was to mix the audio in PCM format.

As I think about the possible implementation some questions come up.

  • Currently, the user can specify a client cert for mumble authentication. I wonder if we can use the same cert for each puppet? What happens if the discord listener user or a puppet user is registered?
  • How far should we take the UI integration what happened if a mumble admin kicks or bans a puppet user?
  • The state logic around the listener and puppet connections.
  • If we can flow through. Do we still need the buffers are can we just forward on receive?

If you have any questions I will try to respond within 24 hours. Unfortunately, I am moving in a couple of weeks and backlogged with other work so I don't have a ton of time to work on improvements.

Good luck.

Stieneee avatar Sep 03 '21 04:09 Stieneee