> For the complete documentation index, see [llms.txt](https://sonity.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sonity.gitbook.io/docs/how-to-guides/optimize-audioclip-settings.md).

# Optimize AudioClip Settings

How to optimize the settings of your AudioClips to use less RAM and CPU

Here are some settings you’d want for most games get lower RAM usage, disk read and CPU usage.\
Read more about the other settings here: [Unity Manual - AudioClip](https://docs.unity3d.com/Manual/class-AudioClip.html).

#### **AudioClip - Overall Settings**

**Compression Format:** Vorbis\
**Quality:** 60. Which is \~192 kbit/s for Vorbis. You can go lower if you’d want to save space but it comes at a loss of quality.\
**Sample Rate Setting:** Should be the same as the sample rate of the platform, which today mostly is 48kHz (this is so that it doesnt have to do a sample rate conversion) when playing.\
Also, if the sounds are created in 48kHz there is more high frequency content which makes it sound better when pitching down vs 44.1kHz.

{% hint style="info" %}
❕ Tip: If you select multiple AudioClips, you can see their total “Imported Size” which is the size they’ll have after all your format and quality settings are applied.
{% endhint %}

#### **AudioClip - Vorbis Quality**

Unity Vorbis Quality 1 is VBR Quality 0 (not -2). Mono is half the bitrate of stereo and 4 channel files (for surround) are twice the bitrate of stereo.

<table data-header-hidden data-full-width="true"><thead><tr><th width="112.9832763671875"></th><th width="117.74989318847656"></th><th width="107.233154296875"></th><th width="112.26666259765625"></th><th width="114.46673583984375"></th><th width="62.816650390625"></th><th width="69.0001220703125"></th><th></th></tr></thead><tbody><tr><td><strong>Unity Vorbis Quality</strong></td><td><strong>VBR Target kbit/s stereo</strong></td><td><strong>VBR Target kbit/s mono</strong></td><td><strong>VBR Range kbit/s stereo</strong></td><td><strong>Noise Test kbit/s stereo</strong></td><td><strong>Size vs 10</strong></td><td><strong>Size vs 60</strong></td><td><strong>Comment</strong></td></tr><tr><td>100</td><td>500</td><td>250</td><td>500 - 1000</td><td>554</td><td>100%</td><td>260%</td><td>Uneccessarely big, don’t use this</td></tr><tr><td>90</td><td>320</td><td>160</td><td>320 - 500</td><td>435</td><td>64%</td><td>167%</td><td>Uneccessarely big</td></tr><tr><td>80</td><td>256</td><td>128</td><td>256 - 320</td><td>382</td><td>51%</td><td>133%</td><td>Use if you want to mazimize quality &#x26; have the disk space and RAM</td></tr><tr><td>70</td><td>224</td><td>112</td><td>224 - 256</td><td>309</td><td>45%</td><td>117%</td><td></td></tr><tr><td>60</td><td>192</td><td>96</td><td>192 - 224</td><td>232</td><td>38%</td><td>100%</td><td>Use this as a default, it is a good balance between quality and size</td></tr><tr><td>50</td><td>160</td><td>80</td><td>160 - 192</td><td>173</td><td>32%</td><td>83%</td><td><a href="https://xiph.org/vorbis/faq/#quality">Sounds like near CD quality</a></td></tr><tr><td>40</td><td>128</td><td>64</td><td>128 - 160</td><td>128</td><td>26%</td><td>67%</td><td></td></tr><tr><td>30</td><td>112</td><td>56</td><td>112 - 128</td><td>117</td><td>22%</td><td>58%</td><td><a href="https://xiph.org/vorbis/faq/#quality">Smaller &#x26; better sound than .mp3 128kbps</a></td></tr><tr><td>20</td><td>96</td><td>48</td><td>96 - 112</td><td>102</td><td>19%</td><td>50%</td><td></td></tr><tr><td>10</td><td>80</td><td>40</td><td>80 - 96</td><td>87</td><td>16%</td><td>42%</td><td>Sounds acceptable. Use if you are desparate for saving space and RAM</td></tr><tr><td>1</td><td>64</td><td>32</td><td>64 - 80</td><td>71</td><td>13%</td><td>33%</td><td>Looses a lot of quality, noticeably stereo separation and bass</td></tr></tbody></table>

Notes: Noise test is calculated using VBR export & size comparison to CBR with a known bitrate.\
Sources: [Recommended Encoder Settings](https://wiki.hydrogenaudio.org/index.php?title=Recommended_Ogg_Vorbis#Recommended_Encoder_Settings) and [Vorbis Quality](https://xiph.org/vorbis/faq/#quality). The bitrates are approximate.

#### AudioClip - Load Type

Stereo files are double the size of mono files. So a 60s 2 channel sound is the same size as a 120s 1 channel sound. The lengths are approximated with stereo files in mind.

<table data-header-hidden data-full-width="true"><thead><tr><th width="186.61676025390625"></th><th width="132.80010986328125"></th><th width="110"></th><th width="90.66656494140625"></th><th width="218.24981689453125"></th><th></th></tr></thead><tbody><tr><td><strong>Length Seconds ~</strong></td><td><strong>Play Frequency</strong></td><td><strong>Load Type</strong></td><td><strong>Pros</strong></td><td><strong>Cons</strong></td><td><strong>Example Sounds</strong></td></tr><tr><td>Short - Less than 1s</td><td>High</td><td>Decompress On Load</td><td>Uses less CPU</td><td>Uses 10x RAM so only use for short sounds.</td><td>Player sounds, footsteps, impacts etc. Commonly used for mobile platforms</td></tr><tr><td>Short - Less than 1s</td><td>Low</td><td>Compressed In Memory</td><td>Uses less RAM</td><td></td><td></td></tr><tr><td>Medium - More than 1s<br>less than 60s</td><td>High &#x26; Low</td><td>Compressed In Memory</td><td>Uses less RAM</td><td></td><td></td></tr><tr><td>Long  - More than 60s</td><td>High</td><td>Compressed In Memory</td><td>Uses less disk read</td><td>Try if you have problems with audio delays. Watch out for load times and RAM usage</td><td>Localized 3D ambiences etc</td></tr><tr><td>Long  - More than 60s</td><td>Low</td><td>Streaming</td><td>Uses less RAM</td><td>Many platforms can only handle less than 10 simultaneously streaming sounds</td><td>Music, background 2D ambiences etc</td></tr></tbody></table>

Note: You want to stream the largest files you have, but not too many at the same time.\
So the 60s threshold for long sounds can be lowered to e.g. 30s or even lower if not many sounds are +60s.

**AudioClip - Preload Audio Data**\
Makes the sound load at startup, which might create long load times on harddrives and slower systems.\
Is useful to combine with Load In Background so it doesn’t interrupt the main thread.

<table data-full-width="true"><thead><tr><th width="168.74993896484375"></th><th width="97.683349609375"></th><th width="100.70001220703125"></th><th width="116.99993896484375"></th><th width="212.1500244140625"></th><th></th></tr></thead><tbody><tr><td><strong>Length in seconds</strong></td><td><strong>Play Frequency</strong></td><td><strong>Preload Audio Data</strong></td><td><strong>Pros</strong></td><td><strong>Cons</strong></td><td><strong>Example Sounds</strong></td></tr><tr><td>Short - Less than 1s</td><td>High</td><td>Yes</td><td>Less frequent disk read</td><td>Use only for frequent &#x26; short sounds. Combine with Load in Background</td><td>Player sounds, footsteps, impacts etc</td></tr><tr><td>Short - Less than 1s</td><td>Low</td><td>No</td><td></td><td></td><td></td></tr><tr><td>Medium &#x26; Long - More than 1s</td><td>Low</td><td>No</td><td></td><td></td><td></td></tr></tbody></table>

Note: I’ve had problems where if I don’t Preload Audio Data, there might be clicks heard in the end of sounds.\
"Prevent End Clicks" in the [SoundContainer](/docs/soundcontainer.md) mitigates this.

**AudioClip - Load In Background**\
When enabled, the AudioClip is loaded without stalling the main thread and any playing is delayed until the AudioClip is loaded.\
Useful to combine with Preload Audio Data so it doesn’t interrupt the main thread.
