Sign in to follow this  
bead-v

Sound files

Recommended Posts

Though this kind of continues the tutorial thread, I didn't want to post there because I think there are still too many unknowns.
(I'll only be talking about TSL here, don't know how much of it applies to K1)

It seems to me there are three types of sound files:
 - sounds.bif has raw .wav files
 - StreamMusic & StreamVoices has compressed .mp3 files renamed to .wav. If renamed back to .mp3 they still play fine, and (untested, correct me if I'm wrong) I assume if they were raw .wav they would still play fine.
 - StreamSounds apparently has something else (extension .wav). To play them in audacity, I needed to import them as raw data, and then halve the playing rate. But that also imports the header, so there's some glitchy sound at the beginning of every file. Kotor Tool also cannot play them and neither can Miles.

 

For my version (4CD), a reference to a sound from a .2da (tested with spells.2da) or from a .uts works only if the sound is in raw .wav and in the override. It doesn't work if the file is in StreamSounds, presumably because it has to be in that third file format.

 

Fair Strides has told me that the Aspyr Update to KotOR 2 on Steam made it so that specific version and update only takes .mp3 files. If anyone has that update, it would be nice to know how the three types of files behave there, so mods can be made compatible with it.

 

There's also one more bug that's been happening to me related to sounds that I just can't figure out. I'm setting off a grenade, so I'm using the visual effect, and I'm firing the vanilla sound in sounds.bif with PlaySound(). Now other sounds I play in the same cutscene (usually!) play normally, but this one is being rebellious. At one point it would work if I started the cutscene directly, but if I went from another cutscene that leads into this one, it wouldn't work. Currently it doesn't work however I play the cutscene. If anyone can think of anything that could cause problems for calling PlaySound() to play a vanilla sound from sounds.bif, please let me know!
EDIT: figured it out!
 

Edited by bead-v

Share this post


Link to post
Share on other sites

TSL has a bit more variation in its audio than K1. If you have access to a Linux box you can run this bash script to convert them - https://gist.github.com/shmerl/30412cda5a5107132a1f

 

Windows 10 has that bash shell, that might also work, although the script requires hexdump, so I dunno. You might be better off spinning up a VM.

Share this post


Link to post
Share on other sites

TSL has a bit more variation in its audio than K1. If you have access to a Linux box you can run this bash script to convert them.

 

That is, to convert TSL audio to K1 audio?

 

Also, found the source of my grenade sound problem, a combat animation was playing at the same time, apparently its (silent) sound overrode the grenade sound. It seems that with PlaySound(), only one sound can play at the same time, a new one will end the previous one.

EDIT: Wrong. Rather it has something to do with the fact that it's the owner & speaker of the node who fires the animation.

EDIT2:

Okay, final solution. The sound wasn't playing because I performed ClearAllActions() on the dialog owner right after it, making it seem like the next sound canceled it. It's acting like it was ActionPlaySound().

Edited by bead-v

Share this post


Link to post
Share on other sites

Ah yes. I would have gone the long way around, decompress with Miles, and export to .mp3 with Audacity.

Share this post


Link to post
Share on other sites

Update!

The StreamSounds sound files as well as the ambient area sound files in StreamMusic in K1 (thanks to HaloGirlAsh117 for identifying those) are RAW .wav files with an added .mp3 header (or rather, three headers, for whatever reason :question:). To play these files, open them up in a hex editor and delete everything up until RIFF, that is 1D6 bytes. You can then open it up normally in Audacity or play it in Miles.

 

Fortunately, the game doesn't need the header to play the files, so if you're adding an edited sound file to the game, just stick the file in RAW .wav format into the right folder and you're done.

Share this post


Link to post
Share on other sites

I have a problem with VO audio files in K1 and was hoping that you might be able to help me.

 

Last summer, when I last edited vanilla VO files, I simply renamed them from .wav to .mp3 and they would play just fine. I could then import them to Audacity and do whatever I wanted.

But now, none of these play anymore. Instead I get static noise in VLC or silence in Windows Media Player. Neither can I edit them in Audacity.

 

I'm probably missing some codec or something but I've no idea which one, so any help would be very appreciated.

Share this post


Link to post
Share on other sites

Just to be safe - could you tell me which files you're trying to open? I should check that they work for me.

Share this post


Link to post
Share on other sites

From a quick sample, it looks like the K1 voice files have a fake header of 199 bytes. You can batch convert them with DD - http://www.chrysocome.net/dd (scroll to the bottom of the page).

 

Put the source WAVs and DD in a folder together, open a command window (Start -> Run -> CMD), navigate to the folder, then put in this:

for %F in (*.wav) do dd if=%~nF.wav of=%~nF.mp3 bs=1 skip=199
That will trim the fake headers.

 

If you want to turn it into a batch file instead, you need to change it slightly:

for %%F in (*.wav) do dd if=%%~nF.wav of=%%~nF.mp3 bs=1 skip=199
pause
Paste that into a text file, save it out as xxx.BAT, put it in the same folder as the files and double click. The "pause" at the end isn't strictly necessary, but it will leave the window open with a "press any key to continue" so you can see what happened.

 

Edit: Or, if you want something where you can enter whatever number of bytes you want to trim, try this:

@echo off
set /p byteno="Please enter the number of bytes to trim from the header: "
for %%F in (*.wav) do dd if=%%~nF.wav of=%%~nF.mp3 bs=1 skip=%byteno%
pause
Alternatively, install Cygwin - https://www.cygwin.com/setup-x86.exe or https://www.cygwin.com/setup-x86_64.exe - making sure to enable XXD in the package list, download the bash scripts I linked to earlier, https://gist.github.com/shmerl/2cec6273ba25dd1486dd and https://gist.github.com/shmerl/30412cda5a5107132a1f, copy the K1 and TSL music files to separate folders under the Cygwin Home directory (e.g. \cygwin64\home\<username>\) and put the appropriate SH script in each. Now open a Cygwin terminal, navigate to the particular music folder (you can use CD to change directory, the same as DOS) and run the bash script using "./", for example,

./gog_kotor_extract_music.sh
  • Like 1
  • Thanks 2

Share this post


Link to post
Share on other sites

@ bead-v: I tried several files but one example is NM15ACJUHA07000_.wav

 

@ Darth Parametric: I'll give this a shot. Not quite sure why this is necessary though as simply renaming worked last time I tried this.

Share this post


Link to post
Share on other sites

If you do it this way then you won't have any problem regardless of what program you use. Just make sure you are trimming the right number of bytes.

Share this post


Link to post
Share on other sites

DarthParametric: That's an intriguing sounding program! I look forward to playing with it when the computer is rebuilt. (Ordering the rest of the parts today, I believe.)

Share this post


Link to post
Share on other sites

Thank you very much. Your solution worked perfectly :)

Is there anything I need to do to get my edited files working ingame or would I just save them as raw .wav?

  • Like 1

Share this post


Link to post
Share on other sites

That's an intriguing sounding program!

It's the program used in those bash scripts for Linux I posted earlier in the thread (it's a standard inclusion in Linux packages I believe). I didn't realise at the time that someone had compiled a version for Windows. I was messing around with trying to do the batch trimming in Powershell when I saw mention of the Windows binary.

 

Is there anything I need to do to get my edited files working ingame or would I just save them as raw .wav?

I'm not sure to be honest, I haven't had much to do with audio mods.

Share this post


Link to post
Share on other sites

 

I'm not sure to be honest, I haven't had much to do with audio mods.

 

Exporting .wav from Audacity worked. I think those are raw .wav files so the answer is proabably yes.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this