Fix doc path
[opentx.git] / radio / util / sinus.py
blob2e9b0932b4d3c315a0a60620b656110223012fde
1 #!/bin/env python
3 from __future__ import print_function
5 import math
7 samples = 1024
8 amplitudes = (32000, 0, 4000, 0, 4000)
10 max = 0
11 min = 0
13 for i in range(samples):
14 sample = 0.0
15 for harmonic, amplitude in enumerate(amplitudes):
16 sample += math.sin(math.pi * 2 * i * (harmonic + 1) / samples) * amplitude / 2
17 sample = int(sample)
18 if sample > max:
19 max = sample
20 elif sample < min:
21 min = sample
22 print("%d," % sample, end=' ')
23 if i % 10 == 9:
24 print()
26 print()
27 print('Range is:', min, max)
29 if max > 32767 or min < -32768:
30 print("Invalid range!")