Stieneee / mumble-discord-bridge

A simple voice bridge between Mumble and Discord.
MIT License
153 stars 16 forks source link

Discord audio volume balancing #10

Open Stieneee opened 3 years ago

OpaqueReptile commented 3 years ago

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?

Stieneee commented 3 years ago

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.

OpaqueReptile commented 3 years ago

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.

Stieneee commented 3 years ago

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.

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.