Skip to content

Commit ae8883b

Browse files
committed
Fix pop in exported track due to wrong peak calculation
This difference of one unit would result in the peak being calculated as smaller than it is, so the applied attenuation would be slightly less than necessary, causing the peak value to overflow during the conversion to `int16` and leading to a pop in the exported track.
1 parent cc8173c commit ae8883b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

nbswave/audio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def append(self, sound):
102102

103103
def to_audio_segment(self):
104104
peak = np.abs(self.output).max()
105-
clipping_factor = peak / (2 ** 15)
105+
clipping_factor = peak / (2 ** 15 - 1)
106106

107107
if clipping_factor > 1:
108108
print(

0 commit comments

Comments
 (0)