Unity声音 Sound (圣典篇)

 

 

 

原址:http://game.ceeger.com/Manual/Sound.html

 

Audio Listener 音频侦听器

The Audio Listener acts as a microphone-like device. It receives input from any given Audio Source in the scene and plays sounds through the computer speakers. For most applications it makes the most sense to attach the listener to the Main Camera. If an audio listener is within the boundaries of a Reverb Zone reverberation is applied to all audible sounds in the scene. (PRO only) Furthermore, Audio Effects can be applied to the listener and it will be applied to all audible sounds in the scene.

音频监听器扮演着像麦克风这样的设备。它接收任何在场景输入的音频源(Audio Source),并通过计算机的扬声器播放声音。对于大多数应用程序,经常会把侦听器贴在主摄像头(Main Camera)。如果一个音频侦听器在混响区(Reverb Zone )内,混响会应用到在场景中所有能听到的声音。(只在专业版)此外,音频效果(Audio Effects ),可以应用到侦听器,它将被应用到场景中的所有听得见的声音。


The Audio Listener, attached to the Main Camera
音频侦听器(Audio Listener)贴到主摄像机

Properties 属性

The Audio Listener has no properties. It simply must be added to work. It is always added to the Main Camera by default.

音频监听器没有属性。它必须被添加才能使用。它总是默认地添加到主照相机。

Details 细节

The Audio Listener works in conjunction with Audio Sources, allowing you to create the aural experience for your games. When the Audio Listener is attached to a GameObject in your scene, any Sources that are close enough to the Listener will be picked up and output to the computer's speakers. Each scene can only have 1 Audio Listener to work properly.

音频侦听器(Audio Listener)配合音频源(Audio Sources),让你可以为你的游戏创建听觉体验。当音频监听器贴在场景中的一个游戏对象,任何音频源,如果足够接近侦听器就会被获取并输出到计算机的扬声器。每个场景只能有1个音频侦听器正常工作。

If the Sources are 3D (see import settings in Audio Clip), the Listener will emulate position, velocity and orientation of the sound in the 3D world (You can tweak attenuation and 3D/2D behavior in great detail in Audio Source) . 2D will ignore any 3D processing. For example, if your character walks off a street into a night club, the night club's music should probably be 2D, while the individual voices of characters in the club should be mono with their realistic positioning being handled by Unity.

如果音频源是3D( 见音频剪辑(Audio Clip)中的导入设置(import settings)),侦听器将模拟在3D世界声音的位置,速度和方向(你可以调整衰减和3D/2D行为,这在音频源( Audio Source)有非常详细的介绍)。 2D将忽略任何3D处理。例如,如果你的人物在街道行走,走进夜总会,夜总会的音乐也许应该是二维的,而人物在俱乐部内独立的声音,应该是伴随着他们真实定位的单声道在Unity中处理。

You should attach the Audio Listener to either the Main Camera or to the GameObject that represents the player. Try both to find what suits your game best.

你应该将音频监听器贴在主相机(Main Camera)或代表玩家的游戏对象(GameObject)。都试一下,找到最适合你的游戏的那种。

Hints 提示

  • Each scene can only have one Audio Listener.
    每个场景只能有一个音频监听器。
  • You access the project-wide audio settings using the Audio Manager, found in the Edit->Project Settings->Audio menu.
    您可以使用音频管理器(Audio Manager),在菜单栏通过Edit->Project Settings->Audio访问项目范围内的音频设置。
  • View the Audio Clip Component page for more information about Mono vs Stereo sounds.
  • 查看音频剪辑组件页,了解更多关于单声道与立体声声音的信息。

Audio Source 音频源

The Audio Source plays back an Audio Clip in the scene. If the Audio Clip is a 3D clip, the source is played back at a given position and will attenuate over distance. The audio can be spread out between speakers (stereo to 7.1) (Spread) and morphed between 3D and 2D (PanLevel). This can be controlled over distance with falloff curves. Also, if the listener is within 1 or multiple Reverb Zones, reverberations is applied to the source. (PRO only) Individual filters can be applied to each audio source for an even richer audio experience. See Audio Effects for more details.

音频源(Audio Source)在场景中播放音频剪辑(Audio Clip)。如果音频剪辑(Audio Clip)是一个3D剪辑,音频源是在一个给定的位置,并会随距离衰减这样的方式进行播放。音频可以在扬声器之间传播(立体声至7.1)(扩散Spread)和可以在3D和2D(平衡调整级别PanLevel)之间进行转换。这是可以控制的随距离衰减曲线。此外,如果侦听器是在1个或多个混响区中,回响将会应用到音频源。 (只专业版可用)单独的过滤器可以应用到每个音频源,可以得到更丰富的音频体验。更多细节请参阅音频效果(Audio Effects)。


The Audio Source gizmo in the Scene View and its settings in the inspector.
音频源在场景视图中gizmo 和 它在检视面板中的设置

Properties 属性

  • Audio Clip 音频剪辑
    Reference to the sound clip file that will be played.
    将被播放的声音剪辑文件
  • Mute 静音
    If enabled the sound will be playing but muted.
    如果启用,声音将被播放,但没有声音(静音)
  • Bypass Effects 直通效果
    This Is to quickly "by-pass" filter effects applied to the audio source. An easy way to turn all effects on/off.
    应用到音频源的快速"直通"过滤效果。一个简单的方法来打开/关闭所有特效。
  • Play On Awake
    唤醒时播放
    If enabled, the sound will start playing the moment the scene launches. If disabled, you need to start it using the Play() command from scripting.
    如果启用,则声音会在场景启动的时候开始播放。如果禁用,则需要从脚本中使用的play()命令来启动它。
  • Loop 循环
    Enable this to make the Audio Clip loop when it reaches the end.
    启用这个属性使音频剪辑(Audio Clip)在播放结束后循环 。
  • Priority
    优先权
    Determines the priority of this audio source among all the ones that coexist in the scene. (Priority: 0 = most important. 256 = least important. Default = 128.). Use 0 for music tracks to avoid it getting occasionally swapped out.
    确定场景所有并存的音频源之间的优先权。(0=最重要的优先权。256 =最不重要。默认为128。)。使用0的音乐曲目,以避免偶尔换出。
  • Volume 音量
    How loud the sound is at a distance of 1 world unit (1 meter) from the Audio Listener.
    声音从距离音频监听器(Audio Listener)1个世界单位(1米)处有多响?
  • Pitch 音调
    Amount of change in pitch due to slowdown/speed up of the Audio Clip. Value 1 is normal playback speed.
    改变音调(Pitch)值,可以减速/加速音频剪辑的播放。1是正常播放速度。
  • 3D Sound Settings
    3D声音设置
    Settings that are applied to the audio source if the is a 3D Sound.
    如果是一个三维的声音,应用到音频源的设置
  • Pan Level
    平衡调整级别
    Sets how much the 3d engine has an effect on the audio source.
    设置多少,3D引擎在音频源上有效果。
  • Spread 扩散
    Sets the spread angle to 3d stereo or multichannel sound in speaker space.
    设置3D立体声或者多声道音响在扬声器空间的传播角度。
  • Doppler Level
    多普勒级别
    Determines how much doppler effect will be applied to this audio source (if is set to 0, then no effect is applied).
    决定了多少多普勒效应将被应用到这个音频信号源(如果设置为0,就是无效果)。
  • Min Distance
    最小距离
    Within the MinDistance, the sound will stay at loudest possible. Outside MinDistance it will begin to attenuate. Increase the MinDistance of a sound to make it 'louder' in a 3d world, and decrease it to make it 'quieter' in a 3d world.
    在最小距离(MinDistance)之内,声音会保持最响亮。 在最小距离(MinDistance)之外,声音就会开始衰减。增加声音的最小距离(MinDistance),可以使声音在3D世界"更响亮",减少最小距离(MinDistance)可使声音在一个三维世界"安静"。
  • Max Distance
    最大距离
    The distance where the sound stops attenuating at. Beyond this point it will stay at the volume it would be at MaxDistance units from the listener and will not attenuate any more.
    声音停止衰减距离。超过这一点,它将在距离侦听器最大距离(MaxDistance)单位,保持音量,并不会作任何衰减。
  • Rolloff Mode
    衰减模式
    How fast the sound fades. The higher the value, the closer the Listener has to be before hearing the sound.(This is determined by a Graph).
    声音淡出的速度有多快。该值越高,越接近侦听器最先听到声音(这是由图形决定)。
  •     Logarithmic Rolloff
        对数衰减
    The sound is loud when you are close to the audio source, but when you get away from the object it decreases significantly fast.
    当你接近的音频源,声音响亮,但是当你远离对象,声音下降显着快。
  •     Linear Rolloff
        线性衰减
    The more far away from the audio source you go, the less you can hear it.
    越是远离音频源的,你可以听到的声音越小。
  •     Custom Rolloff
        自定义衰减
    The sound from the audio source behaves accordingly to how you set the graph of roll offs.
    根据你设置的衰减图形,来自音频源的声音行为。
  • 2D Sound Settings
    2D声音设置
    Settings that are applied to the audio source if the is a 3D Sound.
    如果是一个二维的声音,应用到音频源的设置
  • Pan 2D
    2D平衡调整
    Sets how much the engine has an effect on the audio source.
    设置多少,引擎在音频源上有效果。

Types of Rolloff 衰减类型

There are three Rolloff modes: Logarithmic, Linear and Custom Rolloff. The Custom Rolloff can be modified by modifying the volume distance curve as described below. If you try to modify the volume distance function when it is set to Logarithmic or Linear, the type will automatically change to Custom Rolloff.

衰减模式有三种:对数,线性和自定义衰减。自定义衰减可以修改通过修改音量的距离曲线,如下所述。当它被设置为对数或线性类型时,如果你修改音量距离函数,类型将自动更改为自定义衰减。


Rolloff Modes that an audio source can have. 音频源的衰减模式

Distance Functions 距离函数

There are several properties of the audio that can be modified as a function of the distance between the audio source and the audio listener.

有音频的几个的属性,作为 音频源和音频侦听器之间的距离的函数,可以被修改。

Volume: Amplitude(0.0 - 1.0) over distance. 音量:幅度(0.0-1.0)随距离
Pan: Left(-1.0) to Right(1.0) over distance. 平衡调整: 左(-1.0)到右(1.0)随距离
Spread: Angle (degrees 0.0 - 360.0) over distance. 扩散:角度(0.0到360.0度)随距离
Low-Pass (only if LowPassFilter is attached to the AudioSource): Cutoff Frequency (22000.0-10.0) over distance.
低通(只有当低通滤波器(LowPassFilter)贴到音频源(AudioSource)上): 低通截止频率(10.0~22000.0hz)随距离。


Distance functions for Volume, Pan, Spread and Low-Pass audio filter. The current distance to the Audio Listener is marked in the graph.
音量,平衡调整,扩散和低通音频滤波器的距离函数。当前到音频监侦听器的距离在图中标记。

To modify the distance functions, you can edit the curves directly. For more information, see the guide to Editing Curves.

要修改的距离函数,您可以直接编辑曲线。想了解更多信息,请参阅编辑曲线(Editing Curves)的指南。

Creating Audio Sources 创建音频源

Audio Sources don't do anything without an assigned Audio Clip. The Clip is the actual sound file that will be played back. The Source is like a controller for starting and stopping playback of that clip, and modifying other audio properties.

没有分配音频剪辑的音频源不会播放任何东西。剪辑是实际的声音文件,该文件将被播放。音频源就像是一个控制器,用于启动和停止播放该剪辑,并修改其他的音频属性。

To create a new Audio Source 创建一个新的音频源:

  1. Import your audio files into your Unity Project. These are now Audio Clips.
    导入你的音频文件到Unity项目。这些都是现在的音频剪辑。
  2. Go to GameObject->Create Empty from the menubar.
    从菜单栏选择 GameObject->Create Empty
  3. With the new GameObject selected, select Component->Audio->Audio Source.
    随着新的游戏对象(GameObject) 被选择,选择 Component->Audio->Audio Source
  4. Assign the Audio Clip property of the Audio Source Component in the Inspector.
    在检视面板中分配音频源 (Audio Source)组件的音频剪辑属性。

Note: If you want to create an audio source just for one Audio Clip that you have in the Assets folder, you can drag and drop that Audio Clip to the scene view and an Audio Source game object will be created automatically for it.

注意:如果你想创建一个音频源,只需有一个音频剪辑(Audio Clip)在你的资源文件夹,你可以拖拽音频剪辑(Audio Clip)到场景视图,那么带有音频源(Audio Source)的游戏对象将自动创建。

Platform specific details 平台的具体细节

iOS

On mobile platforms compressed audio is encoded as MP3 for speedier decompression. Beware that this compression can remove samples at the end of the clip and potentially break a "perfect-looping" clip. Make sure the clip is right on a specific MP3 sample boundary to avoid sample clipping (Tools to perform this is widely available). For performance reasons audio clips can be played back using the Apple hardware codec. To enable this check the "Use Hardware" checkbox in the import settings. See the Audio Clip documentation for more details.

在移动平台上的压缩音频以MP3格式编码为了能快捷解压。要注意,这种压缩是可以删除剪辑结尾的样品,并可能打破一个"完美循环"的剪辑。确保剪辑是正确的在一个特定的MP3样品边界,避免样品剪裁(这是执行它广泛被使用的工具)。出于性能方面的原因,音频剪辑可以使用苹果的硬件编解码器进行播放。若要启用它,选上在导入设置(import settings)的"使用硬件(Use Hardware)"复选框。有关详细信息,请参阅音频剪辑(Audio Clip)文件。

Android

On mobile platforms compressed audio is encoded as MP3 for speedier decompression. Beware that this compression can remove samples at the end of the clip and potentially break a "perfect-looping" clip. Make sure the clip is right on a specific MP3 sample boundary to avoid sample clipping (Tools to perform this is widely available).

在移动平台上的压缩音频以MP3格式编码为了能快捷解压。要注意,这种压缩是可以删除剪辑结尾的样品,并可能打破一个"完美循环"的剪辑。确保剪辑是正确的在一个特定的MP3样品边界,避免样品剪裁(这是执行它广泛被使用的工具)。

Audio Clip 音频剪辑

Audio Clips are audio data used by Audio Sources. Unity supports mono, stereo and multi (up to 8) channels audio assets. Unity supports importing the following audio file formats: .aif, .wav, .mp3, and .ogg, and the following tracker module file formats: .xm, .mod, .it, and .s3m. The tracker module assets works the same way as any other audio assets in Unity except no waveform preview can be rendered to the asset import inspector.

音频剪辑被音源所使用来表现被导入到Unity的音频资产。Unity同时支持单声道和立体声音频资产。Unity支持导入以下音频文件格式:.aif, .wav, .mp3, 和 .ogg,和以下音轨模块:.xm, .mod, .it, 和 .s3m。在Unity音轨模块资源和其他音频资源一样,除了无波形预览渲染到资源导入检视面板。

Audio Clip 音频剪辑
The Audio Clip Inspector 音频剪辑检视面板

Properties 属性

  • Audio Format 音频格式
    The specific format that will be used for the sound at runtime.
    在运行时被应用到声音上的特定格式。
  •     Native 原生的
    Larger file size, higher quality. Best for very short sound effects.
    较大文件尺寸,较高质量。最适用于很短的音效。
  •     Compressed 压缩的
    Smaller file size, lower/variable quality. Best for medium length sound effects and music.
    较小文件尺寸,较低/不稳定质量。最适用于中等长度音效与音乐。
  • 3D Sound 三维声音
    If enabled, the sound will play back in 3D space. Both Mono and Stereo sounds can be played in 3D.
    如果启用,音乐将在3D空间中播放。在Unity2.6中,单声道和立体声都可以在3D中播放。
  • Force to mono 强制单声道
    If enabled, the audio clip will be down-mixed to a single channel sound.
    如果启用,该音频剪辑将向下混合到单通道声音。
  • Load Type 加载类型
    The way Unity load audio assets runtime.
    运行时Unity加载音频的方法。
  •     Decompress on load
         加载时解压缩
    Decompress sounds upon load. Use this for smaller compressed sounds to avoid the performance overhead of decompressing on the fly. Beware that decompressing sounds on load will use ~10x more memory than keeping them compressed in memory, so don't use this for large files.
    加载后解压缩声音。使用于较小的压缩声音,以避免运行时解压缩的性能开销。要注意加载时解压缩声音将使用比在它们在内存中压缩的多10倍或更多内存,因此不要使用这个到大文件。
  •     Compressed in memory
         在内存中压缩
    Keep sounds compressed in memory and decompress while playing. This have a slight performance overhead (esp. for Ogg/Vorbis compressed files) so only use this for bigger files.
    保持声音在内存中是压缩的并在播放时解压缩。这有轻微的性能开销(尤其是OGG / Vorbis格式的压缩文件),因此使用这个为大文件。
  •     Stream from disc
         从磁盘流
    Stream audio data directly from disc. This uses a fraction of the original sounds size of memory. Use this for your music or very long tracks. Depending on the hardware, a general advice is to keep this down to 1-2 simultaneously streams.
    直接从磁盘流音频数据。这只使用了原始声音占内存大小的很小一部分。使用这个用于很长的音乐。取决于硬件,一般建议1-2线程同时流。
  • Compression
    压缩
    Amount of Compression to be applied to a Compressed clip. Statistics about file size can be seen beneath the slider. It is suggested to drag the slider to a place that leaves the playback "good enough" but still at a small enough size to meet your file size/distribution needs.
    压缩量应用于压缩的剪辑。有关文件大小的统计可以在之后的滑动条看到。可以拖动滑条来调整来调整大小,播放声音来判断音质,但保持在一个足够小的尺寸,以满足您的文件大小/分配需要。
  • Hardware Decoding
    硬件解码
    (iOS ONLY) Available for compressed audio on iOS devices. Uses Apple's hardware decoder for less CPU intensive decompression. Check out Platform Specific details for more info.
    (仅iOS)用于iOS设备压缩的音频。使用苹果的硬件解码来减少CPU的密集解压缩。
  • Gapless looping
    无缝循环
    (Android/iOS ONLY) Use this when compressing a perfect looping audio source file (in a non-compressed PCM format) to preserve the loop. Standard MPEG encoders introduce silence around the loop point, which will play as little "click" or "pop". Unity handles this smoothly for you.
    (仅Android/iOS)当压缩一个完美的循环音频源文件(在一个非压缩的PCM格式)保持循环时,使用这个。标准的MPEG编码器插入silence循环点,播放时有小的"click" 或 "pop"(可能是短暂停顿的意思)。Unity为你顺畅处理这个问题。

Importing Audio Assets 导入音频资源

Unity supports both Compressed and Native Audio. Any type of file (except MP3/Ogg Vorbis) will be initially imported as Native. Compressed audio files must be decompressed by the CPU while the game is running, but are smaller in file size. If Stream is checked the audio is decompressed on the fly, or else the audio is decompressed entirely upon load. Native PCM formats (WAV, AIFF) have the benefit of being higher fidelity without increasing CPU taxation, but create much larger files. Module files (.mod,.it,.s3m..xm) can deliver very high quality with an extremely low footprint.

Unity支持压缩的和原生的音频。任何类型的文件(MP3/Ogg Vorbis的除外),最初都以原生音频导入(Native即不经任何处理的音频本身)。游戏运行时,压缩音频文件必须由CPU解压缩,但文件要较小。流(Stream )被选择,音频在将运行时解压缩,或者音频在加载时完全解缩。原生PCM格式(WAV,AIFF)有在不增加CPU资源同时有更高的保真度的好处,但创建更大的文件。模块文件(.MOD,.S3M,. XM)可以提供非常高的质量与极低的占用空间。

As a general rule of thumb, Compressed audio(or modules) are best for long files like background music or dialog, and uncompressed is better for short sound effects. Tweak the amount of Compression with the compression slider to just before the difference in sound quality is noticeable.

一般的经验是,压缩音频(或模块)最好是长文件,如背景音乐或对话,未压缩的用于短声音效果更好。用压缩滑动条(Compression)来调整压缩量,前后音质的差异是明显的。

Using 3D Audio 使用3D音频

If an audio clip is marked as a 3D Sound then it will be played back to simulate its position in the game world's 3D space. 3D sounds emulate distance and location of sounds by attenuating volume and panning across speakers. Both mono and multiple channel sounds can be positioned in 3D. For multiple channel audio, use the spread option on the Audio Source to spread and split out the discrete channels in speaker space. Unity offers a variety of options to control and fine-tune the audio behavior in 3D space. Take a look at Audio Source.

如果音频剪辑标记为3D声音(3D Sound),它会模拟在游戏世界三维空间中的位置播放。 3D声音以衰减音量和扬声器之间平衡调整模拟声音的距离和位置。单声道和​​多声道声音都可以放置在三维空间。对于多声道音频,使用的音频源(Audio Source)中的扩散(spread )选项来扩散并在扬声器空间分离出离散通道。Unity提供了多个选项,来控制和微调三维空间中音频的行为。参见音频源(Audio Source)。

Platform specific details 平台支持细节

iOS

On mobile platforms compressed audio is encoded as MP3 for less CPU intensive decompression.

在移动平台上的压缩音频以MP3格式编码,以在解压缩时占用更少的CPU资源。

For performance reasons audio clips can be played back using the Apple hardware codec. To enable this check the "Hardware Decoding" checkbox in the Audio Importer. Note that only one hardware audio stream can be decompressed at a time, including the background iPod audio.

出于性能方面的原因音频剪辑可以使用苹果的硬件编解码器进行播放。要启用它,在音频导入器(Audio Importer)下的"硬件解码(Hardware Decoding)"复选框勾选上。请注意,同一时间只能有一个硬件音频流解压缩,包括背景的iPod音频。

If the hardware decoder is not available, the decompression will fall back on the software decoder (on iPhone 3GS or newer Apple's software decoder is used over Unity's(FMOD) own decoder).

如果硬件解码器不可用,解压的任务将落在软件解码器上(iPhone 3GS或更新的苹果软件解码器是使用Unity(FMOD)自带的解码器)。

Android

On mobile platforms compressed audio is encoded as MP3 for less CPU intensive decompression.

在移动平台上的压缩音频以MP3格式编码,以在解压缩时占用更少的CPU资源。

页面最后更新:2007-11-16

分类: Manual| 翻译: U_鹰

 

 

 

 

 

 

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Unity虚拟现实开发圣典》是一本针对虚拟现实开发者的权威指南。该书主要介绍了如何使用Unity引擎进行虚拟现实应用程序的开发。在这本书中,读者将学习到如何构建虚拟世界、创建互动场景、设计虚拟现实用户界面以及优化应用程序性能等关键技术和概念。 这本电子版的《Unity虚拟现实开发圣典》具有以下优点。 首先,电子版书籍具有便携性和方便性。读者可以随时随地使用各种电子设备访问和阅读这本书,无需携带厚重的实体书籍。此外,电子书可以进行搜索、书签和高亮等功能,方便读者快速定位所需信息。 其次,电子版书籍可以灵活更新。随着虚拟现实技术的不断发展和创新,书籍的内容需要及时跟进。电子版书籍可以通过在线更新的方式持续为读者提供最新的开发技术和实用案例,使读者始终保持在虚拟现实开发的前沿。 再次,电子版书籍通常可以搭配其他多媒体资源。对于虚拟现实这种需要视听体验的技术来说,电子版书籍可以与视频教程、示例代码和实时演示等资源相结合,为读者提供更加丰富的学习体验和实践指导。 总之,《Unity虚拟现实开发圣典》电子版是一本对虚拟现实开发充满深度和广度的权威教材。无论是对于初学者还是有一定经验的开发者来说,这本书都能够提供宝贵的知识和实用的技巧,帮助他们在虚拟现实领域取得突破性的创作和应用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值