Fix loud stereo overflow

pull/357/head
nyanpasu64 2018-11-17 21:45:17 -08:00
rodzic 30a59c8e07
commit 21c78fd7fc
1 zmienionych plików z 3 dodań i 1 usunięć

Wyświetl plik

@ -23,7 +23,9 @@ class Wave:
# Flatten stereo to mono
assert self.data.ndim in [1, 2]
if self.data.ndim == 2:
self.data = np.mean(self.data, axis=1, dtype=dtype)
# np.mean() defaults to dtype=float64,
# which prevents overflow if dtype is an integer.
self.data = np.mean(self.data, axis=1).astype(dtype)
self.nsamp = len(self.data)