Kode / Krom

Other
96 stars 23 forks source link

Implement audio support properly, please (was: sounds play with some delay) #138

Open DarthVernus opened 4 years ago

DarthVernus commented 4 years ago
       //...
        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);
    }
RobDangerous commented 4 years ago

Tested on which platform and with what version of Krom? How large is "some delay"?

DarthVernus commented 4 years ago

~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.

RobDangerous commented 4 years ago

But... I disabled sound in Krom.

DarthVernus commented 4 years ago

What do you mean?

RobDangerous commented 4 years ago

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.

DarthVernus commented 4 years ago

Ah, that's exactly what I did.

RobDangerous commented 4 years ago

OK. Let's move and rename.

DarthVernus commented 4 years ago

Here is what i did:

bool enableSound = true;
               else if (strcmp(argv[i], "--nosound") == 0) {
            enableSound = false;
        }
MoritzBrueckner commented 1 year ago

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.