Skip to content

Commit 91bbed1

Browse files
committed
Fix unsigned short overflow
1 parent 56fa2aa commit 91bbed1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

adafruit_waveform/sine.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ def sine_wave(sample_frequency, pitch):
4141
length = int(sample_frequency / pitch)
4242
b = array.array("H", [0] * length)
4343
for i in range(length):
44-
b[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15) + 2 ** 15)
44+
b[i] = int(math.sin(math.pi * 2 * i / length) * ((2 ** 15) - 1) + 2 ** 15)
4545
return b

0 commit comments

Comments
 (0)