Posted January 18, 2016
high rated
I was looking for the soundtrack for the game (by Jeremy Soule), but couldn't find it anywhere as an add-on. The game contains actual audio files (found in <game-dir>/streammusic directory) for both ambient sounds and music, however for some weird reason they are prepended with some format obfuscating garbage which makes audio players choke on them.
Just looking at the files though reveals their true nature. If you clean the garbage in the beginning, you get a bunch of pretty standard WAV and mp3 files.
Example:
al_nt_undrwtrbed.wav
If you remove 470 bytes of garbage in the beginning, you'll get a valid WAV file with ADPCM encoding (for a nice underwater ambient sound), which mpv describes as:
adpcm_ima_wav
4100Hz stereo 2ch s16.
Same goes for all other al_*.wav files found there.
Other files on the other hand are mp3 encoded with some garbage in the beginning.
For instance 34.wav has 58 garbage bytes before the valid mp3 header. Though 01b.wav looks different, but if you remove same 58 bytes, mpv still recognizes it as an mp3.
Files like mus_*.wav also need removing 58 bytes of garbage from the beginning to get valid mp3.
For example mus_theme_rep.wav is a nice theme which plays during character creation.
No idea who came up with such weird way of obfuscating those files, but instead they could just release the proper soundtrack. I might write some script a bit later to produce proper files from the originals.
_______________________
UPDATE:
* Script for extracting music from KoTOR I: https://gist.github.com/shmerl/2cec6273ba25dd1486dd
* Script for extracting music from KoTOR II: https://gist.github.com/shmerl/30412cda5a5107132a1f
Just looking at the files though reveals their true nature. If you clean the garbage in the beginning, you get a bunch of pretty standard WAV and mp3 files.
Example:
al_nt_undrwtrbed.wav
If you remove 470 bytes of garbage in the beginning, you'll get a valid WAV file with ADPCM encoding (for a nice underwater ambient sound), which mpv describes as:
adpcm_ima_wav
4100Hz stereo 2ch s16.
Same goes for all other al_*.wav files found there.
Other files on the other hand are mp3 encoded with some garbage in the beginning.
For instance 34.wav has 58 garbage bytes before the valid mp3 header. Though 01b.wav looks different, but if you remove same 58 bytes, mpv still recognizes it as an mp3.
Files like mus_*.wav also need removing 58 bytes of garbage from the beginning to get valid mp3.
For example mus_theme_rep.wav is a nice theme which plays during character creation.
No idea who came up with such weird way of obfuscating those files, but instead they could just release the proper soundtrack. I might write some script a bit later to produce proper files from the originals.
_______________________
UPDATE:
* Script for extracting music from KoTOR I: https://gist.github.com/shmerl/2cec6273ba25dd1486dd
* Script for extracting music from KoTOR II: https://gist.github.com/shmerl/30412cda5a5107132a1f
Post edited May 09, 2016 by shmerl