Skip to content

Commit 409fd7a

Browse files
committed
Fix muffling and Sound.length
1 parent 96f68a6 commit 409fd7a

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/openfl/media/Sound.hx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -786,20 +786,12 @@ class Sound extends EventDispatcher
786786
#if (js && html5 && howlerjs)
787787
return Std.int(__buffer.src.duration() * 1000);
788788
#else
789-
if (__buffer.data != null)
790-
{
791-
var samples = (__buffer.data.length * 8.0) / (__buffer.channels * __buffer.bitsPerSample);
792-
return Std.int(samples / __buffer.sampleRate * 1000);
793-
}
794-
else if (__buffer.__srcVorbisFile != null)
795-
{
796-
var samples = Int64.toInt(__buffer.__srcVorbisFile.pcmTotal());
797-
return Std.int(samples / __buffer.sampleRate * 1000);
798-
}
799-
else
800-
{
801-
return 0;
802-
}
789+
if (__buffer.data != null) return Std.int(__buffer.data.length / (__buffer.bitsPerSample >> 3) / __buffer.channels / __buffer.sampleRate * 1000);
790+
#if lime_funkin
791+
else if (__buffer.decoder != null) return Std.int(Int64.toInt(__buffer.decoder.total()) / __buffer.sampleRate * 1000);
792+
#else
793+
else if (__buffer.__srcVorbisFile != null) return Std.int(Int64.toInt(__buffer.__srcVorbisFile.pcmTotal()) / __buffer.sampleRate * 1000);
794+
#end
803795
#end
804796
}
805797
#end

src/openfl/media/SoundChannel.hx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,12 @@ import lime.utils.Int16Array;
339339

340340
if (__isValid)
341341
{
342-
#if lime
342+
#if lime_funkin
343+
__audioSource.gain = volume;
344+
__audioSource.pan = pan;
345+
346+
return value;
347+
#else
343348
__audioSource.gain = volume;
344349

345350
var position = __audioSource.position;

0 commit comments

Comments
 (0)