Kode / Kha

Ultra-portable, high performance, open source multimedia framework.
http://kha.tech
zlib License
1.48k stars 174 forks source link

[HL] some sample rate fixes #1383

Closed MoritzBrueckner closed 2 years ago

MoritzBrueckner commented 2 years ago

If the system falls back to an alternative mix format with a different sample rate than preferred by Kinc, it could happen that the sample rate in the Haxe API wasn't correctly updated because it it was read before the audio was initialized.

Also, audio buffers used a hard-coded sample rate which would fail in the same situation. This would lead to playback with a wrong speed because the resampling code in resampling audio channels depends on the sample rate passed here.

Btw, what's the reason why the sample rate is stored in each buffer when it's also a globally accessible variable? Are the buffers designed to be used for multiple purposes?

On Krom there are similar issues but I couldn't get Krom audio to work even after enabling it in main.cpp (see https://github.com/Kode/Krom/issues/138#issuecomment-558732832; I know of the issues because they exist in Armorcore and they are likely to exist in Kode/Krom as well). I will try to dig deeper in the next days and then eventually open an issue or add something to the linked issue.