xboxdrv/examples/responsecurve-generator.py

25 lines
652 B
Python
Raw Permalink Normal View History

2019-11-24 10:36:25 -07:00
#!/usr/bin/env python3
import sys
import string
if len(sys.argv) != 3:
2019-11-24 10:36:25 -07:00
print("Usage:", sys.argv[0], "STEPS", "EQUATION")
print("Simple generator for generating responsecurve data from equations.")
print("")
print("Example:")
print(" ", sys.argv[0], "6 i**2")
else:
steps = int(sys.argv[1])
equation = sys.argv[2]
left = [int(eval(equation, {'i': i/float(steps-1)}) * -32768) for i in range(0,steps)]
right = [int(eval(equation, {'i': i/float(steps-1)}) * 32767) for i in range(0,steps)]
left.reverse()
left = left[0:-1]
2019-11-24 10:36:25 -07:00
print(string.join([str(x) for x in (left + right)], ":"))
# EOF #