< Return to Video

Audio Mixer and Audio Mixer Groups - Unity Official Tutorials

  • 0:01 - 0:05
    The audio mixer asset in Unity allows us
  • 0:05 - 0:07
    a great deal of control over the signal flow
  • 0:07 - 0:10
    of audio in our projects.
  • 0:11 - 0:14
    By default our main camera
  • 0:15 - 0:18
    is assigned an audio listener component.
  • 0:18 - 0:21
    The audio listener component is where audio
  • 0:21 - 0:23
    is output from the scene
  • 0:23 - 0:27
    to the headphones or the speakers of the listener
  • 0:27 - 0:32
    In Unity all audio starts at an audio source.
  • 0:32 - 0:34
    Here we have a game object called Base
  • 0:34 - 0:38
    and it's got an audio source on it which has a clip
  • 0:38 - 0:41
    of a baseline loaded,
  • 0:41 - 0:43
    which is also set to play on awake and loop.
  • 0:43 - 0:46
    There are 3 other objects
  • 0:46 - 0:49
    which contain other musical parts including
  • 0:49 - 0:51
    an arpeggio kick and percussion.
  • 0:52 - 0:54
    When we play the scene we're going to hear these
  • 0:54 - 0:57
    first 3 parts play directly through
  • 0:57 - 0:59
    the audio listener component.
  • 1:06 - 1:09
    If we want to get more control over how
  • 1:09 - 1:12
    our audio is processed we can create an
  • 1:12 - 1:16
    audio mixer asset, so choose Create
  • 1:17 - 1:19
    Audio Mixer
  • 1:19 - 1:21
    and then we can either double click on it
  • 1:21 - 1:23
    to make it visible
  • 1:23 - 1:26
    or we can go to Window - Audio Mixer
  • 1:26 - 1:28
    or choose command-8
  • 1:28 - 1:31
    on Mac or control-8 on PC.
  • 1:32 - 1:34
    The audio mixer can be docked
  • 1:34 - 1:36
    like many of the other windows,
  • 1:36 - 1:38
    I'm going to dock it down here on the bottom of my screen
  • 1:38 - 1:40
    and I'm going to expand
  • 1:40 - 1:42
    to give myself a little bit more real estate.
  • 1:42 - 1:44
    The default state for an audio mixer
  • 1:44 - 1:46
    is that it's created only
  • 1:46 - 1:50
    with a master group here.
  • 1:50 - 1:53
    In Unity's audio system we refer to channels
  • 1:53 - 1:55
    as groups because they provide a little
  • 1:55 - 1:58
    bit of additional audio functionality
  • 1:58 - 2:00
    that a normal mixer channel would not.
  • 2:00 - 2:03
    Now, we've got our master
  • 2:03 - 2:06
    and currently nothing is assigned to it.
  • 2:06 - 2:08
    If we play we'll see
  • 2:10 - 2:11
    no movement in the meters.
  • 2:11 - 2:14
    If we choose our
  • 2:15 - 2:18
    game objects here we can edit
  • 2:18 - 2:22
    for all of them the output parameter here
  • 2:22 - 2:24
    and we can assign it by clicking on it
  • 2:24 - 2:28
    to the master channel of audio mixer 1.
  • 2:28 - 2:30
    Now when we play
  • 2:33 - 2:34
    we've setup some signal flow,
  • 2:34 - 2:36
    our signal is now passing from
  • 2:36 - 2:39
    our audio sources through the master
  • 2:39 - 2:42
    to the audio listener on the main camera.
  • 2:42 - 2:44
    By default the master group
  • 2:44 - 2:48
    is created with an attenuation effect applied to it.
  • 2:48 - 2:50
    The attenuation effect is what allows
  • 2:50 - 2:53
    us to control the volume of the signal
  • 2:53 - 2:55
    passing through the master group.
  • 2:55 - 2:57
    If we want to adjust that while we're playing
  • 3:01 - 3:04
    we're going to need to click Edit In Play Mode.
  • 3:06 - 3:08
    Now we can adjust the volume
  • 3:09 - 3:12
    and we can see in the inspector on the right
  • 3:17 - 3:19
    that the change is being reflected.
  • 3:19 - 3:21
    Changes made while editing
  • 3:21 - 3:24
    during play mode will be saved
  • 3:24 - 3:26
    to the audio mixer asset.
  • 3:26 - 3:29
    Unlike scene changes, which will revert
  • 3:29 - 3:31
    when exiting play mode.
  • 3:31 - 3:35
    Currently audio mixer 1 has only 1 group
  • 3:35 - 3:36
    the master.
  • 3:36 - 3:39
    To create a more flexible signal flow
  • 3:39 - 3:42
    we're going to go over here to the Groups area
  • 3:42 - 3:45
    and click the + button twice.
  • 3:46 - 3:48
    When we click the + button a new group
  • 3:48 - 3:50
    will be created that is the child
  • 3:50 - 3:52
    of the currently selected group.
  • 3:53 - 3:56
    Notice that in the channel strip view
  • 3:57 - 3:59
    group A and group B have appeared.
  • 3:59 - 4:01
    With multiple groups in our mixer we can
  • 4:01 - 4:04
    now assign some of our parts to different groups
  • 4:04 - 4:06
    Let's assign the kick drum
  • 4:07 - 4:09
    by clicking on the output parameter
  • 4:09 - 4:11
    to group A.
  • 4:12 - 4:13
    Now if we play
  • 4:16 - 4:18
    activate Edit In Play Mode.
  • 4:24 - 4:26
    You'll notice that when we turn down group A
  • 4:26 - 4:28
    we can turn down the kick drum independently because
  • 4:28 - 4:30
    it's now on it's own group.
  • 4:30 - 4:32
    And when we turn down the master we can
  • 4:32 - 4:33
    turn down everything.
  • 4:33 - 4:36
    This is because group A is routed
  • 4:36 - 4:39
    through the master so the master controls
  • 4:39 - 4:42
    everything which is routed through it..
  • 4:42 - 4:44
    That's because of the way
  • 4:44 - 4:46
    that the groups are arranged in the groups
  • 4:46 - 4:47
    area down here.
  • 4:47 - 4:51
    We can see that group A is a child
  • 4:51 - 4:55
    of the master group and group B is in turn
  • 4:55 - 4:56
    a child of group A.
  • 4:56 - 4:58
    So if we assign our arpeggio
  • 4:59 - 5:02
    using it's output to group B
  • 5:03 - 5:04
    we can now test again
  • 5:12 - 5:15
    and we'll see that turning down group A
  • 5:15 - 5:17
    now turns down
  • 5:18 - 5:20
    both the kick and the arpeggio
  • 5:20 - 5:24
    because group B is a child of group A.
  • 5:24 - 5:27
    So here we have what's called a
  • 5:27 - 5:29
    serial signal flow routing,
  • 5:29 - 5:32
    meaning group B passes through group A
  • 5:32 - 5:35
    and then passes through the master.
  • 5:35 - 5:39
    We can also create a parallel signal flow
  • 5:39 - 5:41
    by changing the routing of group B.
  • 5:41 - 5:44
    If we click on group B in the groups area
  • 5:44 - 5:47
    and drag it's name on to the master
  • 5:47 - 5:49
    we can now make group B
  • 5:49 - 5:52
    a child of the master and pass it's signal
  • 5:52 - 5:56
    directly to the master, and we can test that out.
  • 6:04 - 6:07
    So now we have the kick in group A.
  • 6:08 - 6:10
    The arpeggio in group B.
  • 6:11 - 6:14
    And everything being run through the master.
  • 6:15 - 6:17
    While we're working in the mixer we may want to check
  • 6:17 - 6:20
    parts of our mix individually.
  • 6:20 - 6:24
    We can do this using the solo, mute and bypass
  • 6:24 - 6:26
    buttons on each of the groups.
  • 6:37 - 6:39
    When we click solo
  • 6:39 - 6:42
    all the other tracks are temporarily muted
  • 6:42 - 6:44
    so that we can hear that track by itself
  • 6:44 - 6:46
    and make any changes we need to make.
  • 6:46 - 6:49
    When we click mute the opposite happens.
  • 6:49 - 6:51
    The one track we've muted becomes silent
  • 6:51 - 6:54
    and we can hear anything else that we need to hear.
  • 6:55 - 6:59
    Bypass allows us to bypass any
  • 6:59 - 7:01
    audio effects that we've applied to the channel.
  • 7:02 - 7:04
    Let's go down and click Add
  • 7:04 - 7:06
    Low Pass Simple.
  • 7:06 - 7:08
    This is a low pass filter which will remove
  • 7:08 - 7:11
    high frequencies from our arpeggio sound.
  • 7:14 - 7:15
    Here's the arpeggio soloed.
  • 7:17 - 7:19
    Here's the bypass.
  • 7:20 - 7:22
    So if we're having problems with one of our effects
  • 7:22 - 7:25
    or we want to check something we can bypass.
  • 7:25 - 7:28
    It's worth noting that solo, mute and bypass
  • 7:28 - 7:30
    are not intended to be used at runtime
  • 7:30 - 7:32
    they're supposed to be used in
  • 7:32 - 7:34
    setting up your mix and designing your sounds.
  • 7:34 - 7:36
    But not to be controlled by the
  • 7:36 - 7:38
    engine while the game is playing.
  • 7:38 - 7:43
    Additionally each group has it's own pitch control.
  • 7:44 - 7:47
    If we look in the inspector we'll see
  • 7:47 - 7:49
    that the pitch is currently set
  • 7:49 - 7:50
    to 100 for this group,
  • 7:51 - 7:52
    our arpeggio,
  • 7:52 - 7:54
    let's set it to 50%.
  • 8:08 - 8:11
    So we can adjust the pitch not just
  • 8:11 - 8:13
    at the individual sound level using
  • 8:13 - 8:16
    audio source pitch control but also
  • 8:16 - 8:18
    at the group level.
  • 8:18 - 8:20
    In addition to controlling signal flow
  • 8:20 - 8:22
    with groups we can also control
  • 8:22 - 8:24
    signal flow with multiple mixers.
  • 8:25 - 8:27
    By using multiple mixers for each
  • 8:27 - 8:29
    category of sounds in our mix
  • 8:29 - 8:31
    we can then route those mixers
  • 8:31 - 8:34
    to groups in audio mixer 1
  • 8:34 - 8:36
    to control the overall balance of the mix.
  • 8:37 - 8:39
    If we create another mixer by
  • 8:39 - 8:40
    clicking the + button,
  • 8:41 - 8:42
    we'll call this one
  • 8:43 - 8:44
    Drum Mixer.
  • 8:46 - 8:50
    We can now create two groups within this.
  • 8:50 - 8:52
    We'll configure this in a
  • 8:53 - 8:55
    parallel routing
  • 8:55 - 8:58
    and we will assign our kick
  • 9:00 - 9:03
    to the drum mixer kick channel
  • 9:03 - 9:06
    and we'll activate our percussion source here
  • 9:06 - 9:10
    and assign that to the percussion channel.
  • 9:10 - 9:12
    In order to be able to control the volume balance
  • 9:12 - 9:14
    between those two sets of elements let's
  • 9:14 - 9:16
    create a third group
  • 9:18 - 9:20
    and route it to the master output.
  • 9:21 - 9:23
    Now if we grab our drum mixer
  • 9:23 - 9:26
    and drop it on to audio mixer 1
  • 9:26 - 9:30
    we can choose drum group as an input.
  • 9:31 - 9:33
    When we play the scene
  • 9:45 - 9:48
    We can see that our entire drum mixer
  • 9:48 - 9:51
    is now being routed through drum group
  • 9:51 - 9:53
    to the master output.
  • 9:54 - 9:56
    As you're working in the mixer and your project's
  • 9:56 - 9:58
    grow more complex you may find
  • 9:58 - 10:01
    that you want to manage the view of the mixer.
  • 10:01 - 10:03
    This can be done using the visibility
  • 10:03 - 10:06
    controls down here, let's say we want to make
  • 10:06 - 10:08
    groups A and B invisible and just view the
  • 10:08 - 10:10
    drum group and the master,
  • 10:10 - 10:13
    we can do that by clicking these eye icons
  • 10:13 - 10:15
    beside the group names.
  • 10:15 - 10:19
    Once we've made them visible we can save that in a view.
  • 10:19 - 10:21
    Here we currently only have one view,
  • 10:21 - 10:25
    let's click the + button to make another.
  • 10:25 - 10:27
    Now in view View Simple we have
  • 10:27 - 10:29
    these two groups turned off
  • 10:29 - 10:30
    and in our main view
  • 10:31 - 10:33
    we could have them turned back on
  • 10:33 - 10:35
    by clicking on the view name we can toggle
  • 10:35 - 10:37
    between different views of the mixer.
  • 10:37 - 10:39
    Snapshots allow us to store
  • 10:39 - 10:42
    and recall the state of the mixer.
  • 10:42 - 10:46
    We'll cover snapshots in their own dedicated lesson.
  • 10:46 - 10:48
    Please see the link below for more information.
  • 10:48 - 10:50
    So far we've taken a look at
  • 10:50 - 10:53
    controlling our signal flow for our game music.
  • 10:53 - 10:55
    Let's take a look at an example which includes
  • 10:55 - 10:57
    some sound effects as well.
  • 10:58 - 11:00
    Here we have the Nightmares project
  • 11:00 - 11:03
    which is available for download on the asset store.
  • 11:03 - 11:05
    What we've done is we've setup two mixers.
  • 11:05 - 11:07
    One is the master mixer and another
  • 11:07 - 11:10
    is a sound effects mixer.
  • 11:10 - 11:12
    In the master mixer we have two groups,
  • 11:12 - 11:16
    one for music and one for our sound effects.
  • 11:16 - 11:18
    We've also got our vocal effects
  • 11:18 - 11:20
    for when the player gets hurt routed
  • 11:20 - 11:22
    to a vocal effects group also on
  • 11:22 - 11:24
    the sound effects mixer.
  • 11:25 - 11:28
    Our background music is routed directly
  • 11:28 - 11:30
    to the music channel of the master mixer
  • 11:30 - 11:32
    since there's only one channel for the
  • 11:32 - 11:34
    music in this case.
  • 11:34 - 11:36
    If we play our scene we can see this in action.
  • 11:49 - 11:51
    Using this approach we can then
  • 11:51 - 11:53
    balance each separate set of effects,
  • 11:53 - 11:56
    gun shots, vocal effects
  • 11:56 - 11:59
    against our music easily
  • 11:59 - 12:01
    using one overall volume for sound effects
  • 12:01 - 12:04
    and one overall volume for music.
Title:
Audio Mixer and Audio Mixer Groups - Unity Official Tutorials
Description:

more » « less
Duration:
12:05

English subtitles

Revisions