Mais conteúdo relacionado


Audios in Unity

  1. Audio in Unity Ehsan Ehrari 1
  2. Implementing Audio • Audio Clip • Assets file like mp3,wav… • Audio Source • Receiving audio clip and play them • Audio Listener • In order to play audio by audio source this component should be in the scene • Changing the its location change the frequency of sound by audio source 2
  3. Stereo VS Mono • The difference is in the number of channels (signals) used. Mono uses one, stereo uses more than one. • In monaural sound one single channel is used. It can be reproduced through several speakers, but all speakers are still reproducing the same copy of the signal. • In stereophonic sound more channels are used (typically two). You can use two different channels and make one feed one speaker and the second channel feed a second speaker (which is the most common stereo setup). 3
  4. Stereo VS Mono Stereo Mono Unity supports mono, stereo and multichannel audio assets (up to eight channels). 4
  5. Importing Audio into Unity Options • Force To Mono • When this option is enabled, multi-channel audio will be mixed down to a mono track before packing. • Normalize • When this option is enabled, audio will be normalized. • Load In Background • When this option is enabled, the loading of the clip will happen at a delayed time on a separate thread, without blocking the main thread. • Ambisonic • Ambisonic audio sources store audio in a format which represents a soundfield that can be rotated based on the listener’s orientation. It is useful for 360-degree videos and XR 5
  6. Load Type • Decompress on load • Small sounds, Removing the process of decompressing while the audio is play • Compress in memory • Large audios • Streaming • Load and decompress, Low Memory 6
  7. Compression Format • PCM • higher quality at the expense of larger file size and is best for very short sound effects. • ADPCM • sounds that contain a fair bit of noise and need to be played in large quantities, such as footsteps, impacts, weapons, 3.5 times samller than pcm • Vorbis/MP3 • The compression results in smaller files but with somewhat lower quality compared to PCM audio. The amount of compression is configurable via the Quality slider. This format is best for medium length sound effects and music. 7
  8. Preview Window • When Auto Play is on the clips will play as soon as they are selected • When Loop is on the clips will play in a continual loop. • This will play the clip. 8
  9. 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. • Furthermore, Audio Effects can be applied to the listener and it will be applied to all audible sounds in the scene. • Each scene can only have one Audio Listener. 9
  10. AudioSource • An AudioSource is attached to a GameObject for playing back sounds in a 3D environment. In order to play 3D sounds you also need to have a AudioListener. The audio listener is normally attached to the camera you want to use. 10
  11. Audio Source Properties • Audio Clip • clip file that will be played. • Output • output through an audio listener or an audio mixer. • Mute • Muted clip • Bypass Effects • “Cut” filter effects applied to the audio source • Bypass Listener Effects • This is to quickly turn all Listener effects on/off. • Bypass Reverb Zones • This is to quickly turn all Reverb Zones on/off. • Play On Awake • the sound will start playing the moment the scene launches • Loop • Audio Clip loop when it reaches the end. 11
  12. Audio Source Properties • Priority • Priority: 0 = most important. 256 = least important. Default = 128. Swapped out clip • Volume • How loud the sound is at a distance of one world unity from audio listener • Pitch • Slowdown/Speed up of the Audio Clip • Stereo Pan • Set to stereo sound • Spatial Blend • Sets how much the 3D engine has an effect on the audio source • Doppler Level • An observer behind the source would hear the sound with a lower frequency, while an observer in front would hear a higher frequency than is being produced by the source. This shift in frequency is called the doppler effect. • how much doppler effect will be applied to this audio source. Car distance from human 12
  13. Audio Source Properties • Spread • Sets the spread angle to 3D stereo or multichannel sound in speaker space • Min Distance • Within the MinDistance, the sound will stay at loudest possible • Max Distance • The distance where the sound stops attenuating at. • Rolloff Mode • How fast the sound fades. The higher the value, the closer the Listener has to be before hearing the sound. • 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 further 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. 13
  14. Audio Mixer • The Unity Audio Mixer allows you to mix various audio sources, apply effects to them, and perform mastering. • The window displays the Audio Mixer which is basically a tree of Audio Mixer Groups. • An Audio Mixer group is essentially a mix of audio, a signal chain which allows you to apply volume attenuation and pitch correction; it allows you to insert effects that process the audio signal and change the parameters of the effects. • There is also a send and return mechanism to pass the results from one bus to another. • An Audio Mixer is an asset • You can create one or more Audio Mixer and have more than one active at any time. • An Audio Mixer always contains a master group. • You route the output of an Audio Source to a group within an Audio Mixer. The effects will then be applied to that signal. 14
  15. Ducking • Ducking allows you to alter the effect of one group based on what is happening in another group. An example might be to reduce the background ambient noise while something else is happening. 15
  16. Properties S Button Soloing the group. M Button Muting the group. B Button Bypassing all the effects in the group. 16
  17. Add Effect When you select Add you can select from a list of effects that can be applied to the group. 17
  18. Reverb Zones • Reverb Zones take an Audio Clip and distorts it depending where the audio listener is located inside the reverb zone. • They are used when you want to gradually change from a point where there is no ambient effect to a place where there is one, for example when you are entering a cavern. 18
  19. Properties • Min Distance • Represents the radius of the inner circle in the gizmo, this determines the zone where there is a gradually reverb effect and a full reverb zone. • Max Distance • Represents the radius of the outer circle in the gizmo, this determines the zone where there is no effect and where the reverb starts to get applied gradually. • Reverb Preset • Determines the reverb effect that will be used by the reverb zone. 19
  20. Properties 20
  21. Any Question? 21