From ffb96bb5d0091dbb282501d156530c03e7e1ba4a Mon Sep 17 00:00:00 2001 From: ajzaff Date: Fri, 12 Jun 2020 00:29:57 -0400 Subject: [PATCH] Fix a clamping inaccuracy in the speaker writer --- speaker/speaker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/speaker/speaker.go b/speaker/speaker.go index d59389f..43f8956 100644 --- a/speaker/speaker.go +++ b/speaker/speaker.go @@ -118,7 +118,7 @@ func update() { if val > +1 { val = +1 } - valInt16 := int16(val * (1<<15 - 1)) + valInt16 := int16((val+1)/2*(1<<16-1) + (-1 << 15)) low := byte(valInt16) high := byte(valInt16 >> 8) buf[i*4+c*2+0] = low