XNB Size for Sound Effects

Hello everyone! I’m currently developing an Android game with Monogame, and as I was about to upload my aab file, I found out that it is over 100mb too big. After a lot of digging around, I found that the main cause for the size is due to giant xnb files made through the content builder. More specifically, anything that is built as a sound effect becomes massive.

I have several songs that I built as sound effects for features such as looping and playing stuff simultaneously, and these are causing the majority of the problem.

Does anyone know a way to reduce the sizes of the sound effect xnbs without ruining their quality, or why they are so big compared to songs? I am considering trying to make a workaround by building them as songs instead, but thought I’d see if there was a better alternative first.

1 Like

Change the audio quality in the properties in the content editor maybe?

Thanks for the quick reply!

I actually tried that in the Windows version, but it gave me an error. (I have a Windows version so I can test without needing an Android device or emulator.) Just tried again in the Android version and it works, but the audio sounds pretty bad now. I might just have to make the audio files smaller before building them into xnbs. Hopefully I can reduce the size that way without losing too much quality.

You could try including the raw sound files and loading them with SoundEffect.FromFile instead of having them in the content project.

I have not tried it myself, but my understanding is that it will let you use your original files at the cost of longer load times.

I am not exactly sure, but I think, most file formats will get packed as WAV - which just makes them very big.

Not sure about “aab” and how wide it is supported on the different systems monogame can build to.

Have you tried using a different format? I think I always went with ogg files and that went well enough for me … maybe someone here, knows which file formats will work best

As far as I know .WAV is uncompressed and huge and the reason monogame doesn’t use something compressed like .mp3 is because you have to pay a licensing fee to release a game using it. I have switched to using ogg vorbis because I’m under the impression that it’s compressed and free but I had to find a library to load and play them in windows and am not sure if it’s available on android.

Thanks for the suggestion! I was actually planning on working on this today, so I will try this first and see how it goes.

All my sound files are currently in ogg format. Aab is actually the android package. It is like an alternative to an apk. (Google Play won’t be accepting apks in the near future according to what I’ve read.) I think I also read that aabs allow 150 mbs while apks allow 100.

I am also using ogg vorbis for the same reasons: small sizes and no fees. My problem seems to be when the content builder turns them into xnbs. When they build as “soundeffects” they just get massive for some reason.

Just gave this a try, but it seems it’ll only read wav files this way.

Yeah the trick is to not content build them and then load and play them yourself outside of monogame. If the files are long make sure you are streaming them instead of loading the whole thing to play it.

Thanks for the reply! Is there any chance you could explain this process in more detail? I tried loading the sounds with SoundEffect.FromFile like Peewi said, but it would only accept wav files, which are just as big as the xnbs from the ogg files.

I’m not exactly sure how to do it with android but heres what I did for windows (note you will have to replace the audio stuff for every target operating system you have):

  1. In Visual studio you need to reference the monogame code for android directly instead of a dll / lib.
  2. Figure out how to get your music files to copy to the output directory instead of running them through the content compiler (I just copy them manually).
  3. Look into the monogame for android source code and figure out how they call android system functions.
  4. Don’t use the monogame audio code at all and learn how android does audio then add code to the monogame android project that will call android audio system the way you want.

Honestly. It is hard to come up with a worse solution.

@Jaredk105 Here’s what you should actually do. Either use Compress option from mgcb editor, or use something like FMOD.

Thanks for the detailed explanation. So would that mean I would have to play the music using something other than Monogame’s Song and SoundEffect classes?

Thanks for the suggestions. I’ve tried compress, but it doesn’t seem to do anything. I might try the FMOD thing, but I will need to look into it more.

Yes

Celeste uses FMOD, so, get hunting, err or climbing?

I wish there were more information on using these third-party tools…