From 7dafbb2e4e4c88879d1c6e69a73539d5ee0477ef Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 20 Jan 2019 02:17:10 +0900 Subject: [PATCH] examples/sinewave: Bug fix: Sinewave volume was too small --- examples/sinewave/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/sinewave/main.go b/examples/sinewave/main.go index e6cdbe724..50de5a273 100644 --- a/examples/sinewave/main.go +++ b/examples/sinewave/main.go @@ -68,7 +68,7 @@ func (s *stream) Read(buf []byte) (int, error) { const length = int64(sampleRate / frequency) p := s.position / 4 for i := 0; i < len(buf)/4; i++ { - const max = (1<<15 - 1) / 2 + const max = 32767 b := int16(math.Sin(2*math.Pi*float64(p)/float64(length)) * max) buf[4*i] = byte(b) buf[4*i+1] = byte(b >> 8)