nrlulz / ACF

Combat damage system for Garry's Mod
110 stars 118 forks source link

ACF size is ballooning due to giant .wavs #18

Open Bubbus opened 11 years ago

Bubbus commented 11 years ago

The sound folder is getting pretty ridiculous. ACF content is 586MB, of which 442MB is sound data.

I propose we compress all these sounds to .mp3 format. Source supports some high quality mp3s so we shouldn't lose out on audio clarity (though it doesn't matter for half of the sounds cause they're from youtube).

Me and Frohman entertained the idea in the past and discovered that appropriate compression can take the sound folder from ~440MB down to ~50MB. We'll need to update sound references to the new .mp3s, but it won't be more than a quick find+replace job. I think it's worth it.

Issues? I'll go ahead with it otherwise.

nrlulz commented 11 years ago

I think it's a good idea, the references within acf wouldn't be a problem. The only issue would be the references people have to acf sounds in e2s...

Bubbus commented 11 years ago

Yeah, I could drop a note in the ACF thread warning about this before I go ahead with it. Maybe drop a hint in a text file in the repo for people who don't check FP?

nrlulz commented 11 years ago

Definitely post a heads up in the thread but I don't think people are going to look for a text file in the addon... I guess go ahead and do it, it's better in the long run. Maybe you could upload the mp3s then delete all the wavs after a couple weeks or so to give people a chance to switch over without straight up breaking stuff.

Fervidusletum commented 11 years ago

Just a heads up, might want to check looping works fine with mp3s. I read somewhere that smooth mp3 loops are impossible because the format has a short, silent lead-in.

Another option might be to move the unused sounds that aren't a default for engine or weapon, etc, to a companion svn; since they don't change often you only really need to check the companion svn every now and then. Though that does still leave the problem of a gigantic download...

Bubbus commented 11 years ago

Thanks for the heads-up. I just tried to compress the engine sounds. I'm not convinced it's possible;

  1. Tried MP3 first. Played fine but no looping.
  2. Tried a utility called mp3loop (looped .wav converter). Played fine but no looping.
  3. Tried using .wav ADPCM compression. Did not play at all. What codecs does source support?

I'm going to use .mp3 on all the non-looping sounds but it's a shame about the engines because they're pretty huge (example, b6_petrollarge.wav 1.7Mb for 10 seconds). Would anyone mind if I cranked down the bitrate on these engine sounds?

Bubbus commented 11 years ago

The acf_extras sounds are a mess. Browse some of the horn sounds and see what I mean. In addition to compressing these sounds, can we just flat out dump some of them? Companion repo sounds like a great place to put them.

And the duplicates! who approved this brb OCD fit

nrlulz commented 11 years ago

Can wavs not be compressed? Or maybe lower rates if it doesnt make them sound like shit.

This might be useful: https://developer.valvesoftware.com/wiki/Looping_a_Sound

Bubbus commented 11 years ago

I've been down that route unfortunately. Seems that source doesn't support ADPCM .wav compression or looped .mp3s. Going to try some other codecs tomorrow and if that doesn't work out I'll figure out what bitrate I can drop to without hurting the sounds too much. After that I'll hunt duplicates. Can't spend more time on this because I'm being manhunted over missiles.

In good news I converted all the non-looping sounds I could find today, that's less than half of the sounds but I still managed to shave 100MB off.

nrlulz commented 11 years ago

Hmm, well according to that article it does support MS-ADPCM, is that different from ADPCM?

Bubbus commented 11 years ago

I used ffmpeg's adpcm_ima_wav format. I see an adpcm_ms codec too, will try tomorrow. That would be ideal because it has similar compression to .mp3 (per channel though)

nrlulz commented 11 years ago

Yeah that's another thing, all of these sounds can probably be flattened to mono if they have more than one channel... I don't see any point in having stereo sounds if the engine is going to be handling all the directional stuff anyway.

Ugh, there are caps in filenames too...

Bubbus commented 11 years ago

Good point. I'll need to find out what kind of effect stereo sounds have ingame. If none, squash time.

IMO the sounds are a mess right now. My opinion is that ACF assets should only be supporting ACF content and all these alternative sounds should be split off, especially considering the quality of some and the esoteric nature of others.

nrlulz commented 11 years ago

I agree, but I don't think everyone will with the argument that not everyone will install the extras on their client and thus will have missing sounds. Maybe also if we do split it, we can merge in the old "karbine's engine sounds" pack (since I think there are a lot of duplicate sounds from there), perhaps @Amplar can chime in on this? If he ever gets online again, lol.

Bubbus commented 11 years ago

If karb's engine pack is good, can we replace this mess with it? There's enough engine sounds in here to make GTA 6 with. I'll be happy trimming the sound folder under 100MB in any case.

Fervidusletum commented 11 years ago

I think most of the engine sounds (\sound\acf_extra\vehiclefx\engines\i4, \i6, etc) are from karb's pack.

Bubbus commented 11 years ago

I had a shot at MS ADPCM, comes out ingame as white noise. Ideally we'd have mono sounds with loop cues - tried flattening them to mono which does halve the filesize, but also scrubs the loop cues. Unless someone can point me at a wav converter that I can run in batch and also preserves the cues, I think splitting the extra sounds out is the only solution left. If we lose the acf_extra folder we lose more than 300mb. Not saying we can't re-add them if they get resubmitted in a compressed format.

nrlulz commented 11 years ago

Ok I'm just gonna take a vote on this. http://facepunch.com/showthread.php?t=1244349&p=40796369&viewfull=1#post40796369

nrlulz commented 11 years ago

New information! I don't think we want to flatten them all to mono, because according to this article, when distance sounds are implemented it uses the left channel for "near" sound and the right channel for "far" sound. Now I'm not sure if all the sounds have a far and near channel so some of them probably could be flattened (esp. the extras) but I know at least some of them do. So I'm gonna just wait on flattening any of them.

Fervidusletum commented 11 years ago

New information! It's looking like Garry is going to be implementing a new library for sounds, BASS (http://www.un4seen.com/). Might be new hope for looped mp3 or other compressed formats, assuming they seamlessly loop. Not to mention the other cool things we might be able to do with the library. (Perhaps a proper doppler effect for engines?)

http://facepunch.com/showthread.php?t=1276264&page=2

Bubbus commented 11 years ago

I started removing the unused sounds today, but there's a problem. Some codebase analysis done by Frohman/Em See shows that ACF uses 78 sounds, which leaves 953 unused sounds. The git command to "completely forget" about a file rewrites the entire commit history, for every file. This takes a lot of time and is a cpu-heavy process. I managed to process 48 of those unused sounds today, within two hours. I don't intend to do any more because of time + electricity cost + goddamn it's warm in here.

Does anyone have an off-site server/vps/whatever they can run this operation with? You need the ACF repo, this shell script and this text file (place both in repo root); https://dl.dropboxusercontent.com/u/902553/Misc%20Files/scrubsounds.sh https://dl.dropboxusercontent.com/u/902553/Misc%20Files/toremove.txt (thanks Frohman!)

Once you've completed that operation, force-push to the github with your copy of the repo (or try it out with another repo first if you're not sure)(or send the deflated repo to one of us if you don't have access). This operation should drop the files from the repo (and from the version history), without causing the files to be deleted next time folks update their ACF (at least, with git. IDK about svn). This will have a side effect of messing up people's forks (XCF :'( ), so give warning before you do this.

Once the sounds are gone from master, we can write an extras installation panel inside acf itself, using the new resource library. When they click on an install button, we can present the user with the workshop page for addons containing segments of the extra content and they can subscribe to it.

I can handle the installation GUI if someone wants to handle the git job. Thanks.