Enhancement: audio speakers (#44)

* refactor: active speakers

1. Observe the loudest adjusted with active ratio instead of linear average of decibel values
2. Follow RFC6465 to convert audio level from decibel to linear value.
3. Quantize audio level for stable slice comparison
4. Switch moving average algorithm from MMA to EMA to have the same center of mass with SMA
5. Minor: remove seenSids map allocation
6. Minor: minimize division arithmetic

* Update pkg/rtc/audiolevel.go

Co-authored-by: David Zhao <david@davidzhao.com>
This commit is contained in:
hn8
2021-07-09 09:46:24 -07:00
committed by GitHub
co-authored by David Zhao
parent 1fd858a16b
commit dcfe7eaf4f
12 changed files with 103 additions and 86 deletions
+1 -1
View File
@@ -110,7 +110,7 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
done := make(chan bool, 1)
done := make(chan struct{})
// function exits when websocket terminates, it'll close the event reading off of response sink as well
defer func() {
logger.Infow("WS connection closed", "participant", pi.Identity, "connectionId", connId)
+2 -2
View File
@@ -34,7 +34,7 @@ type LivekitServer struct {
turnServer *turn.Server
currentNode routing.LocalNode
running utils.AtomicFlag
doneChan chan bool
doneChan chan struct{}
}
func NewLivekitServer(conf *config.Config,
@@ -126,7 +126,7 @@ func (s *LivekitServer) Start() error {
return err
}
s.doneChan = make(chan bool, 1)
s.doneChan = make(chan struct{})
// ensure we could listen
ln, err := net.Listen("tcp", s.httpServer.Addr)