Unity Manual User Guide Creating Gameplay Sound

Dźwięk

Audio Listener

The Audio Listener(obiekt nasłuchujący dźwięk) działa jak urządzenie typu mikrofon. to otrzymuje wejście z jakiegokolwiek danego Audio Source(źródła dźwięku) w scenie i odtwarza dźwięki przez głośniki komputera. Dla większości aplikacji, nasłuchiwanie najlepiej dawać do głównej(kamery) Camera. Jeżeli audio listener jest w obszarze (strefy pogłosu) Reverb Zone wtedy pogłos stosowany jest do wszystkich słyszalnych dźwięków w scenie. (Tylko dla wersji PRO) Ponadto, (efekty dźwiękowe)Audio Effects mogą być stosowane do słuchacza i zostanie zastosowana do wszystkich słyszalnych dźwięków w scenie.

sound-0.jpg

The Audio Listener, dołączony do Main Camera(kamery głównej)

Properties

The Audio Listener nie posiada właściwości. Po prostu musi być dodany do obiektu,aby działał. Zawsze jest dodawany domyślnie do Main camera.

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.

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.

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.

Podpowiedzi

Każda scena może mieć tylko jeden Audio Listener. Dostęp do całego projektu ustawiania dźwięku za pomocą Audio Manager, znajduje się w Edit - Project Settings - Audio menu. Zobacz Audio Clip, strona komponenta, na której znajdziesz więcej informacji na temat dźwięków Mono i Stereo.

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.

sound-1.jpg

Audio Source gizmo w widoku sceny i w ustawieniach inspektora.

Properties

Audio ClipReference to the sound clip file that will be played. MuteIf enabled the sound will be playing but muted. Bypass EffectsThis Is to quickly „by-pass” filter effects applied to the audio source. An easy way to turn all effects on/off. Play On AwakeIf enabled, the sound will start playing the moment the scene launches. If disabled, you need to start it using the Play() command from scripting. LoopEnable this to make the Audio Clip loop when it reaches the end. PriorityDetermines 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. VolumeHow loud the sound is at a distance of 1 world unit (1 meter) from the Audio Listener. PitchAmount of change in pitch due to slowdown/speed up of the Audio Clip. Value 1 is normal playback speed. 3D Sound SettingsSettings that are applied to the audio source if the is a 3D Sound. Pan LevelSets how much the 3d engine has an effect on the audio source. SpreadSets the spread angle to 3d stereo or multichannel sound in speaker space. Doppler LevelDetermines how much doppler effect will be applied to this audio source (if is set to 0, then no effect is applied). Min DistanceWithin 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. Max DistanceThe 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. Rolloff ModeHow 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 RolloffThe sound is loud when you are close to the audio source, but when you get away from the object it decreases significantly fast. Linear RolloffThe more far away from the audio source you go, the less you can hear it. Custom RolloffThe sound from the audio source behaves accordingly to how you set the graph of roll offs. 2D Sound SettingsSettings that are applied to the audio source if the is a 3D Sound. Pan 2DSets how much the engine has an effect on the audio source.

unity_manual

Typy Rolloff

Są trzy typy Rollof: Logarithmic, Linear i Custom Rolloff. Custom Rolloff może być modyfikowane poprzez zmianę odległości krzywej, jak opisano poniżej. Jeśli ty spróbujesz modyfikować dźwiękowy dystans kiedy jest ustawiona Logarithmic or Linear, typ zmieni się automatycznie w Custom Rolloff.

sound-2.jpg

Typy Rolloff mogą mieć Audio Source

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.Pan: Left(-1.0) to Right(1.0) over distance.Spread: Angle (degrees 0.0 - 360.0) over distance.Low-Pass (only if LowPassFilter is attached to the AudioSource): Cutoff Frequency (22000.0-10.0) over distance.

sound-3.jpg

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.

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:

Import your audio files into your Unity Project. These are now Audio Clips. Go to GameObject-Create Empty from the menubar. With the new GameObject selected, select Component-Audio-Audio Source. Assign the Audio Clip property of the Audio Source Component in the Inspector.

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.

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.

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).

Audio Clip

Klipy audio mają dane używane przez Audio Sources. Unity wspiera mono, stereo i multi (do 8) kanałów audio. Unity wspiera importowanie kolejnych typów plików audio: .aif, .wav, .mp3, and .ogg, i następne: tracker module file formats: .xm, .mod, .it, and .s3m. Asset tracker module, działa tak samo, jak w innych audio assetsach w Unity, za to podgląd przebiegu może być renderowany do assetu inspektora importu.

sound-6.jpg

Inspektor Audio klipu.

Properties

Audio FormatThe specific format that will be used for the sound at runtime. NativeLarger file size, higher quality. Best for very short sound effects. CompressedSmaller file size, lower/variable quality. Best for medium length sound effects and music. 3D SoundIf enabled, the sound will play back in 3D space. Both Mono and Stereo sounds can be played in 3D. Force to monoIf enabled, the audio clip will be down-mixed to a single channel sound. Load TypeThe way Unity load audio assets runtime. Decompress on loadDecompress 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. Compressed in memoryKeep 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. Stream from discStream 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. CompressionAmount 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.

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.

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.

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.

unity_manual

Używanie 3D Audio

Jeśli audio klip jest oznaczony na 3D Sound, to zostanie on odtworzony, tak, by symulować swoją pozycję w świecie 3D. Dźwięki 3D emulują odległości i lokalizację dźwięków, objętości tłumienia i przesuwanie wszystkich głośników. Zarówno Mono jak i inne rodzaje dźwięków mogą być umieszczone w 3D. Do wielokrotnego kanału, użyj spread option na Audio Source do rozprzestrzeniania się i rozdzielania dyskretnych kanałów przestrzeni głośnika. Unity oferuje różnorodne możliwości kontrolowania i dostrajania dźwięku w przestrzeni 3D. Spójrz na Audio Source.

Platform specific details

iOS

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

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.

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).

Android

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

Previous

Next

unity_manual/sound.txt · ostatnio zmienione: 2012/12/27 16:21 przez roocky
Recent changes RSS feed Debian Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki