I've just started playing with my Gemma M0 board and wanted to implement a simple sine wave generator using adafruit_waveform sine library. The problem is that even running the provided example, I get an overflow error: "OverflowError: value must fit in 2 byte(s)"

the sample code is simply:

- Code: Select all | TOGGLE FULL SIZE
`wave = sine.sine_wave(16000, 440)`

the library code is also extremely simple:

- Code: Select all | TOGGLE FULL SIZE
`def sine_wave(sample_frequency, pitch):`

"""Generate a single sine wav cycle at the given sampling frequency and pitch."""

length = int(sample_frequency / pitch)

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)

return b

The overflow error is thrown any time that unsigned short b[i] is given a value larger greater than 32767, i.e 2^15.

I know I can simply write my own sine function that changes b from "H" to 'i" - but it seems odd that a stock function has this bug.

I am missing something?