Recording bug that makes other people too quiet fixed.
This commit is contained in:
@@ -33,6 +33,7 @@ const (
|
|||||||
sourceBufferSize = 16
|
sourceBufferSize = 16
|
||||||
encoderBufferSize = 50
|
encoderBufferSize = 50
|
||||||
sourceStaleAfter = 2 * time.Second
|
sourceStaleAfter = 2 * time.Second
|
||||||
|
activeSampleLevel = 512
|
||||||
limiterThreshold = 28000
|
limiterThreshold = 28000
|
||||||
limiterRatio = 4
|
limiterRatio = 4
|
||||||
)
|
)
|
||||||
@@ -494,19 +495,28 @@ func mixPCMFrames(frames [][]byte) []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var mixed []int32
|
var mixed []int32
|
||||||
gain := 1.0
|
activeFrames := 0
|
||||||
if len(frames) > 1 {
|
|
||||||
gain = 1 / math.Sqrt(float64(len(frames)))
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, frame := range frames {
|
for _, frame := range frames {
|
||||||
if mixed == nil {
|
if mixed == nil {
|
||||||
mixed = make([]int32, samplesPerFrame*channels)
|
mixed = make([]int32, samplesPerFrame*channels)
|
||||||
}
|
}
|
||||||
|
active := false
|
||||||
for i := range mixed {
|
for i := range mixed {
|
||||||
sample := int16(binary.LittleEndian.Uint16(frame[i*2:]))
|
sample := int16(binary.LittleEndian.Uint16(frame[i*2:]))
|
||||||
|
if !active && abs16(sample) >= activeSampleLevel {
|
||||||
|
active = true
|
||||||
|
}
|
||||||
mixed[i] += int32(sample)
|
mixed[i] += int32(sample)
|
||||||
}
|
}
|
||||||
|
if active {
|
||||||
|
activeFrames++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gain := 1.0
|
||||||
|
if activeFrames > 1 {
|
||||||
|
gain = 1 / math.Sqrt(float64(activeFrames))
|
||||||
}
|
}
|
||||||
|
|
||||||
out := make([]byte, bytesPerFrame)
|
out := make([]byte, bytesPerFrame)
|
||||||
@@ -518,6 +528,13 @@ func mixPCMFrames(frames [][]byte) []byte {
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func abs16(sample int16) int16 {
|
||||||
|
if sample < 0 {
|
||||||
|
return -sample
|
||||||
|
}
|
||||||
|
return sample
|
||||||
|
}
|
||||||
|
|
||||||
func limitSample(sample int32) int32 {
|
func limitSample(sample int32) int32 {
|
||||||
if sample > limiterThreshold {
|
if sample > limiterThreshold {
|
||||||
sample = limiterThreshold + (sample-limiterThreshold)/limiterRatio
|
sample = limiterThreshold + (sample-limiterThreshold)/limiterRatio
|
||||||
|
|||||||
@@ -153,6 +153,23 @@ func TestMixFrameHandlesQuietAndLoudSources(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMixFrameDoesNotAttenuateSpeakerForSilentOpenMics(t *testing.T) {
|
||||||
|
speaker := make(chan []byte, 1)
|
||||||
|
silent1 := make(chan []byte, 1)
|
||||||
|
silent2 := make(chan []byte, 1)
|
||||||
|
speaker <- pcmFrame(12000)
|
||||||
|
silent1 <- pcmFrame(0)
|
||||||
|
silent2 <- pcmFrame(0)
|
||||||
|
|
||||||
|
out := mixFrame([]chan []byte{speaker, silent1, silent2})
|
||||||
|
for i := 0; i < len(out); i += 2 {
|
||||||
|
got := int16(binary.LittleEndian.Uint16(out[i:]))
|
||||||
|
if got != 12000 {
|
||||||
|
t.Fatalf("sample %d = %d, expected unattenuated speaker 12000", i/2, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestMixFrameLimiterBoundsOverloadedSamples(t *testing.T) {
|
func TestMixFrameLimiterBoundsOverloadedSamples(t *testing.T) {
|
||||||
a := make(chan []byte, 1)
|
a := make(chan []byte, 1)
|
||||||
b := make(chan []byte, 1)
|
b := make(chan []byte, 1)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# shellcheck shell=bash disable=SC2034,SC2154
|
# shellcheck shell=bash disable=SC2034,SC2154
|
||||||
|
|
||||||
pkgname=skald-git
|
pkgname=skald-git
|
||||||
pkgver=0.0.0.r1532.g3e06de7
|
pkgver=0.0.0.r1533.g3df0c22
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc='Audio-only hall-based conferencing server'
|
pkgdesc='Audio-only hall-based conferencing server'
|
||||||
arch=('x86_64' 'aarch64')
|
arch=('x86_64' 'aarch64')
|
||||||
|
|||||||
Reference in New Issue
Block a user