Krom
Krom copied to clipboard
Implement audio support properly, please (was: sounds play with some delay)
//...
Assets.loadSoundFromPath("impact_a.ogg", function(sound:Sound) {
testSound = sound;
});
}
//...
function keyboardDownListener(keyCode:KeyCode)
{
if (testSoundAC != null)
testSoundAC.play();
else if (testSound != null)
testSoundAC = Audio.play(testSound);
}
Tested on which platform and with what version of Krom? How large is "some delay"?
~0.5s. os: Windows 7 Krom from Kode Studio 18.11. I know that Kha and Krom are outdated in this release. But Armory3d uses a more recent version and has the same probem. I also built latest Krom from github (for my armory3d project) and had the same problem with sound. HTML5 has less delay.
But... I disabled sound in Krom.
What do you mean?
I literally disabled sound in Krom: https://github.com/Kode/Krom/blob/master/Sources/main.cpp#L96 That's because the current implementation is just a temporary hack. You can manually activate it on the command line but I wouldn't recommend it.
Ah, that's exactly what I did.
OK. Let's move and rename.
Here is what i did:
bool enableSound = true;
else if (strcmp(argv[i], "--nosound") == 0) {
enableSound = false;
}
Not sure if this belongs in a separate issue, but since my last one about loading sounds was closed in favour of this one:
(From https://github.com/Kode/Kha/pull/1441)
Krom currently doesn't check whether loading a sound was successful, and in turn it crashes because it tries to dereference a null pointer. Instead, it should simply return null in that case (see https://github.com/armory3d/armorcore/pull/56). I can't test Kode's version of Krom at the moment because I don't know how to handle this new node stuff, so instead I'm writing this here.