当前位置:网站首页>Introduction to Audio Types and Encoding Formats in Unity
Introduction to Audio Types and Encoding Formats in Unity
2022-07-31 18:32:00 【Chen's words must be done】
Introduction to Audio Types and Encoding Formats in Unity
The Inspector window displays several import settings.These settings determine: loading behavior, compression behavior, quality, sample rate, and whether binaural audio is supported.
One, load the audio file
Unity can specify how audio files are loaded through the following 3 settings:
- Preload Audio Data: On to automatically load audio data during scene initialization, off to defer key loading until the audio file is needed.
- Load In Background (loading in the background): On, the main thread is blocked until the background loading is completed, and when off, the background is asynchronously loaded.
- Load Type: The loading of audio files is further controlled by the load type, which will be described in detail later.
Second, Load Type: Load Type
Decompress On Load: This setting compresses files on disk to save space and decompresses them into memory on first load.This is the standard way to load audio files and should be used in most cases.
It takes a while to decompress the file, which causes additional overhead in the loading process, but reduces the amount of work required to play the audio file.
Compressed In Memory: This setting simply copies audio from disk into memory when it loads.Audio files are only decompressed during runtime when they are played.
This will sacrifice runtime CPU while playing audio clips, but will increase acceleration and reduce runtime memory consumption while audio clips remain asleep.
Therefore, this option is best for large audio files that are used frequently, or are stunned with incredible bottlenecks on memory, and are willing to sacrifice CPU cycles to play audio clips
Streaming: This setting will load, encrypt and play the file at runtime by gradually pushing the file through a small buffer where only a small portion of the entire file exists at a time.
This method uses the least amount of memory for a specific audio clip, but the most memory used by the CPU at runtime.Since each playback instance of the file requires its own buffer, this setup has the unfortunate downside of referencing an audio clip multiple times, resulting in multiple copies of the same audio clip in memory that must be processed separately, which if used haphazardlyCauses the runtime CPU to document.So this option is last for single-instance audio clips that play periodically, which don't need to overlap other instances of themselves or even other streaming audio clips.For example, this setting ends up being used with background music and ambient sound effects that need to be played most of the time in the scene.
Summary: By default, Preload Audio Data
is deprecated, Load In Background
is disabled, and Decompress On Load
is usedThe loading type of code> will cause the scene to take too long to load, but it will ensure that every audio clip in the scene is understood when needed.When an audio clip is required, there will be no loading delay, the audio clip will be played when Play()
is called.A good compromise to improve scene load time is to deprecate Load In Background
for audio clips that are only needed later, but this should not be used for audio clips that are required shortly after scene initialization.Then manually control the audio data loading time through AudioClip.LoadAudioData()
and AudioClip.UnloadAudioData()
.All methods can be used in one scene, and the best performance has been achieved.
Three, encoding format and quality level
Unity supports 3 audio clip encoding formats. You can view the audio clip properties in the Inspector panel summary. Which format is determined by the Compression Format option:
Compressed: The compression algorithm depends on the target platform used
- Vorbis: Lossy compression.Ogg's full name should be OGG Vorbis is a new audio compression format, similar to existing music formats such as MP3.But one difference is that it is completely free, open and patent-free
- MP3: Lossy compression.The same bit rate (Bit Rate) encoded OGG sounds better than MP3.The MP3 format is patent protected.
- PCM: Lossless uncompressed, providing near-analog audio effects.It trades a larger file size for higher audio quality and is suitable for extremely short and high-definition applications.
- ADPCM: Lossy compression, this format is much more efficient than PCM in terms of size and CPU consumption, but the compression can be quite noisy.For explosion, impact sound, you can ignore the noise.
边栏推荐
猜你喜欢
随机推荐
ThreadLocal
How can we improve the real yourself, become an excellent architect?
A common method and the use of selenium
Kotlin coroutines: continuation, continuation interceptor, scheduler
Handling write conflicts under multi-master replication (3) - Convergence to a consistent state and custom conflict resolution logic
useragent在线查找
Go record - slice
go mode tidy出现报错go warning “all“ matched no packages
leetcode:6135. 图中的最长环【内向基环树 + 最长环板子 + 时间戳】
cas与自旋锁(轻量级锁就是自旋锁吗)
Bika LIMS 开源LIMS集—— SENAITE的使用(检测流程)
MySQL---Create and manage databases and data tables
【愚公系列】2022年07月 Go教学课程 022-Go容器之字典
TestCafe之如何进行调试
Golang go-redis cluster模式下不断创建新连接,效率下降问题解决
Chinese encoding Settings and action methods return values
无主复制系统(2)-读写quorum
Flex布局详解
20.支持向量机—数学原理知识
中文编码的设置与action方法的返回值