当前位置:网站首页>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.
边栏推荐
- AcWing 1282. Search Keyword Problem Solution ((AC Automata) Trie+KMP)+bfs)
- 10 Ways to Keep Your Interface Data Safe
- useragent怎么获取
- TestCafe总结
- C# 之 扑克游戏 -- 21点规则介绍和代码实现
- 2022 Android interview summary (with interview questions | source code | interview materials)
- 认识异常 (看完这篇你就懂了)
- 保证接口数据安全的10种方式
- 【Yugong Series】July 2022 Go Teaching Course 021-Slicing Operation of Go Containers
- [TypeScript] OOP
猜你喜欢
随机推荐
spark报错OutOfMemory「建议收藏」
20.支持向量机—数学原理知识
认识异常 (看完这篇你就懂了)
go mode tidy出现报错go warning “all“ matched no packages
flowable工作流所有业务概念
多线程之锁
BOW/DOM(上)
Golang go-redis cluster模式下不断创建新连接,效率下降问题解决
Go1.18升级功能 - 模糊测试Fuzz 从零开始Go语言
Golang 小数操作之判断几位小数点与四舍五入
每日练习------随机产生一个1-100之间的整数,看能几次猜中。要求:猜的次数不能超过7次,每次猜完之后都要提示“大了”或者“小了”。
A common method and the use of selenium
【愚公系列】2022年07月 Go教学课程 020-Go容器之数组
MySQL---单行函数
JD.com searches for products by keyword API
华为手机一键开启“维修模式”隐藏所有数据,让手机隐私更加安全
MySQL---Basic select statement
手把手教你学会部署Nestjs项目
学生管理系统第一天:完成登录退出操作逻辑 PyQt5 + MySQL5.8
Huawei mobile phone one-click to open "maintenance mode" to hide all data and make mobile phone privacy more secure