Attempt to improve over all voice code.

This commit is contained in:
Storm Dragon
2026-08-11 19:47:01 -04:00
parent 30a02eba14
commit eae1d8b99a
17 changed files with 1198 additions and 130 deletions
+6 -12
View File
@@ -9,7 +9,7 @@ import (
func (ti TreeItem) String() string {
if ti.User != nil {
if ti.User.LocallyMuted {
if ti.User.IsLocallyMuted() {
return "[MUTED] " + ti.User.Name
}
// Calculate total volume as percentage
@@ -35,8 +35,7 @@ func (ti TreeItem) TreeItemStyle(fg, bg uiterm.Attribute, active bool) (uiterm.A
func (b *Barnard) changeVolume(users []*gumble.User, change float32) {
for _, u := range users {
au := u.AudioSource
if au == nil {
if b.Stream == nil || !b.Stream.HasUserAudio(u) {
continue
}
var boost uint16
@@ -44,7 +43,7 @@ func (b *Barnard) changeVolume(users []*gumble.User, change float32) {
var ng float32
var curboost float32
curboost = float32((u.Boost - 1)) / 10
cv = au.GetGain() + curboost
cv = u.Volume + curboost
ng = cv + change
boost = uint16(1)
if ng > 1.0 {
@@ -58,9 +57,7 @@ func (b *Barnard) changeVolume(users []*gumble.User, change float32) {
}
u.Boost = boost
u.Volume = ng
if !u.LocallyMuted {
au.SetGain(ng)
}
b.Stream.SetUserGain(u, ng)
b.UserConfig.UpdateConfig(u)
}
b.UserConfig.SaveConfig()
@@ -68,16 +65,13 @@ func (b *Barnard) changeVolume(users []*gumble.User, change float32) {
func (b *Barnard) resetVolume(users []*gumble.User) {
for _, u := range users {
au := u.AudioSource
if au == nil {
if b.Stream == nil || !b.Stream.HasUserAudio(u) {
continue
}
// Reset to original volume (1.0) and boost (1)
u.Boost = uint16(1)
u.Volume = 1.0
if !u.LocallyMuted {
au.SetGain(1.0)
}
b.Stream.SetUserGain(u, 1.0)
b.UserConfig.UpdateConfig(u)
}
b.UserConfig.SaveConfig()