当前位置:网站首页>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.
边栏推荐
- Introduction of Jerry voice chip ic toy chip ic_AD14NAD15N full series development
- MySQL---aggregate function
- Chinese encoding Settings and action methods return values
- go基础部分学习笔记记录
- matplotlib ax bar color Set the color, transparency, label legend of the ax bar
- 多线程之锁
- AcWing 1282. 搜索关键词 题解((AC自动机)Trie+KMP)+bfs)
- Masterless Replication System (3)-Limitations of Quorum Consistency
- MySQL---多表查询
- UserAgent 解析
猜你喜欢
1161. 最大层内元素和 : 层序遍历运用题
go基础部分学习笔记记录
九齐ny3p系列语音芯片替代国产方案KT148A性价比更高420秒长度
【码蹄集新手村600题】通向公式与程序相结合
手把手教你学会部署Nestjs项目
The new telecom "routine", my dad was tricked!
MySQL - single function
35 MySQL interview questions and diagrams, this is also easy to understand
Combinatorics Notes (6) Associative Algebra of Locally Finite Partially Ordered Sets, Möbius Inversion Formula
架构师04-应用服务间加密设计和实践
随机推荐
微信小程序的路由拦截
MySQL---子查询
华为手机一键开启“维修模式”隐藏所有数据,让手机隐私更加安全
移动web开发02
Golang——从入门到放弃
TestCafe总结
无主复制系统(3)-Quorum一致性的局限性
如何才能真正的提高自己,成为一名出色的架构师?
全平台GPU通用AI视频补帧超分教程
【愚公系列】2022年07月 Go教学课程 020-Go容器之数组
Masterless replication system (2) - read and write quorum
浅谈网络安全之算法安全
GateWay实现负载均衡
Golang 切片删除指定元素的几种方法
21.支持向量机—核函数的介绍
How to change npm to Taobao mirror [easy to understand]
Go record - slice
【愚公系列】2022年07月 Go教学课程 022-Go容器之字典
Apache EventMesh 分布式事件驱动多运行时
The article you worked so hard to write may not be your original