当前位置:网站首页>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.

边栏推荐
- MySQL - multi-table query
- matplotlib ax bar color 设置ax bar的颜色、 透明度、label legend
- 【AcWing】第 62 场周赛 【2022.07.30】
- rj45对接头千兆(百兆以太网接口定义)
- Golang——从入门到放弃
- MySQL---Basic select statement
- 手把手教你学会部署Nestjs项目
- 【Yugong Series】July 2022 Go Teaching Course 023-List of Go Containers
- JD.com searches for products by keyword API
- IP protocol from 0 to 1
猜你喜欢

MySQL---运算符

leetcode:6135. 图中的最长环【内向基环树 + 最长环板子 + 时间戳】

21.支持向量机—核函数的介绍

After Effects tutorial, How to adjust overexposed snapshots in After Effects?

MySQL - multi-table query

杰理语音芯片ic玩具芯片ic的介绍_AD14NAD15N全系列开发

Golang 小数操作之判断几位小数点与四舍五入
![[Network Communication 3] Advantech Gateway Modbus Service Settings](/img/ec/e9e1d9a374183ecaa8a8c9437ec82c.png)
[Network Communication 3] Advantech Gateway Modbus Service Settings

flowable工作流所有业务概念

MySQL---operator
随机推荐
matplotlib ax bar color 设置ax bar的颜色、 透明度、label legend
AcWing 1282. 搜索关键词 题解((AC自动机)Trie+KMP)+bfs)
ResNet的基础:残差块的原理
基于WPF重复造轮子,写一款数据库文档管理工具(一)
2022 Android interview summary (with interview questions | source code | interview materials)
GateWay实现负载均衡
【luogu P8326】Fliper (Graph Theory) (Construction) (Eulerian Circuit)
MySQL - multi-table query
MySQL - single function
MySQL---Subqueries
35 MySQL interview questions and diagrams, this is also easy to understand
获取抖音视频详情 API
Golang 必知必会Go Mod命令
新型电信“套路”,我爸中招了!
Flex布局详解
MySQL---子查询
MySQL---Basic select statement
Last write wins (discards concurrent writes)
如何识别假爬虫?
useragent在线查找