From d3c827915916b48a50482815f130ede501cc15c2 Mon Sep 17 00:00:00 2001 From: ThunderClapLP <59509654+ThunderClapLP@users.noreply.github.com> Date: Tue, 6 Aug 2024 20:29:31 +0200 Subject: [PATCH] 32bit: clamp value to fix distortion --- GDScriptAudioImport.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GDScriptAudioImport.gd b/GDScriptAudioImport.gd index 6f41bc8..9f021a5 100644 --- a/GDScriptAudioImport.gd +++ b/GDScriptAudioImport.gd @@ -202,7 +202,7 @@ func convert_to_16bit(data: PoolByteArray, from: int) -> PoolByteArray: for i in range(0, data.size(), 4): spb.data_array = data.subarray(i, i+3) single_float = spb.get_float() - value = single_float * 32768 + value = clamp(single_float * 32768, -32768, 32767) data[i/2] = value data[i/2+1] = value >> 8 data.resize(data.size() / 2)