Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Is There An Automated Intelligent Downsampling Tool? (Read 5126 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Is There An Automated Intelligent Downsampling Tool?

I have been working on a bunch of audio mods for XCOM 2, and recently I moved into music packs. UE3 requires WAV files, which is extremely unfortunate because it means increased RAM, storage and network consumption for users.

To this point I have been analyzing each file manually in Audacity and downsampling it to 22050 if there is not a significant amount of information above 11KHz. However, as I have become more ambitious I have begun working with more and more files. My current project has a little under 60, my next one is likely to have hundreds.

Given that I am really not looking forward to manually analyzing hundreds of files, I'm wondering if there is a tool that will do this automatically. Even something that could compare two spectrum analyses and discard one of them would do it (since I could downsample everything and then ask it to decide if the new file sounds the same as the old one). Any thoughts?

Thanks!

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #1
the simplest thing you could try is to put the audio through a highpass filter (or take the difference between original and resampled&upsampled back) and decide based on the loudness of what's left (relative to the loudness of the source, or not), loudness can be measured in ffmpeg: https://ffmpeg.org/ffmpeg-filters.html#loudnorm
a fan of AutoEq + Meier Crossfeed

 

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #2
the simplest thing you could try is to put the audio through a highpass filter (or take the difference between original and resampled&upsampled back) and decide based on the loudness of what's left (relative to the loudness of the source, or not), loudness can be measured in ffmpeg: https://ffmpeg.org/ffmpeg-filters.html#loudnorm

That makes sense. It's still largely manual, but it's not quite as significant a faff as analyzing every single file in Audacity.

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #3
It won't be manual if you automate it in a script. ffmpeg can be called from Python really easy, for example. I suppose that you can do some coding if you do game mods?
a fan of AutoEq + Meier Crossfeed

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #4
It won't be manual if you automate it in a script. ffmpeg can be called from Python really easy, for example. I suppose that you can do some coding if you do game mods?

The very short answer is yes, but my experience is pretty much nonexistent outside of a game engine framework. Even batch files are foreign territory. Still, nothing ventured nothing gained :)

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #5
It's very likely you will be able to do this if you want to.
Quote
Even batch files are foreign territory
But why "even"? Among higher level languages, that's one of the hardest languages to use. (btw, it's about the same with bourne shell / bash)
FWIW, they are foreign territory to me as well — I usually don't even try to use bash (if it is not trivial enough to be a simple one liner without any logic, like calling a few programs, passing the output from one to another). Unless it's already written in bash by somebody else and I need to do a small fix…
a fan of AutoEq + Meier Crossfeed

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #6
It's very likely you will be able to do this if you want to.
Quote
Even batch files are foreign territory
But why "even"? Among higher level languages, that's one of the hardest languages to use. (btw, it's about the same with bourne shell / bash)
FWIW, they are foreign territory to me as well — I usually don't even try to use bash (if it is not trivial enough to be a simple one liner without any logic, like calling a few programs, passing the output from one to another). Unless it's already written in bash by somebody else and I need to do a small fix…

Really? I guess I see .bats as being so pedestrian and utilitarian that they seem like they should be the quick easy path to some tasks. That makes me feel better about giving up last time I tried to write one.

I have the documentation open. Once I finish making the hyper-TIS-100 esotericness of the sound cue editor understand my current loops I'll have a bash... I mean go at it. Thanks for the advice!

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #7
Really? I guess I see .bats as being so pedestrian and utilitarian that they seem like they should be the quick easy path to some tasks. That makes me feel better about giving up last time I tried to write one.

I have the documentation open. Once I finish making the hyper-TIS-100 esotericness of the sound cue editor understand my current loops I'll have a bash... I mean go at it. Thanks for the advice!
They are easy but only for some tasks. Actually this one could be doable, but you will likely need to parse text (to get the results of loudness analysis from ffmpeg) and I can't tell without googl'ing how easy it is in .bat or bash.
For tasks which aren't completely trivial, .bats are a booby trap.
But I can tell that it's a piece of cake in Python (3) if you know the basics of the language and can search the web well. It has proper documentation and a lot of resources on the web, and in general has sensible design.
a fan of AutoEq + Meier Crossfeed

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #8
WAV is just a container format, beside PCM it supports other coding schemes like ADPCM and even MP3 - perhaps UE3 supports such variations? You can download sample files on wikipedia's WAV article and test that.
Eventually you could compress the files for distribution and make the installer decompress them to WAV.

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #9
WAV is just a container format, beside PCM it supports other coding schemes like ADPCM and even MP3 - perhaps UE3 supports such variations? You can download sample files on wikipedia's WAV article and test that.
Eventually you could compress the files for distribution and make the installer decompress them to WAV.

That's very interesting, I didn't know that! I actually remember listening to all of those Wikipedia examples once, but evidently it didn't leave an impression.

I just did a test, UDK does not support the example Mp3 files. It actually applies its own compression and processing after import, so I suspect that they really do just want PCM and weren't going to pay for the rights to implement an Mp3 decoder. I believe it's some kind of Ogg derivative, but in any case at the default "40%" quality setting (where 100% is least compression) a 3:40 song is around 40 MB.

On a related note, I don't know how one produces an Mp3 containing WAV short of writing your own header. Every program I have used assumes that WAV means LPCM.

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #10
If you're on Windows, I remember VirtualDub (a video editor) could write these WAVs with "surprising" codecs. But that could be not the most direct way to do that.

Also if that statement (UE will re-compress your music into Vorbis anyway) is true, then you should not resample, it will likely only do harm without any profit in the end.
a fan of AutoEq + Meier Crossfeed

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #11
SoX (Sound eXchange) supports several WAV coding schemes. It also might be usable for your original scenario - it can filter, resample, change bit depth, do spectral analysis etc. But as already said I'd rather stick to the inbuilt UDK lossy format, if it's OggVorbis derivative then you can go really low on bitrate without losing much quality.

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #12
MP3-inside-WAV was famous in the beginnings of MP3 (late 90s), and its sole function was to distribute small files that could be played by the default windows media player, or even in a webpage using Internet explorer, and the media player as an ActiveX control. (because windows itself included the frauhoffer mpeg audio layer 3 decoder).

In order to create them, the only thing that was needed was an application that could record to wav using the system codecs, and allowing to choose the codec.  And of course, it also required the frauhoffer mp3 encoder as a system codec. (of which, a pirated version circulated at that time).

Nowadays, there are other general purpose tools that can generate them, but are mostly a thing of the past (like AVI videos with DivX and MP3, or flash videos).

On another note, ~40MB for a 3:40 song length sounds like an uncompressed PCM at 44Khz 16bit stereo.  (general rule of thumb is 10MB per minute.   1.441Mbit = 176400Bytes/s = 10.33MB/minute ).  A similar rule of tumb was 1MB/minute for 128kbps MP3 files.

And yes, if you had some background in writing shell scripts ( .bat/.cmd in this case), tools like sox or ffmpeg can do what you want easily.

But as a GUI tool, You might be interested in mediacoder. It has an audio-only version that includes a resampler, so you should be able to convert to wave in batch while changing the sampling rate
http://www.mediacoderhq.com/audio/

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #13
On another note, ~40MB for a 3:40 song length sounds like an uncompressed PCM at 44Khz 16bit stereo.
Yep noticed that too, nintendoeats: it looks like you're doing something wrong - that 40% quality setting doesn't seem to get applied...

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #14
Allow me to expand on the internal compression and what I think is happening. There is very little public documentation out there on the Unreal 3 sound system, so this is mostly conjecture.

When you import a WAV it saves the whole thing in the mod package. It then also creates a vorbis copy, I suspect for use on platforms with limited RAM. Because mods are only for the PC it's entirely possible that the ogg files are never used. We know that it must create some kind of compressed file because adjusting the compression level setting for a WAV makes the overall package size bigger or smaller.  We know that it must be storing the entire WAV because package files are huge, and it is possible to adjust the compression setting in both directions at any time. This conversion is just part of the import process, it happens automatically. You also cannot import an ogg directly.

I should further say that downsampling files for use with UE3 is industry standard practice.

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #15
What if you manually remove the WAV files from the package? Will it make it use Vorbis files on PC or will it just break down?
a fan of AutoEq + Meier Crossfeed

Re: Is There An Automated Intelligent Downsampling Tool?

Reply #16
What if you manually remove the WAV files from the package? Will it make it use Vorbis files on PC or will it just break down?

It's all or nothing. The only reason that I know that it is saving an Vorbis version is that there is a line in the browser with the word Ogg in it. See an example of the content browser attached to this post. The whole system is known to be clunky and inefficient. The engine is over 15 years old and from what I am able to tell commercial game studios don't even use the built-in audio system anymore. In fact, my project for today is looking into using the Wwise system that Firaxis themselves used to do the XCOM 2 audio (because of the improved cue system, not because of file sizes).