Skip to content

Commit 3116c9e

Browse files
Reduce distortion at higher volume levels
1 parent 20f8794 commit 3116c9e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

CircuitPython_Essentials/CircuitPython_Audio_Out_Tone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
length = 8000 // frequency
1414
sine_wave = array.array("H", [0] * length)
1515
for i in range(length):
16-
sine_wave[i] = int((1 + math.sin(math.pi * 2 * i / 18)) * tone_volume * (2 ** 15))
16+
sine_wave[i] = int((1 + math.sin(math.pi * 2 * i / length)) * tone_volume * (2 ** 15 - 1))
1717

1818
audio = audioio.AudioOut(board.A0)
1919
sine_wave_sample = audioio.RawSample(sine_wave)

0 commit comments

Comments
 (0)