Describe the bug
When loading a .wav audio file (Khamake quality set to 1.0), the Sound object's length will not be set correctly on HL on Windows. The reason for this is the known hl.Ref issue we've had before with the sample rate (https://github.com/Kode/Kha/pull/1361), but that alone is unfortunately not enough here because something is wrong with the resulting float value.
The sound in my case has a length of ~62.95s and the wav reader seems to parse the file correctly as you see in the following screenshot:
_Screenshot from VS 2019 that shows sound->length is correct in hl_kore_sound_init_wav()._
However it is somehow passed to Haxe as 5.51085676554428e-315, at least that's the result when printing the value in Haxe. So there must be a conversion error somewhere, but I currently have no idea where... My current hypothesis is that the value is converted from float to double and that's where the issue comes from.
This is the changed code in korehl/Sound.hx in initWav():
final sampleRateRef: hl.Ref<Int> = sampleRate;
final lengthRef: hl.Ref<Float> = length;
var data = kore_sound_init_wav(StringHelper.convert(filename), dataSize.getData(), sampleRateRef, lengthRef);
sampleRate = sampleRateRef.get();
length = lengthRef.get();
Execution Environment:
Host system (where you compile your code): Windows 10
Target system (where you run your code): Windows 10
IDE used (if any): VS 2019
Kha revision: latest master a4a10b824258c769a951b01feb61c3e310f129f5, no changes apart from the above code
Describe the bug When loading a .wav audio file (Khamake quality set to 1.0), the
Sound
object's length will not be set correctly on HL on Windows. The reason for this is the knownhl.Ref
issue we've had before with the sample rate (https://github.com/Kode/Kha/pull/1361), but that alone is unfortunately not enough here because something is wrong with the resulting float value.The sound in my case has a length of ~62.95s and the wav reader seems to parse the file correctly as you see in the following screenshot:
_Screenshot from VS 2019 that shows
sound->length
is correct inhl_kore_sound_init_wav()
._However it is somehow passed to Haxe as
5.51085676554428e-315
, at least that's the result when printing the value in Haxe. So there must be a conversion error somewhere, but I currently have no idea where... My current hypothesis is that the value is converted from float to double and that's where the issue comes from.This is the changed code in
korehl/Sound.hx
ininitWav()
:Execution Environment: