纳金网

标题: unity 3d 音频处理基础(三) [打印本页]

作者: 晃晃    时间: 2011-9-5 08:11
标题: unity 3d 音频处理基础(三)
The Audio Clip InspectorAudio Clips just work. The only thing you should have to do with them is reference them from within Audio Sources.
Audio Clip(音频剪辑)只负责工作,你要做的事就是在Audio Source(音频源)里引用它。
Properties
属性
Sound assets only have read-only properties. Some of these properties can be changed in the Import Settings
声音资源只具有只读属性。其中的一些属性可以在"Import Setting"里进行修改。
Format
The format the sound is stored in. Unity supports 4 raw formats and one compressed:
格式
声音保存的格式. Unity 支持四种原始格式和一个压缩后的格式:
Mono 8 bit
8 bit uncompressed mono PCM audio
单声道8位
8位未压缩的单声道 PCM 音频
Mono 16 bit
16 bit uncompressed mono PCM audio
单声道16位
16位未压缩的单声道PCM 音频
Stereo 8 bit
8 bit uncompressed stereo PCM audio
立体声 8 位
8 位未压缩的立体声PCM 音频
Stereo 16 bit
16 bit uncompressed stereo PCM audio
立体声 16 位
16 位未压缩的立体声PCM 音频
Ogg Vorbis
Ogg Vorbis encoded stereo or mono audio
Ogg Vorbis
Ogg Vorbis 编码的立体声或单声道音频
Length
The duration of the sound file in seconds.
长度
声音持续的时间,以秒为单位.
Frequency
The sampling frequency of the file.
频率
文件的采样频率.
Importing Audio Assets
导入音频资源
Unity features support for two types of audio: Uncompressed Audio or Ogg Vorbis. Any type of audio file you import into your project will be converted to one of these formats.

Unity支持两种类型的音频:未经压缩的音频或Ogg Vorbis 。任何类型的音频文件导入到您的项目将改为这两种格式之一。
File Type Conversion
文件类型转换
.AIFF
Converted to uncompressed audio on import, best for short sound effects.
导入时转换为未经压缩的音频, 最好音效文件较短
.WAV
Converted to uncompressed audio on import, best for short sound effects.
导入时转换为未经压缩的音频, 最好音效文件较短
.MP3
Converted to Ogg Vorbis on import, best for longer music tracks.
导入时转换为 Ogg Vorbis 格式, 最好音乐曲目较长.
.OGG
Compressed audio format, best for longer music tracks.
已压缩的音频格式, 最好音乐曲目较长.
Import Settings
If you are importing a file that is not already compressed as Ogg Vorbis, you have a number of options in the Import Settings of the Audio Clip. To access the Import Settings, select the Audio Clip in the Project View and choose Assets->Import Settings... from the menu bar, or click the Settings button in the Project View header. Here, you can compress the Clip into Ogg Vorbis format, force it into Mono or Stereo playback, and tweak other options. There are positives and negatives for both Ogg Vorbis and uncompressed audio. Each has its own ideal usage scenarios, and you generally should not use either one exclusively.
如果你导入的文件是尚未压缩的Ogg Vorbis格式 ,您在Audio Clip(音频剪辑)"Import Settings"里有许多的选项。要访问"Import Settings"(导入设置),在"roject View"窗口中选中音频剪辑,在菜单栏里选择"Assets"->"Import Settings...",或在"roject View"窗口上单击"Settings"按钮。在这里,你可以把剪辑压缩成Ogg Vorbis格式,使它进入单声道或立体声播放和调整其他选项。Ogg Vorbis和未压缩音频都有着各自的优点和缺点。每个都有自己的理想使用的情况,通常不应只使用一种格式。
The Audio Clip Import Settings
Audio Format
Only available if the file was initially saved in an uncompressed format.
音频格式
只有在导入的文件是未压缩的音频格式的时候可选
Uncompressed
Best for short sound effects. For more info, jump to the using uncompressed audio section.
未压缩的格式
最好用于短的音效. 想了解更多,可参阅 using uncompressed audio部分.
Ogg Vorbis
Best for longer audio files like music. For more info, jump to the using Ogg Vorbis section
Ogg Vorbis格式
最好用于长的音频文件,比如音乐. 想要了解更多,可参阅 using Ogg Vorbis 部分.
Channels
You can force the sound to play back in Mono or Stereo. This is important for using Positional Audio.
Channels
你可以选择声音是单声道还是立体声播放. 这一部分在 using Positional Audio有提及.
Bitrate
Set the bitrate to optimize file size of compressed Ogg Vorbis Clip
比特率
设置比特率,优化压缩成Ogg Vorbis的文件大小
Decompress on load
If enabled, this Clip will be decompressed into memory when the containing level is loaded. This is important for optimizing player experience.
加载时解压缩
如勾选该选项,该剪辑将在其所在的层被加载后,解压至内存。这对玩家体验来说时至关重要的.
Using Positional Audio
Positional audio is the placement and volume of sounds across the computer speakers. It simulates distance and location of sounds by fading volume and panning across speakers. Unity supports Positional audio, but only mono Audio Clips are played positionally. Stereo sounds are always at the volume and panning determined by the asset file. For this reason, mono Clips are best for sound effects, and stereo Clips are best for music.
定位音频是声音播放的音量和方位。它通过声音音量和声像的衰减,模拟声音的距离和位置。Unity支持定位音频,但是只有单声道音频剪辑可用于定位播放 。立体声声音的音量和声像始终由资源文件所决定。所以单声道的剪辑最好是做声音效果用,而立体声剪辑最好是作为音乐使用。
There are special cases, like if you wanted music playing from two unique in-game speaker environment objects. The closer you move your character to one of the speakers, the louder the music will get. This setup would require the speaker music in mono format.
也有些特殊情况,比如你想音乐在游戏环境里的两个扬声器里播放。当你移动你所控制的对象慢慢接近其中一个扬声器的时候,你会听到那里的音乐比较响。这里需要扬声器所播放的音乐格式为单声道格式。
If you have an Audio Clip that is in stereo, but you want to use it positionally, change the Channels property to Force Mono in the Import Settings. This allows you to be very creative with how you use audio in your game.
如果你的Audio Clip(音频剪辑)是立体声的, 但是你又想用它来定位播放, 需要在"Import Settings"里把"Channels"属性的值改为"Force Mono". 这将使你对游戏里如何运用声音,拥有更多的创新.
When to use Uncompressed Audio
何时使用为压缩过的音频
If you are creating a web player game, do not use uncompressed audio. Only use Ogg Vorbis.
如果你制作的是一个网页游戏,请不要用未压缩的音频,只能使用Ogg Vorbis格式.
Uncompressed has the benefit of being quick to play without increasing CPU taxation. This is because it does not need to be decompressed before it can be played. However, uncompressed audio is quite large so it will increase the size of your player. Usually short Clips like sound effects are good for uncompressed audio, unless you are publishing a web player. If you are publishing a web player, you don't want to increase the file size any more than is absolutely necessary so you basically won't use uncompressed audio, unless you have a few crucial sounds that are shorter than 0.5 seconds. Clips that Uncompressed audio should usually be either 22khz or 11khz. Ideally you should not use 44khz since that takes up too much disk space and the quality difference is not very audible.
未压缩的音频的优点是可以更快的播放,无须增加CPU的额外支出。这是因为它并不需要解压缩才能播放。然而,未压缩的音频是相当大的,所以会增加你发布文件的大小。通常短的音效使用非压缩音频是没有什么问题的,除非你发布的是网页版。如果您发布了一个网页版的播放器,不让文件大小更大是绝对有必要的,因此您基本上不会使用非压缩音频,除非你有几个关键的声音都少于0.5秒。未经压缩的音频剪辑应当通常是22khz或11khz 的。理想的情况是你没有必要使用44khz,因为它占用太多的磁盘空间,并且音质的差异也不容易听得出来。
When to use Ogg Vorbis
何时用Ogg Vorbis格式
If you are creating a web player game, always use Ogg Vorbis.
如果你制作的是一个网页游戏, 基本上使用Ogg Vorbis格式.
Ogg Vorbis files have the benefit of being compressed, which minimizes the amount of disk space they consume. This means that you can include long audio files without making a huge increase in the file size of your player. However, before they can be played back they must be decompressed. This takes time and processor cycles. Frequency of Ogg Vorbis files should be 44khz, because playback will be faster than files with a 22khz frequency.
Ogg Vorbis 格式的文件的优点是经过压缩后文件占有的磁盘空间极小. 这就意味着你可以包含一个长的音效文件而不用占用大量的空间. 无论如何, 在播放它们之前需要对它们进行解压缩,这将需要点时间和CPU周期. Ogg Vorbis 格式的文件频率可以为44khz, 播放起来会比22khz的文件快
Loading Ogg Vorbis files
加载Ogg Vorbis文件
If you're using Ogg Vorbis, you have an option to choose when the Clip will be decompressed. The option is set in the Import Settings:
如果你用的是Ogg Vorbis格式,在"Import Settings"里,有一个剪辑解压缩的选项供你选择:
DecompressOnLoad enabled
Decompress and load the Clip into RAM when the player is loading.
勾选
在下载播放器的时候将剪辑解压并载入到内存中.
DecompressOnLoad disabled (Live decompression)
Decompress and play the Clip real-time when the Clip is triggered to start.
不勾选 (实时解压)
剪辑被触发时实时解压和播放.
Decompressing on load is the most common. It means that the levels containing the Clip will take longer to load initially, and it will use up more of the end-user's RAM. Live decompression does not load the Clip data into RAM at level load. Instead, it requires the CPU to decompress the sound real-time. This means it is more CPU intensive rather than RAM intensive.
加载的时候解压是最常见的。这意味着,包含此剪辑的各级将需要更长的时间才能加载,并占用了更多的内存。实时解压在该级加载时,不加载剪辑数据到内存。相反,它要求CPU对声音实时解压缩。这意味着这是CPU密集型的,而不是内存密集型。
To summarize, enable decompression on load as much as possible, and definitely for all short Clips. Pick live decompression for longer Clips like music tracks. All Ogg Vorbis Clips using live decompression will increase CPU usage. It can use a substantial amount of CPU to live decompress multiple Clips at once, so you should avoid playing more than 2 live decompression Clips at once.
总之,尽可能勾选"DecompressOnLoad",所有短的剪辑一定要勾选该选项,长的剪辑采用实时解压。所有Ogg Vorbis剪辑使用实时解压会增加CPU使用率。一起实时解压多个剪辑会占用大量的CPU,所以你应该避免同时播放超过2个实时解压剪辑的情况。
Hints
提示
There is not much of a reason to import your own .ogg files. Create your sounds in AIFF or WAV format, then you can compress them if you want to right inside the Import Settings.
你不一定非要导入现有的.ogg文件,你可以使用AIFF或WAV格式的声音,在"Import Settings"里对它们直接进行压缩。
Stereo sounds are always played as-is. If you want to use attenuation and other 3D audio effects, force your Clip to be mono in the Import Settings.
立体声声音始终原样播放,如果您想使用的衰减和其他3D音频效果,在"Import Settings"里您必须要将剪辑强制转换为单声道。

作者: Asen    时间: 2011-9-8 09:33

作者: 奇    时间: 2012-2-17 23:21
加精、加亮滴铁子,尤其要多丁页丁页

作者: 晃晃    时间: 2012-5-2 23:20
你们都躲开,我来顶

作者: 菜刀吻电线    时间: 2012-5-17 23:24
呵呵,很好,方便罗。

作者: tc    时间: 2012-7-29 23:20
百度的叫度娘,网易的叫易娘,新浪内部还在为是叫新娘还是浪娘而争论不休!……不管你们是企鹅的额娘,豆瓣的伴娘,还是华为的伪娘,都要记得,淘宝才是你们的亲娘啊!亲!!

作者: 菜刀吻电线    时间: 2012-9-23 23:20
我就看看,我不说话

作者: 晃晃    时间: 2012-9-28 23:22
谢谢楼主,真是太实用了





欢迎光临 纳金网 (http://go.narkii.com/club/) Powered by Discuz! X2.5