ko4life-net / ko

Open source development of the game Knight Online. This is a reversed engineered old version of the game aiming to replicate the nostalgic experience we all once had <3
MIT License
52 stars 21 forks source link

Discuss new audio library implementation for the game engine #124

Open stevewgr opened 1 year ago

stevewgr commented 1 year ago

Description

Note that currently the existing game engine implementation can only load WAV audio files. This implementation can be found in CWaveFile class.

We need to start thinking about a new Audio library for this game engine.

There are multiple reasons as to why. The official game in v1298 client introduced Miles Sound System SDK coming from mss32.dll in order to start migrating from WAV files to MP3 considering WAV files are big in size and also affects performance due to load time.

Eventually the official game in the latest versions started migrating towards OGG audio files using OpenAL which there couple couple of nice docs for it. Going with OpenAL and converting all audio files to OGG reduced the size and improved performance noticeably in the official client.

We can use this free fork of OpenAL: https://github.com/kcat/openal-soft

Another alternative is FFMpeg: https://github.com/FFmpeg/FFmpeg

Here is a nice discussion: https://stackoverflow.com/questions/12915892/library-for-reading-audio-files

Even though I suggest going for OpenAL as it will also make it work as in the official game, this ticket is open for discussion.

ko4life-psko commented 1 year ago

I noticed I was tagged here, so I'll write a quick reply.

Generally what you say makes sense. Not much that I can personally add here, since I haven't tinkered much with audio in this game engine.

I think as long as OpenAL satisfying the following criteria:

Then you can't go much wrong here.

twostars commented 4 months ago

I was curious on this myself, and apparently Miles is used in the 1.264 client as well. If accuracy and sticking to the official client is important, I would use Miles. This tracks with the whole "making reverse engineering easier & sticking to official behaviour" thing, since you'd basically just be replicating what the official 1.264 client already does.

Otherwise, OpenAL is a solid choice. Cross-platform, supports 64-bit well (at least compared with the old versions of Miles following the version used by KO for quite some time), and not really that tedious to implement. But the reverse engineering point is a little confusing to me, because then you'd be referring to considerably newer clients rather than the one you're primarily working with. The downside is just having to deal with assets not native to the 1.264 client (either straight up the sound files from the newer clients, or the old ones converted).

Ultimately I think it comes down to what the intentions of the project are. If you're wanting to do your own thing, then OpenAL is more than fine. If you want to keep things somewhat official and have it easier to mimic from the official client, then you'd use Miles.