Skip to content

Commit f989a1b

Browse files
authored
fix sound length rounding to seconds (#645)
1 parent 7fc8e6d commit f989a1b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

source/openfl/media/Sound.hx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,8 @@ class Sound extends EventDispatcher
695695
// var samples = (__buffer.data.length * 8) / (__buffer.channels * __buffer.bitsPerSample);
696696
// return Std.int(samples / __buffer.sampleRate * 1000);
697697
var samples = (Int64.make(0, __buffer.data.length) * Int64.ofInt(8)) / Int64.ofInt(__buffer.channels * __buffer.bitsPerSample);
698-
var value = samples / Int64.ofInt(__buffer.sampleRate) * Int64.ofInt(1000);
698+
var div = Int64.divMod(samples * Int64.ofInt(1000), Int64.ofInt(__buffer.sampleRate));
699+
var value = (div.quotient + (div.modulus / __buffer.sampleRate));
699700
return Int64.toInt(value);
700701
}
701702
else if (__buffer.__srcVorbisFile != null)

0 commit comments

Comments
 (0)