Audio Basics Crash Course

Audio is a easy to overlook when it comes to optimization and setup. It can sometimes feel like a black box. In this guide I’ll show you what are some general best practices. Also look as the prefabs database as there some nice already set up configurations for things such as 2D (world) audio.

Import settings:
This by far is one of the easiest things to mess up. My personal preference is to import the audio in PCM (.wav) format, but it will accept multiple formats. Avoid importing mp3 if you can. Unity will take care of compression if you need it. If you really need the file sizes to be small use a external editing software such as audacity or reaper and export as ogg vorbis, you can choose the compression quality during export. Unity also has the ability to choose quality, its passable, but it doesn’t hold up at very low quality.

Once you have the audio imported into Unity simply click on it in your assets to bring up its import settings in the inspector.

I won’t go over the top four options since you can hover over the option to get a description, but I will say that if you plan to use the sound as spatialized audio, and the audio file is in stereo (it will have two waveforms in the preview), set it as mono. The right track of the stereo file is ignored if it is spatialized.

I will go over the box section, this is how the audio file is loaded and stored. The Default box will by default be selected, if you are making Quest content click the android icon for those settings.

Load type is incredibly import. By default if is set to decompress on load. That setting will take a audio that is compressed and decompress it and store the uncompressed audio file into ram. This is not optimal for most use cases. Compressed in memory loaded the compressed audio file into ram, and decompresses it on the fly. Streaming keeps the audio file on the disk and decompresses it on the fly.

How you decide to have the audio load is incredibly subjective. There are factors such as file length, amount of times called, and file type play into your choice.

Compression format another topic of importance. Vorbis (ogg) is a lossy compressed format that yields good quality and small file size. The downside is that it is very cpu intensive. On quest, use the android override, when you would use Vorbis, use mp3. Long audio files should defiantly use vorbis. PCM is uncompressed, it is basically free on the cpu and has incredible quality, but it will be large in file size. Great for really short audio files. ADPCM is lower in quality, but also small in file size. Use it if you really need to save download size. Its great for noisy sound effects.

With this info hopefully you should have a good idea of what type of import settings to use.

Audio source:
The audio source combined with the VRC_Spatial Audio Script can sometimes feel like a black box. My general rule of thumb is to add the Spatial Audio script and keep its default gain and far settings. Show the advanced options and enable Use Audio Source Volume Curve or untick Enable Spatialization for 2D (world) audio.

The audio source component has some quirks which are as follows. The Bypass ticks do not work, they are overridden in game. Priority should always be changed from default, doppler also is overridden in game.

Logarthmic Rolloff is the most realistic type of falloff, but I recommend using a custom curve that brings the source to 0 when it gets too quiet. If too many audio sources are playing at once, it can cut off players voices when they speak. You can use the curve to adjust spatial blend to hide the audio origin.

Other aspects of audio source work as intended so be sure to hover over the option to get a description or read up on unity documentation.

I wrote this guide in a hour hyped up on coffee and black tea so I’ll fix my typos and ramblings later. I wanted to get this out quickly.

6 Likes

If you do not want to have a specific location you can create a 2D to 3D transition. These settings are just a example to demonstrate the concept. The most important settings are the VRC_Spatial_Audio_Source settings and the extreme values on the curves, not the shape of the curves themselves.