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
+4 -4
View File
@@ -553,7 +553,7 @@ func (p *ParticipantImpl) SetTrackMuted(trackId string, muted bool) {
}
}
func (p *ParticipantImpl) GetAudioLevel() (level uint8, noisy bool) {
func (p *ParticipantImpl) GetAudioLevel() (level uint8, active bool) {
p.lock.RLock()
defer p.lock.RUnlock()
level = silentAudioLevel
@@ -562,9 +562,9 @@ func (p *ParticipantImpl) GetAudioLevel() (level uint8, noisy bool) {
if mt.audioLevel == nil {
continue
}
tl, tn := mt.audioLevel.GetLevel()
if tn {
noisy = true
tl, ta := mt.audioLevel.GetLevel()
if ta {
active = true
if tl < level {
level = tl
}