Optimizing sound memory limit

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Jedi
User avatar
Posts: 1205
Joined: Mon Mar 21, 2011 8:12 pm
Location: STALKER!
Projects :: Star Wars Battlefront - Tides of War
Games I'm Playing :: SWBF2 RC EAW
xbox live or psn: I have ps4

Optimizing sound memory limit

Postby ARCTroopaNate » Fri Jun 22, 2018 2:35 pm

I'm working on an era mod, and I've run into what I believe is the sound memory pool limit on some maps. Right now I'm loading in some stock weapon sounds (Tri-shot sound in GCW era for example). While also loading in the stock sound file for each map. Is there any way I can optimize things so I can load more than just a few extra sounds on a map before it hits the limit? Thanks.

Resistance Leader
User avatar
Posts: 5103
Joined: Tue Feb 09, 2010 8:43 pm
Location: Greater Seattle Area
Projects :: EVERYWHERE + Zero Munge + TCW
Games I'm Playing :: Civ3 + DEHR
xbox live or psn: Marth8880

Re: Optimizing sound memory limit

Postby Marth8880 » Fri Jun 22, 2018 6:59 pm

Well sure.

ARCTroopaNate wrote:While also loading in the stock sound file for each map.

Don't do this. :P However, if you don't want to recreate your own stock sound LVL that uses only the stock sounds that you need...

Which stock sound LVL is it? If anything, it should be one from a map that has as few unique sounds as possible, i.e. no vehicles and few ambient SFX emitters - I believe Coruscant is the best option for that.

ARCTroopaNate wrote:Is there any way I can optimize things so I can load more than just a few extra sounds on a map before it hits the limit?

Figure I might as well come up with a "checklist" for optimizing sound memory usage when adding custom sounds:

  • Looping sounds should only be as long as they absolutely need to be in order to not sound too obviously repetitive. However, when shortening loops, you should always make sure that the end result is a seamless loop - not always the easiest thing to do, but I find that it tends to be best if you trim the ends of the track so that the waveforms in the beginning and end of the track look like they more-or-less connect and flow together - or alternatively you could try crossfading the beginning and end of the track together, but this tends to sound a lot worse in my experience. :P

  • When exporting sound effects from Audacity, you should always export them at the highest possible sample rate, i.e. the sample rate that the sound was imported in, or the sample rate of the audio track with the highest sample rate if it's a multitrack project. With that said, every WAV file you reference in your sound bank should be resampled in the ASFX file (do not do it in Audacity) to the lowest sample rate possible while still retaining the fidelity necessary for it to not sound obviously muddy.
    • The best way to determine the lowest possible rate is to import the sound in Audacity and listen to the sound at various sample rates by adjusting the Project Rate (bottom-left corner of the application window). I strongly recommend using a good pair of headphones for this
    • You don't have to use a standard sample rate (like 22050, 44100, 48000, etc.), you can technically use whatever value you want - e.g. most of the voice chatter SFX in MEU is resampled to 24000. In fact, sounds like really super-low booms that are layered into explosions and whatnot should almost always be resampled to a value <500.
    • There's honestly not usually any real need to use sample rates >32000ish for sound effects that are played in 3D space during battle (like weapon fire, or foley especially). Over the years, I've noticed that the higher-ranged tones tend to be drowned out drastically by all of the other sounds that are playing.

  • You should go through all of your custom sound effects and make sure that none of them have any "silent ends" like the one in the following example:

    Image

    All of that highlighted track is nothing but silence. Because WAV files are uncompressed, this is a *huge* waste of sound memory. As it is, that WAV file is 431 KB, which is also how much sound memory it uses. However, deleting all of that unnecessary, wasted space brings the WAV file down to 158 KB. As one may expect, this applies to the beginning of sound files just as well. With all of that said, it is very important to note that when deleting wasted space like that, you should take care not to accidentally delete any non-silent bits, like at the very end of a fade.


And finally, a couple relevant snippets from an e-mail exchange I had with psych0fred back in 2012:

psych0fred wrote:There's no limit to the number of sounds but there is a limit to the amount of sound memory available.
When building the shipped game we used as much memory as needed so each level does not have that much available.
For mods you should start by using a level that has the same assets/vehicles you want with as much memory available as possible if you want to add more. Most people start with a level like COR since there's no vehicles. I don't recall the command but you can try soundmem or just ht tab to tab through all of the command line commands until you find it.

psych0fred wrote:If you run out of sound memory, some or many of the sounds that fit into memory may still play, but with random corruption or errors. When you run out of memory lots of weird things can happen to the sounds. What you should do is start with a level like COR and then add your new/additional sounds 1 at a time, changing/adding only 1 thing at a time so when things break you know exactly why. You can also look at the BF1 mod tools and the DataTAT3 folder (under Assets\Shipped Add On). That was the first implementation of additional sounds and the foley setup should function the same way as what you are trying to do even though it's BF1.

Jedi
User avatar
Posts: 1205
Joined: Mon Mar 21, 2011 8:12 pm
Location: STALKER!
Projects :: Star Wars Battlefront - Tides of War
Games I'm Playing :: SWBF2 RC EAW
xbox live or psn: I have ps4

Re: Optimizing sound memory limit

Postby ARCTroopaNate » Sat Jun 23, 2018 12:31 pm

Thanks for the detailed response Marth.

To be clear on the stock sounds, my lua setup for each map looks like this (on geonosis for example)

ReadDataFile("dc:sound\\tow.lvl;towcw")
ReadDataFile("sound\\geo.lvl;geo1cw")

I'm a little confused as to what you're suggesting I do with this, are you suggesting I recreate each of the stock map sound lvls using only the sounds I need?

I'm also not loading in custom sounds as of now, it's just stock bf1 and bf2 sounds (thanks for those btw) used in different eras, do you know if these are already optimized for file size and silent ends or should I go through and fix these?

I did notice some of the stock explosion layered sounds at high rates but also a couple at like 300, I'll drop the others down to 300 and see if that helps, additionally dropping the 44000 to 22000 should help.

Thanks for the help with this, tbh kind of posted this one with the hope you'd reply, not a lot of folks around here good with sounds (myself included).

EDIT: Wow, just resampling in the asfx file cut my file size down like 95%

Return to SWBF2 Modding

Who is online

Users browsing this forum: No registered users and 1 guest