2019-11-24 10:36:25 -07:00
|
|
|
#!/usr/bin/env python3
|
2011-07-23 15:22:31 -06:00
|
|
|
|
|
|
|
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")
|
2011-07-23 15:22:31 -06:00
|
|
|
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)], ":"))
|
2011-07-23 15:22:31 -06:00
|
|
|
|
|
|
|
# EOF #
|