TTT2 icon indicating copy to clipboard operation
TTT2 copied to clipboard

Proximity Voice Chat Enhancements

Open ruby0b opened this issue 1 year ago • 11 comments

Planning to implement most of these myself as mentioned on the Discord, just putting a cleaned up list here to keep track / discuss:

Server-side:

  • [x] Using regular voice chat for everyone during the preparing phase: #1490
  • [x] Maximum voice chat range cutoff: #1503

Client-side:

  • [x] Voice chat toggle keybinding (upstreaming https://github.com/ruby0b/ttt2-voice-chat-toggle): #1506
  • [ ] Hiding voice chat panels (with a setting to hide them only for players that you hear through proximity voice chat. Will require clients to receive the information that a voice is heard locationally)

ruby0b avatar Mar 29 '24 22:03 ruby0b

Nice to see you working on that. Together with my UI rework, the 0.14.0 update will feature quite a lot of voice chat improvements!

TimGoll avatar Mar 30 '24 15:03 TimGoll

Voice chat toggle keybinding (upstreaming https://github.com/ruby0b/ttt2-voice-chat-toggle)

What's the general consensus on this? Should this really be a secondary keybind? Or a setting in the client voice setting where you can switch between different modes like "push to talk", "push to mute", "toggle" and "voice activation"?

IMHO we don't need a new keybind for this. It could use the already existing one. We should also make sure that the global voicechat is automatically muted as soon as the team voice chat is engaged.

TimGoll avatar Apr 06 '24 11:04 TimGoll

I agree that it's probably unnecessary to introduce another keybind, we should just use a dropdown for the different options. Toggle and voice activation would be the same thing though because as far as I can tell the voice chat always uses some built-in threshold, right?

I found it a bit difficult to wrap my head around how team chat should work when using anything other than push-to-talk, so I made some diagrams. I guess for toggle it would be like this (G = global voice chat key, T = team voice chat key): image

Push to mute seems a little more confusing since pressing the key is supposed to mute you. But I guess it could work like this, where you switch voice chat by pressing and then releasing the key: image

ruby0b avatar Apr 06 '24 13:04 ruby0b

as far as I can tell the voice chat always uses some built-in threshold, right?

Yes, but you still have to press a key to start talking. I'd like to add an option to use voice without. Maybe it doesn't work like I thought, then I'll scrap that idea.

About your other question: I thought these fancy voice modes are only relevant for global voice chat. I think team voice can always be push to talk, this would make it so much simpler. No matter what mode you are in, as soon as the team chat key is pressed, the global voice is muted.

TimGoll avatar Apr 06 '24 13:04 TimGoll

Makes sense, there's probably no reason to use anything other than push-to-talk for team voice. Would releasing the team voice key always put you back to being muted or would it be "smart" and put you back into the global voice state you had previously? (The former would probably be simpler to implement)

About having to press the toggle to start talking: I think you essentially want the game to automatically press the toggle bind once whenever you join, right? So something like this line that I'm using in my addon:

hook.Add("InitPostEntity", "voice_toggle/AutoEnableVoiceChat",
        function() if cv_auto_enable:GetBool() then voice_enable() end end)

I would probably call that mode "Toggle (on by default)" or something like that (and maybe call the regular toggle "Toggle (off by default)"?). Could also just be a sub-option that's greyed out if you're not using toggle (if it's possible to conditionally grey out options).

ruby0b avatar Apr 06 '24 13:04 ruby0b

or would it be "smart" and put you back into the global voice state you had previously?

Depends on the mode: If it was in toggle mode and previously enabled, it should return to being enabled. If it was in push to talk and the global talk key is no longer pressed, it should be disabled. And so on.

The rest looks good to me, but imho such details can be discussed later on

TimGoll avatar Apr 06 '24 13:04 TimGoll

@ruby0b You seem to be more knowledgeable than me with this topic. Does your #1503 address the issue described in #1482? To me it seems like it is only possible to cut off the voice chat range, not to extend it

TimGoll avatar Apr 11 '24 14:04 TimGoll

The way I understand it, 3D sound is very much baked into gmod itself and it sadly exposes no way to configure it besides turning it on and off in the PlayerCanHearPlayers hook. This 3D sound does not seem to have any cutoff, instead just getting very quiet at long distances, so technically the range is infinite by default! Cutting the voice range short in the way I've done in #1503 was fairly simple but is of course not that clean since now the volume is not a continuous function that approaches 0 as the speaker is nearing the range cutoff but rather we just have a hard drop to 0 once the speaker goes out of range.

Of course we do have ways to modify the audio output of each player and so we could downscale the volume accordingly with our cut-off point (which I think is what @EntranceJew is proposing in #1482). I'm not sure if we can increase the volume of far away players this way since we can't upscale player volumes afaik, would have to check.

At the end of the day there's always the option of manually processing incoming voice data from clients and writing an entirely custom 3d voice implementation on the server which would solve all of these issues but that would obviously be non-trivial and can probably not be done in pure lua :)

ruby0b avatar Apr 11 '24 15:04 ruby0b

Thanks for that insight, I'll relay that information to that issue

TimGoll avatar Apr 11 '24 15:04 TimGoll

I forgot where we had this discussion, but the voice UI now supports team changes, the change was rather easy: https://github.com/TTT-2/TTT2/pull/1473/commits/86881f47e71e6a57c363371cb9ce746a7b063b02

TimGoll avatar Apr 12 '24 08:04 TimGoll

Updated the milestone to give you more time to finish the last todo on your list.

TimGoll avatar Aug 20 '24 07:08 TimGoll