Jump to content

[Abandoned] Wav to snr converter

Recommended Posts

As announced in our 11th community update, we decided to open source wav_to_snr (repository link). This is a very simple application that allows you to convert audio files to a format that is compatible with BattleForge called SNR.

SNR is compressed a lot, and it is lossy compression (over 70% of data is lost). Sample count is the same as WAV, but for most samples only 4 bits instead of 16 bits is used for the value, that means 16 possibilities instead of 65536 possibilities. It is not that bad as it might look at first look. There is some function (difference from previous 2 samples) applied so the dynamic range does not need to be that big, and only precision is lost.

Currently it works this way: for each block of 32 consequent samples it tries all "configurations" and calculates all samples in the block, then pick the one that have on average smallest difference from the original sound. The problem with this is that if the original audio is decreasing at the end of block, but the compressed one is increasing it, it can still be the one with smallest difference, and if next block start lower than the source, the difference between the last sample of the block and first sample of the next block will be even greater because of that.

In theory "configuration" should be picked so that whole audio wave is as similar shape as possible, instead of absolute difference for each sample averaged over independent blocks. But comparing shapes of waves is much more complicated thing, requires much more computation time, and what is most important it is much more complicated to write.

So if anyone will improve the algorithm it would be great 🙂 right now it is kind of unusable for voice 😞 but for some simple effects it sounds kind of maybe acceptable.

If you want to just play existing file check out:

Metagross31 and Kapo like this
Link to post
Share on other sites
  • 2 weeks later...

Sounds like a job for a Fourier transform. I will try to give it a look in the upcoming weeks once I get access to my Laptop that runs Labview again. I am not too familiar with audio formats and their compression methods but I've worked with image compression and proprietary file structures already, so I might be able to help out.

What programming language are you using? Not too comfortable with my programming skills but I'll make do.

Edited by Kaliber84
Kubik likes this
Link to post
Share on other sites

I am using Rust,and If I would buy LabView it would be my second most expensive software by far. For other audio files I think you can find enough documentation easily. Snr is different story thou 😞 there are linked resources in the repo, and the repo is trying to reproduce `EA XAS ADPCM` codec that is used by other BF files. We also know that EALayer3 (EL31 and I think L32P) are supported by BF. EALayer3 is mp3 with some bit changes (no I can not say what exactly those changes are 😢). https://bitbucket.org/Zenchreal/ealayer3/src/master/ is code that can for some mp3 files convert them to valid snr files, we recently discovered the (almost complete) set of conditions that the file needs to met to be correctly converted, and even thou mp3 claims compression of 75-95% it actually sounds better than our attempts to reproduce `EA XAS ADPCM` codec.

If you will have any questions about the formats, or any other question feel free to reach to me (preferably on discord, but forum also works 🙂 ).

Link to post
Share on other sites
  • 2 months later...
  • Majora changed the title to [Help Needed] Wav to snr converter

I know this one got overshadowed a bit by the new-patch-hype, but we would greatly appreciate the help from the community for making the implementation of voicelines possible. We already have two cards fully recorded and ready to go, with others in various stages of recordings, but they are currently on hold because of the mentioned issues. 

Please help us out 🙂 

Kubik and Kapo like this
Link to post
Share on other sites
  • Zyna changed the title to [Abandoned] Wav to snr converter
  • Zyna unpinned and unfeatured this topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Terms of Use