From f989a1b95560a8552d795bae1788c244bb9d5df9 Mon Sep 17 00:00:00 2001 From: Betopia <73242725+betpowo@users.noreply.github.com> Date: Wed, 4 Jun 2025 10:23:51 -0400 Subject: [PATCH] fix sound length rounding to seconds (#645) --- source/openfl/media/Sound.hx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/openfl/media/Sound.hx b/source/openfl/media/Sound.hx index b0632e78..cbccc35b 100644 --- a/source/openfl/media/Sound.hx +++ b/source/openfl/media/Sound.hx @@ -695,7 +695,8 @@ class Sound extends EventDispatcher // var samples = (__buffer.data.length * 8) / (__buffer.channels * __buffer.bitsPerSample); // return Std.int(samples / __buffer.sampleRate * 1000); var samples = (Int64.make(0, __buffer.data.length) * Int64.ofInt(8)) / Int64.ofInt(__buffer.channels * __buffer.bitsPerSample); - var value = samples / Int64.ofInt(__buffer.sampleRate) * Int64.ofInt(1000); + var div = Int64.divMod(samples * Int64.ofInt(1000), Int64.ofInt(__buffer.sampleRate)); + var value = (div.quotient + (div.modulus / __buffer.sampleRate)); return Int64.toInt(value); } else if (__buffer.__srcVorbisFile != null)