Music, Unity

So in Part 1 of Music and Sound I talked about creating your own game music. Now I’ll show you how to integrate the music into Unity.

Unity updated many things about their engine in the latest release. One of the biggest overhauls they did was toward sound creation and manipulation within the engine. This post will go over the basics of using the sound engine but if you want to take it to the next level here is a link to Unity’s advanced tutorial on making sound groups and mixers:

Background Music

Sound and Music is sometimes the most underrated thing game developers take into consideration when making their games. But what they don’t realize is that extra addition can take a game from great, to epic. Imagine Super Mario or any of the Final Fantasy Games without their phenomenal score. The ability to completely immerse the player would be lost. Movies use music to manipulate the mood of the audience in order to provoke certain emotions; fear, sadness, anxiety. Games can use music to do the same. For example, speeding up music can create a feeling of intensity and urgency.

Implementing Sounds in Unity

Before we begin here are some Unity terms that you should know:

  • Audio Listener – controls audio output to the headphones.
  • Audio Source – where the sound comes from
  • Audio Clip – sound file
  • Audio Mixer – Controls Audio Groups
  • Audio Group – Channel for certain clips and effects

To create sound in Unity you need at least three things. I’ll leave Audio Mixer and Audio Groups out for now.

  1. Audio Clip
  2. Audio Source
  3. Audio Listener

Step 1: Create Audio Game Objects

In your hierarchy create a empty gameobject and call it SoundManager. I like to organize my sounds by putting them in an empty SoundManager Object.

Step 2: Add Audio Source to the SoundManager

Step 3: Add Audio Clip to source

Create an Audio folder in your “Assets” folder. This folder will hold all your sound clips.


Take the sound file you created from the previous post, and with your Explorer (or Finder for Macs) move it to this Audio folder.

Then add this clip to the Audio Clip area of the Audio Source you added to SoundManager.


Make sure that the Loop and Play on Awake boxes are selected as well. This will ensure that your music will play throughout your game and will play at the creation of the SoundManger object.


Step 4: Add SoundManager Script

In your scripts folder create a new script and call it SoundManager. This script can control certain effects that can be applied to your clips, like pitch controls; however I’m only use it to will ensure the game music is playing.

public AudioSource musicSource;
public static SoundManager instanceSM = null;
// Use this for initialization
void Awake () {
// Update is called once per frame
void Update () {
    if (!(GetComponent<AudioSource>().isPlaying))
        //Debug.log("Something is wrong with Music.");

And there you have it. If you press play your music should start playing. I’ll continue talking about adding sound effects to specific game objects in my next post, as well as getting into Audio Mixers.

Happy Coding


Music, Unity

So for game developers worrying about the music is one of the last things on our minds. It shouldn’t be. Music gives games the extra layer of professionalism that immerses players into the gaming experience.

Now there are a bunch of free loops online. And if you want something professional you can always pay someone to write a small loop for you too. However, for those of us developers that want our games to have a unique sound, (and have an hour or two to kill) we can create our own music loops.

One of my favorite tools to do this is Audio Sauna. It’s a really good off/online music editor and gives games a very 80s feel, with the synths and samples it uses.

IT’S SOOOO EASY TO USE! Don’t just have the same generic garage band samples that everyone has. Trust me. There. Is. A. Better. Way.

Now, I am no composer, producer, music maker, so this is just my 2 cents on how to create song for your game.

Intro to Audio Sauna

To get started you can go to the audio sauna site:


They have a great online studio for quick sound loop generation. When you open the studio you should see a screen like this:


Do you see it? Great! Okay so what are we looking at. Well the studio works like most big audio applications with a menu bar at the top some editing hotkeys below that. Your main editing area in the middle, with the source input area. And the mixer, is located at the bottom.

Creating Music

Step 1: Choosing Sound Inputs

So the art of making loops, beats, music in the studio is by creating rhythms and layering different inputs together. The studio already has up one of the default inputs: the Analog Synth. Down in the Mixer you can see that the “Analog Synth” is colored red instead of blue. This indicates that it is selected and that is the current track you are editing.

Let’s take a closer look at the Analog Synth. input. So it seems pretty daunting at first but after playing around with it for a while it gets easier to understand. On the left Audio Sauna has created some presets for you to use.


Now the AWESOME thing about this tool is that you can use your qwerty keyboard as a regular musical keyboard! “But wait?!” You exclaim, “There are way more keys on a musical keyboard than a computer one.”  Yes. The tool gets around this caveat by having an octave button that will bounce your input up and down the keyboard’s(musical) keys.


See my mouse isn’t anywhere on the screen but when I hit the keyboard key the corresponding musical keyboard key depresses.


**I’m just noticing how confusing referencing your key from your keyboard and key from your musical keyboard is getting, so I’m going to call the musical keyboard key’s “mkeys”.

Step 2: Writing Notes

You might have also noticed that the side mkeyboard is also depressed.


The mkeyboard in the main editing area, is the full standard mkeyboard. And shows you where your note will be placed in the sheet time line. You see there are two ways of adding notes to your loop’s “sheet music”. One, using your keyboard. Two, using the pencil edit tool right on the timeline.


The Pencil tool allows you to click inside of the timeline sheet and create notes that will be triggered on play. If you exit out of the Analog Synth. input editor, you will see the plain editing sheet. However the notes you create will all be on the short 1/16 beat. To change how long the note lasts just change the 1/16 to a larger fraction, by clicking on it.


At the top of the sheet you can see a green bar. The green bar on the top signifies the length of the loop.

Step 3: Recording Music

Now to actually save any noise you have been creating you need to record your key input.

Let’s get the Input tool back. By double clicking the red Analog Sync. will bringing it back into view. Click on the keyboard to start using the keyboard to manipulate the mkeys. Now hit the record button on the bottom.


The green bar is now highlighted over with a red one, to signify that it is recording your key strokes now. Each time you press a key a red mark should appear one 1/16 at a time.


Great! now keep playing around with the beat until you fill up the loop.

Step 4: Layering beats

So I mentioned that using the tool was meant for layering sounds on top of one another. So lets make those other beats. Click the top right horizontal bars.


A new screen should appear. Currently the Analog Synth is selected and is the only track that has notes in it.


Now double click on the FM-Synth. The tool will then change back to the editor view, but for the FM-Synth.


As you can see below the FM-Synth is now red in the mixer. However, the Analog Synth input editor is still out.


To get the FM-Synth input tool out double click on the red FM synth name in the mixer.


A new input should appear now, like the one above. This time the presets are on the right hand side. Select one of them and beginning hitting the keys, to hear what kind of sound will be made.

This editor works the same as the one before. So either with the pencil, or in record mode with the keyboard, you can create your timeline sheet music. There is also a Sampler input that you can use. You will have to repeat the process.

Step 5: Saving the Loop

So after you have composed your amazing awesome mix. Lets get it into unity. From the File Menu there are two options you should be familiar with. The Save to My Computer option and the Export Loop as Audio File.


You should use the Save to My Computer option when you haven’t quite finished your mix and would like to work on it later. The Tool saves what you’ve done as a session that you can reopen with the tool again. The Export Loop as Audio File is the one we need when we are done with our loop and want to put it into Unity.

The next blog post in the series will be adding your saved Loop into Unity!

Happy Mixing!