< Return to Video

TANKS! Unity Tutorial - Phase 8 of 8 - Audio Mixing

  • 0:02 - 0:05
    Phase 8 - Audio
  • 0:05 - 0:08
    With the GameManager selected
  • 0:08 - 0:10
    we're going to put in some music
  • 0:10 - 0:12
    for our game, so we need an audio source.
  • 0:12 - 0:15
    So select the GameManager game object,
  • 0:15 - 0:18
    Add Component, type in 'sou'
  • 0:18 - 0:21
    hit return and you'll have yourself an audio component.
  • 0:22 - 0:25
    Then if we click on the circle select
  • 0:25 - 0:28
    and choose BackgroundMusic as the clip.
  • 0:29 - 0:31
    Then finally check Loop
  • 0:32 - 0:34
    So choose the BackgroundMusic clip,
  • 0:34 - 0:36
    check Loop at the bottom.
  • 0:37 - 0:39
    I'm just going to keep saving my scene to update it.
  • 0:40 - 0:42
    We're going to create what's called and audio mixer.
  • 0:42 - 0:44
    In Unity we have audio sources,
  • 0:44 - 0:46
    they output all of the sound, they might be on
  • 0:46 - 0:48
    game objects in the scene, they might be on instantiated objects.
  • 0:49 - 0:51
    But basically they all need to route in to a mixer
  • 0:51 - 0:53
    in order to balance them with one another.
  • 0:54 - 0:56
    So select the AudioMixers
  • 0:56 - 0:58
    folder in the project.
  • 0:58 - 1:00
    Click the Create button and choose Audio Mixer.
  • 1:00 - 1:03
    So this is a Create button on the project window.
  • 1:04 - 1:05
    Choose Audio Mixer.
  • 1:05 - 1:08
    I'm just going to rename this MainMix.
  • 1:09 - 1:11
    Then I'm going to go to
  • 1:11 - 1:14
    Window - Audio Mixer
  • 1:14 - 1:16
    So it's control8 on pc, command8 on mac.
  • 1:17 - 1:19
    And I'm just going to grab this and
  • 1:19 - 1:21
    dock it somewhere sensible, I like to do it
  • 1:21 - 1:23
    next to the game view,
  • 1:23 - 1:26
    I just find that useful, but you might want to
  • 1:26 - 1:28
    do it during the game so it might make sense to
  • 1:28 - 1:30
    dock it by the scene view, it's totally up to you.
  • 1:30 - 1:32
    The idea is that we want to
  • 1:32 - 1:34
    route each audio source that we've made
  • 1:34 - 1:36
    during the day in to a particular,
  • 1:36 - 1:37
    what we call group.
  • 1:37 - 1:39
    If you've used audio software before you might call these
  • 1:39 - 1:41
    tracks or channels depending on which package
  • 1:41 - 1:44
    you use, but Unity calls them groups.
  • 1:45 - 1:47
    So each group of sounds needs
  • 1:47 - 1:49
    it's own group. Makes sense?
  • 1:49 - 1:51
    So our master is where all of those
  • 1:51 - 1:53
    groups will end up, so what you'll see
  • 1:53 - 1:55
    if you look at the mixer
  • 1:56 - 1:58
    Is that we have things on the side
  • 1:58 - 2:01
    with + buttons, so Groups is one of those.
  • 2:01 - 2:03
    So if I click on this + button
  • 2:03 - 2:05
    I can make a new group.
  • 2:05 - 2:07
    The first thing that I'm going to do is make
  • 2:07 - 2:10
    a group for my music
  • 2:13 - 2:15
    Then each time I make a new group
  • 2:15 - 2:17
    I need to reselect the master because I want
  • 2:17 - 2:19
    each of those groups to be a child of that.
  • 2:19 - 2:21
    So I reselect my master,
  • 2:21 - 2:23
    I hit +, and the next group
  • 2:23 - 2:25
    I want to make is for the sound effects,
  • 2:25 - 2:27
    so I just call it SFX.
  • 2:29 - 2:31
    And then finally we need one
  • 2:31 - 2:33
    more for our driving audio.
  • 2:33 - 2:35
    So the idling and the engine sounds.
  • 2:36 - 2:38
    Remember I'm making these
  • 2:38 - 2:40
    and reselecting the master each time
  • 2:40 - 2:42
    so that they're children of that.
  • 2:42 - 2:44
    So now we need to go through all of our
  • 2:44 - 2:46
    audio sources and route them in to the
  • 2:46 - 2:47
    correct group that we've just made.
  • 2:47 - 2:49
    Then we'll actually do the balancing
  • 2:49 - 2:51
    but first we need to hook everything up.
  • 2:51 - 2:53
    So the first thing I'm going to do is select
  • 2:53 - 2:55
    my Tank prefab, so I go to my
  • 2:55 - 2:58
    Prefabs folder and I select Tank.
  • 2:58 - 3:00
    And this should become second nature once we've done
  • 3:00 - 3:02
    a couple of them but the first thing I'm going to do
  • 3:02 - 3:04
    is to look at the audio sources there.
  • 3:05 - 3:07
    So if I zoom in a little bit for you, what you'll see
  • 3:07 - 3:09
    under each audio clip, the second
  • 3:09 - 3:11
    parameter there is Output, and that is
  • 3:11 - 3:13
    which group this is going in to.
  • 3:14 - 3:17
    So the first audio source we know is for driving,
  • 3:17 - 3:20
    so I'm going to click on the circle select
  • 3:20 - 3:23
    and you'll see MainMix and you'll see
  • 3:23 - 3:25
    CompleteMainMix which is used for the complete game,
  • 3:25 - 3:27
    so ignore that, look at the MainMix
  • 3:27 - 3:29
    and we're going to select Driving.
  • 3:29 - 3:32
    So Engine - Sounds in the first
  • 3:32 - 3:34
    audio source will go to there,
  • 3:34 - 3:36
    remember the second audio source was for
  • 3:36 - 3:38
    sound effects so under Output
  • 3:38 - 3:40
    we'll choose SFX.
  • 3:42 - 3:44
    So one more time, the first audio source
  • 3:44 - 3:47
    should be routed to Driving, the second to SFX.
  • 3:49 - 3:51
    And that's our Tank setup.
  • 3:52 - 3:54
    Then the next thing that had an audio source
  • 3:54 - 3:56
    was our Shell.
  • 3:56 - 3:58
    and if you expand the Shell you'll see the
  • 3:58 - 4:02
    ShellExplosion which has the audio source attached to it.
  • 4:02 - 4:04
    So in the prefab, in the project, just click
  • 4:04 - 4:07
    the arrow next to it to see the child object ShellExplosion
  • 4:07 - 4:09
    and then you'll be able to route that also
  • 4:09 - 4:12
    to the SFX mixer group.
  • 4:14 - 4:15
    So what else needs routing?
  • 4:15 - 4:17
    Well we just added our GameManager
  • 4:17 - 4:19
    and we just put on BackgroundMusic
  • 4:19 - 4:21
    so we need to set that up as well.
  • 4:22 - 4:24
    So for that audio source I'm just
  • 4:24 - 4:26
    going to click the Output
  • 4:26 - 4:28
    and set that to Music.
  • 4:31 - 4:34
    So the TankExplosion also has
  • 4:34 - 4:37
    to be routed as well so in the Prefabs,
  • 4:37 - 4:39
    TankExplosion prefab,
  • 4:39 - 4:42
    the audio source there needs setting to sound effects.
  • 4:42 - 4:44
    The SFX mixer group.
  • 4:45 - 4:47
    Okay, so now we're ready to mix,
  • 4:47 - 4:49
    everything is hooked up in to that so I'm just going to show you
  • 4:49 - 4:52
    really quickly, please don't do this, I'm just going to demonstrate.
  • 4:53 - 4:55
    So what you'll see in the mixer
  • 4:55 - 4:57
    is that all of these levels
  • 4:57 - 5:00
    are moving around and when I actually do something,
  • 5:01 - 5:03
    the SFX gets a level too.
  • 5:03 - 5:05
    But nothing is balanced yet, so we're going to do
  • 5:05 - 5:07
    that but we're also going to use an effect
  • 5:07 - 5:09
    to make sure that the sound effects can cut
  • 5:09 - 5:11
    through everything else.
  • 5:11 - 5:13
    So the Music group, I'm going to set the attenuation,
  • 5:13 - 5:15
    and by that I simply mean the level,
  • 5:15 - 5:17
    of the music down a little bit.
  • 5:17 - 5:20
    It's kind of loud, it's compressed as you'd expect.
  • 5:20 - 5:23
    I'm going to bring that down to -12, so do that now.
  • 5:23 - 5:26
    Drag that fader down to -12.
  • 5:27 - 5:29
    Then I'm going to select the Driving group
  • 5:29 - 5:33
    and set that way down to -25.
  • 5:33 - 5:36
    So it's super loud and super obnoxious sounding
  • 5:36 - 5:38
    and we don't really want that, we'll drag it all the way down
  • 5:38 - 5:40
    so that it's nice and subtle in the mix.
  • 5:40 - 5:42
    -25.
  • 5:42 - 5:44
    Then for the Music we want
  • 5:44 - 5:46
    the music to be ducked down every time
  • 5:46 - 5:48
    there's an explosion, so we want the music
  • 5:48 - 5:51
    level to dip every time a sound effect comes in.
  • 5:51 - 5:53
    So we do that with something called ducking.
  • 5:53 - 5:55
    So ducking basically means that you can
  • 5:55 - 5:57
    use 1 source to decrease
  • 5:57 - 5:59
    the attenuation of another.
  • 5:59 - 6:01
    At the bottom of the Music group
  • 6:01 - 6:03
    I'm going to click on Add.
  • 6:04 - 6:07
    So here I can add a Duck Volume effect.
  • 6:09 - 6:11
    And when I do that you should see it on the inspector,
  • 6:11 - 6:13
    I get this effect, so when you select
  • 6:13 - 6:15
    any of these groups, so you can see I can click on
  • 6:15 - 6:17
    them and they highlight in blue.
  • 6:17 - 6:20
    When I select Music I've just added Duck Volume,
  • 6:21 - 6:23
    And it says it's first thing is
  • 6:23 - 6:26
    a warning saying 'No Send source is connected.
  • 6:26 - 6:28
    There's basically no other group
  • 6:28 - 6:30
    sending a signal to this group in order to
  • 6:30 - 6:32
    tell it to duck, so we need to sort that out.
  • 6:32 - 6:35
    So what I'm going to do is go to my SFX group.
  • 6:35 - 6:37
    My SFX, I will select it,
  • 6:37 - 6:39
    and then at the bottom of SFX
  • 6:39 - 6:41
    I'm going to add a send.
  • 6:43 - 6:46
    And that send has a receive.
  • 6:46 - 6:48
    So you need to just basically send the signal of this
  • 6:48 - 6:50
    to something and the only thing
  • 6:50 - 6:52
    that we've got is this Duck Volume effect
  • 6:52 - 6:54
    on the Music group.
  • 6:54 - 6:56
    So I'm just going to select that
  • 6:56 - 6:58
    and then how much of this do we want to send?
  • 6:58 - 7:00
    Well we want to send the entire level
  • 7:00 - 7:03
    So instead of nothing, -80 decibels,
  • 7:03 - 7:05
    we're going to drag it all the way to the top.
  • 7:05 - 7:07
    So we're not going to add this or reroute the signal,
  • 7:07 - 7:09
    we're just using it to command
  • 7:09 - 7:11
    that effect, so drag it all the way to the right
  • 7:11 - 7:12
    I.E. full.
  • 7:12 - 7:14
    What does Duck Volume mean?
  • 7:14 - 7:16
    Duck Volume is basically
  • 7:16 - 7:19
    using one signal to subtract from another.
  • 7:19 - 7:21
    What you'll see in a moment is that we have
  • 7:21 - 7:23
    a certain threshold for how much signal
  • 7:23 - 7:26
    is going to be required to decrease that.
  • 7:28 - 7:31
    Okay, so I'm going to reselect my Music.
  • 7:32 - 7:34
    And I'm going to look at that Duck Volume.
  • 7:34 - 7:36
    What you'll see is that we have a
  • 7:36 - 7:38
    meter here effectively, so I'm just going to
  • 7:38 - 7:40
    show you how that works.
  • 7:40 - 7:42
    So when I play the game
  • 7:42 - 7:44
    this Duck Volume is waiting for something to be played
  • 7:44 - 7:46
    from the sound effects, so if I fire something
  • 7:46 - 7:48
    you see that this yellow comes up
  • 7:48 - 7:50
    from the left to the right.
  • 7:50 - 7:52
    But there's a white line
  • 7:53 - 7:55
    which is representing the threshold
  • 7:55 - 7:57
    So what I'm going to do is reduce the threshold
  • 7:57 - 8:00
    so that it starts to
  • 8:00 - 8:02
    pull down the volume of the music
  • 8:02 - 8:04
    out of a particular amount of signal coming in
  • 8:04 - 8:06
    from the SFX group.
  • 8:06 - 8:08
    so I'm going to pull that threshold down to
  • 8:08 - 8:11
    round about -45.
  • 8:11 - 8:13
    So now I'm just going to turn this up
  • 8:13 - 8:15
    so you can hear what I'm doing.
  • 8:15 - 8:17
    Now when I actually play it
  • 8:26 - 8:28
    You can hear the music gets pulled down as that
  • 8:28 - 8:30
    threshold comes in.
  • 8:30 - 8:32
    Then what I'm also going to do is change
  • 8:32 - 8:33
    a couple of other settings there,
  • 8:33 - 8:36
    I'm going to change my Ratio to 250%,
  • 8:37 - 8:39
    so it's going to curb it even further,
  • 8:39 - 8:41
    and my Attack Time to 0.
  • 8:41 - 8:43
    So as soon as there's any signal at all
  • 8:43 - 8:45
    that's passing that threshold it's going to come
  • 8:45 - 8:46
    in to effect.
  • 8:46 - 8:48
    The attack time is usually how long it waits to
  • 8:48 - 8:50
    come to full effect, but we don't want it
  • 8:50 - 8:52
    to wait, we want it to start straight away.
  • 8:52 - 8:54
    So Attack Time should be 0.
  • 8:54 - 8:56
    Ratio should be 250. So now.
  • 9:04 - 9:06
    It's nice and prompt. As soon as I start hitting
  • 9:07 - 9:09
    the music goes down.
  • 9:09 - 9:11
    So it's going to be hard for you guys to hear on these speakers
  • 9:11 - 9:14
    and obviously you can check it out with headphones as well.
  • 9:14 - 9:16
    But that's exactly what's happening.
  • 9:16 - 9:19
    So it's time for you to save your scene,
  • 9:19 - 9:20
    and play it one more time,
  • 9:20 - 9:23
    because we have completed our training day.
Title:
TANKS! Unity Tutorial - Phase 8 of 8 - Audio Mixing
Description:

more » « less
Duration:
09:32

English subtitles

Revisions