You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When length is even this is likely to try to assign 65536 (depending a little on floating point part of calculation and math functions) to a 16bit unsigned value, i.e. it will overflow it. The multiplier of 2**15 (32768) is too large, value-between-minus1-plus1-at-plus1 * 32768 + 32768 = 65536.
b = array.array("H", [0] * length)
for i in range(length):
b[i] = int(math.sin(math.pi * 2 * i / length) * (2 ** 15) + 2 ** 15)
The same code is used in various places. I'd suggest a scan across alll Learn guides and adafruit's whole repo.