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
+6 -6
View File
@@ -60,8 +60,8 @@ type AudioConfig struct {
// interval to update clients, in ms
UpdateInterval uint32 `yaml:"update_interval"`
// smoothing for audioLevel values sent to the client.
// audioLevel will be an average of `smooth_samples`, 0 to disable
SmoothSamples uint32 `yaml:"smooth_samples"`
// audioLevel will be an average of `smooth_intervals`, 0 to disable
SmoothIntervals uint32 `yaml:"smooth_intervals"`
}
type RedisConfig struct {
@@ -113,10 +113,10 @@ func NewConfig(confString string) (*Config, error) {
},
},
Audio: AudioConfig{
ActiveLevel: 40,
MinPercentile: 40,
UpdateInterval: 500,
SmoothSamples: 8,
ActiveLevel: 30, // -30dBov = 0.03
MinPercentile: 40,
UpdateInterval: 500,
SmoothIntervals: 4,
},
Redis: RedisConfig{},
Room: RoomConfig{