@@ -68,7 +68,6 @@ def __export(self, data, filename, normalize, samplingRate, bitsPerSample):
68
68
assume_sorted = True , bounds_error = False , fill_value = 0 )
69
69
dlg += 10
70
70
71
-
72
71
arr = spl (xnew )
73
72
dlg += 10
74
73
@@ -78,18 +77,26 @@ def __export(self, data, filename, normalize, samplingRate, bitsPerSample):
78
77
return
79
78
80
79
if normalize :
81
- # normalize values to -1.0 to 1.0
82
- arr = np .divide (arr , np .max (np .abs (arr )))
83
- dlg += 5
84
-
85
- if dtype == np .dtype (np .uint8 ).type :
86
- arr = np .add (arr , 1 )
87
- amplitude = amplitude // 2
88
-
89
- arr = np .multiply (arr , amplitude )
90
- dlg += 5
91
- # samples only go from -(2**15) to (2**15) for 16-Bit PCM for example
92
- # => missing one possible value at (2**15)-1
80
+ divide = np .max (np .abs (arr )) # scale to max range
81
+ else :
82
+ divide = 1000 #mA
83
+ # scale to 1A maximum as per import into ltspice
84
+
85
+ # normalize values to -1.0 to 1.0
86
+ arr = np .divide (arr , divide )
87
+ dlg += 5
88
+
89
+ if dtype == np .dtype (np .uint8 ).type :
90
+ arr = np .add (arr , 1 )
91
+ amplitude = amplitude // 2
92
+
93
+ arr = np .multiply (arr , amplitude )
94
+ dlg += 5
95
+ # samples only go from -(2**15) to (2**15) for 16-Bit PCM for example
96
+ # => missing one possible value at (2**15)-1
97
+
98
+ if dtype != np .dtype (np .float ).type :
99
+ arr = np .round (arr , 0 )
93
100
94
101
# convert to data type
95
102
data_resampled = arr .astype (dtype )
0 commit comments