Krom icon indicating copy to clipboard operation
Krom copied to clipboard

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

Open DarthVernus opened this issue 5 years ago • 9 comments

       //...
		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);
	}

DarthVernus avatar Nov 26 '19 14:11 DarthVernus

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

RobDangerous avatar Nov 26 '19 15:11 RobDangerous

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

DarthVernus avatar Nov 26 '19 17:11 DarthVernus

But... I disabled sound in Krom.

RobDangerous avatar Nov 26 '19 17:11 RobDangerous

What do you mean?

DarthVernus avatar Nov 26 '19 17:11 DarthVernus

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.

RobDangerous avatar Nov 26 '19 17:11 RobDangerous

Ah, that's exactly what I did.

DarthVernus avatar Nov 26 '19 17:11 DarthVernus

OK. Let's move and rename.

RobDangerous avatar Nov 26 '19 17:11 RobDangerous

Here is what i did:

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

DarthVernus avatar Nov 26 '19 17:11 DarthVernus

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.

MoritzBrueckner avatar Dec 17 '22 00:12 MoritzBrueckner