5 # IT's annoying that the 1023,4 and 4095,16 almost, but dont exactly, cancel. UGH
6 # The intent is clearly to have the same mapping, but it's not done very well.
7 # Sony engineers and/or the Academy should pick one of these mappings for both.
10 return (math.pow(10.0,(((((x*1023.0)/4.0-16.0)/219.0)-0.616596-0.03)/0.432699))-0.037584)*0.9
12 def Fit(value, fromMin, fromMax, toMin, toMax):
13 if fromMin == fromMax:
14 raise ValueError("fromMin == fromMax")
15 return (value - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin
18 x = Fit(x, 64.0/1023.0, 940.0/1023.0, 0.0, 1.0)
19 if x < 0.030001222851889303:
20 y = ((x-0.030001222851889303 ) * 0.28258064516129)
22 y = (219.0*(math.pow(10.0, ((x-0.616596-0.03)/0.432699)) - 0.037584) /155.0)
27 for i in xrange(steps):
29 print x, SLog2_to_lin(x)
32 print SLog2_to_lin_copy(90.0/1023.0) / 0.9
33 print SLog2_to_lin_copy(91.0/1023.0) / 0.9
34 print SLog2_to_lin_copy(582.0/1023.0) / 0.9
35 print SLog2_to_lin_copy(940.0/1023.0) / 0.9
36 print SLog2_to_lin_copy(998.0/1023.0) / 0.9
39 def WriteSPI1D(filename, fromMin, fromMax, data):
40 f = file(filename,'w')
41 f.write("Version 1\n")
42 f.write("From %s %s\n" % (fromMin, fromMax))
43 f.write("Length %d\n" % len(data))
44 f.write("Components 1\n")
47 f.write(" %s\n" % value)
52 RANGE = (-0.125, 1.125)
54 for i in xrange(NUM_SAMPLES):
55 x = i/(NUM_SAMPLES-1.0)
56 x = Fit(x, 0.0, 1.0, RANGE[0], RANGE[1])
57 data.append(SLog2_to_lin(x))
58 WriteSPI1D('slog2.spi1d', RANGE[0], RANGE[1], data)