Game Audio Development with Unity 5.X - Micheal Lanham - E-Book

Game Audio Development with Unity 5.X E-Book

Micheal Lanham

0,0
41,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

Create 'AAA' quality game audio with new features and tools built for Unity

About This Book

  • Explore the basics of audio development in Unity to create spatial sound, mixing, effects, composition, adaptive audio and more.
  • Leverage the Audio Mixer of Unity 5.x to create blockbuster sound and music for your game.
  • Learn about developing professional audio for games with FMOD Studio and composing original music with Reaper.
  • Build amazing audio synchronized graphic visualizations with Unity.
  • Understand how real-time character lip syncing can be implemented.

Who This Book Is For

The ideal target audience for this book will be game developers, both Indie as well as semi pro. No prior knowledge of Unity and audio development is assumed,

What You Will Learn

  • Develop game audio and other audio effects with Unity
  • Getting familiar with the new Audio Mixer introduced in Unity 5
  • Implement dynamic and adaptive audio using various tools and strategies
  • Explore interesting ways to incorporate audio into a game with sound visualization
  • Use 3rd party professional audio development tools like FMOD
  • Compose original music and record vocals
  • Understand and troubleshoot audio performance issues

In Detail

Game Audio is one of the key components in making a game successful and it is quite popular in the gaming industry. So if you are a game developer with an eye on capturing the gamer market then this book is the right solution for you.

In this book, we will take you through a step by step journey which will teach you to implement original and engaging soundtracks and SFX with Unity 5.x. You will be firstly introduced to the basics of game audio and sound development in Unity. After going through the core topics of audio development: audio sources, spatial sound, mixing, effects, and more; you will then have the option of delving deeper into more advanced topics like dynamic and adaptive audio. You will also learn to develop dynamic and adaptive audio using the Unity Audio Mixer. Further, you will learn how professional third party tools like FMOD are used for audio development in Unity. You will then go through the creation of sound visualization techniques and creating your own original music using the simple yet powerful audio workstation Reaper. Lastly, you will go through tips, techniques and strategies to help you optimize game audio performance or troubleshoot issues.

At the end of the book, you'll have gained the skills to implement professional sound and music. Along with a good base knowledge audio and music principles you can apply across a range of other game development tools.

Style and approach

This book will have a step by step practical approach where downloadable free games will be given with the book and readers will be free to work with them.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 428

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Game Audio Development with Unity 5.X
Design a blockbuster game soundtrack with Unity 5.X
Micheal Lanham

BIRMINGHAM - MUMBAI

Game Audio Development with Unity 5.X

 

Copyright © 2017 Packt Publishing

 

 

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: June 2017 Production reference: 1280617 Published by Packt Publishing Ltd.

Livery Place
35 Livery Street
Birmingham
B3 2PB, UK. ISBN 978-1-78728-645-0www.packtpub.com

Credits

Author

Micheal Lanham

Copy Editor

Charlotte Carneiro

Reviewer

Francesco Sapio

Project Coordinator

Sheejal Shah

Commissioning Editor

Amarabha Banerjee

Proofreader

Safis Editing

Acquisition Editor

Reshma Raman

Indexer

Tejal Daruwale Soni

ContentDevelopmentEditor

Jason Pereira

Graphics

Jason Monteiro

Technical Editor

Prashant Mishra

Production Coordinator

Shantanu Zagade

About the Author

Micheal Lanhamis a solutions architect with petroWEB and currently resides in Calgary, Alberta, in Canada. In his current role, he develops integrated GIS applications with advanced spatial search capabilities. He has worked as a professional and amateur game developer building desktop and mobile games for over 15 years. In 2007, Micheal was introduced to Unity 3D and has been an avid developer, consultant, and manager of multiple Unity game and graphic projects since.

Micheal has previously written Augmented Reality Game Development, also published by Packt Publishing in 2017.

 

I would really like to thank the team at Packt Publishing for all their support and assistance in making this book so easy and enjoyable to write. It has been a joy working with the team, which is composed of nothing but dedicated professionals. I would especially like to thank Reshma Raman and Jason Pereira. Reshma, the Senior Acquisition Editor, understood and agreed with the vision I had for this book. Jason, the Content Development Editor, has been a joy to work with and has worked hard assisting me when needed. Of course, no book would ever make it past the first draft if it were not for the dedication and hard work of the reviewers. So I would also like to make a special thanks to all the dedicated and hard work of the reviewers. Writing a book would not be possible if I didn't have the support of my family and friends, Especially, with the help of my little tester and ideas contributor, Ava, who has been a great asset in developing several of the books exercises. Yet, none of this would be possible without the help and support of Rhonda. Rhonda has been gracious enough to draw some of the initial diagrams, lend her musical ear, and help with those first draft reviews. I found this book a pleasure to write, and none of it would have been possible without any of the people I mentioned above.

 

About the Reviewer

Francesco Sapio obtained his Computer Science and Control Engineering degree from Sapienza University of Rome, Italy, with a couple of semesters in advance, graduating summa cum laude. He is currently studying a Master of Science in Engineering in Artificial Intelligence and Robotics at the same university.

He is a Unity 3D and Unreal expert, a skilled game designer, and an experienced user of the major graphics programs. He developed Gea 2: A New Earth (Sapienza University of Rome), an educational game for high school students to learn concepts of physics, and Sticker Book (series) (Dataware Games), a cross-platform series of games for kids. In addition, he worked as consultant for the (successfully funded by Kickstarter) game Prosperity - Italy 1434 (Entertainment Game Apps, Inc), and for the open online collaborative ideation system titled Innovoice (Sapienza University of Rome). Moreover, he has been involved in different research projects, such as Belief-Driven-Pathfinding (Sapienza University of Rome), a new technique of pathfinding in videogames that was presented as a paper at the DiGRA-FDG Conference 2016; and Project Anima (Royal Melbourne Institute of Technology), which included developing a recommendation system for games.

He has authored several books for Packt. He is an active writer on the topic of game development. Recently, he authored the book Getting Started with Unity 5.x 2D Game Development, which takes your hand and guides you through the amazing journey of game development, the successful Unity UI Cookbook, which has been translated into other languages, and teaches readers how to develop exciting and practical user interfaces for games within Unity, and a short e-guide called What do you need to know about Unity. In addition, he co-authored the book Unity 5.x 2D Game Development Blueprints. Furthermore, he has also been a reviewer for the following books: Game Development Patterns and Best Practices, Game Physics Cookbook, Mastering Unity 5.x, Unity 5.x by Example, and Unity Game Development Scripting.

Francesco is also a musician and a composer, especially of soundtracks for short films and video games. For several years, he worked as an actor and dancer, where he was a guest of honor at the theatre Brancaccio in Rome. In addition, he is a very active person, having volunteered as a children's entertainer at the Associazione Culturale Torraccia in Rome.

Finally, Francesco loves math, philosophy, logic, and puzzle solving, but most of all, creating video games--thanks to his passion for game designing and programming.

You can find him at www.francescosapio.com.

Acknowledgments

I’m deeply thankful to my parents for their infinite patience, enthusiasm, and support throughout my life. Moreover, I’m thankful to the rest of my family, in particular to my grandparents, since they have always encouraged me to do better in my life with the Latin expressions “Ad maiora” and “Per aspera ad astra”. Finally, a huge thanks to all the special people around me whom I love, in particular to my girlfriend; I’m grateful for all of your help in everything. I do love you.

www.PacktPub.com

For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www.packtpub.com/mapt

Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.

Why subscribe?

Fully searchable across every book published by Packt

Copy and paste, print, and bookmark content

On demand and accessible via a web browser

Customer Feedback

Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial process. To help us improve, please leave us an honest review on this book's Amazon page at https://www.amazon.com/dp/1787286452.

If you'd like to join our team of regular reviewers, you can e-mail us at [email protected]. We award our regular reviewers with free eBooks and videos in exchange for their valuable feedback.

Help us be relentless in improving our products!

To my father Leslie, who taught me how to love and appreciate music of all forms.

Table of Contents

Preface

What this book covers

What you need for this book

Who this book is for

Conventions

Reader feedback

Customer support

Downloading the example code

Downloading the color images of this book

Errata

Piracy

Questions

Introducing Game Audio with Unity

Introduction to game audio

Main game audio components

Diegetic versus non-diegetic sound

Audio layers or groups

Getting started with unity

Downloading unity

An introduction to unity

Downloading and importing project assets

A tour of the village

Importing audio into unity

Inspecting the imported audio files

Audio sources and listeners

Adding an audio source

3D sound and spatial blending

Summary

Scripting Audio

Introduction to scripting in Unity

Building a musical keyboard

Importing and playing notes

Enhancing the virtual keyboard

Weapons and sound

Throwing the ax

Understanding the axController script

Playing sounds on collision

Randomizing audio

Background music

Summary

Introduction to the Audio Mixer

Introducing the Unity Audio mixer

Creating mixer groups

Shaping audio with effects

Visualizing audio equalization

The master mixer and controlling signal flow

Routing audio signals in the mixer to effects

Audio effects breakdown

Equalization effects

Lowpass and Lowpass simple

Highpass and Highpass simple

ParamEQ

Delay effects

Echo

SFX reverb

Flange

Chorus

Other effects

Pitch Shifter

Normalize

Compressor

The duck volume effect

Summary

Advanced Audio Mixing

Recording audio changes with snapshots

Pausing the scene

Audio Mixer scripting with parameters

A dynamic audio wind effect

Creating environmental audio zones

Dynamic music mixing

Summary

Using the Audio Mixer for Adaptive Audio

Introducing adaptive audio

Building adaptive audio cues

Creating mood with adaptive music

Vertical remixing with the Audio Mixer

Footsteps with adaptive sound

Summary

Introduction to FMOD

Getting started with FMOD Studio

Installing FMOD Studio

Back to the basics

Effects and mixing

Mixing in a reverb effect

Parameters, snapshots, and triggers

Summary

FMOD for Dyanmic and Adaptive Audio

Dynamic wind and environmental zones

Scripting with FMOD

Revisiting the footsteps example

Adaptive music with FMOD

Transition timelines and stingers

Summary

Visualizing Audio in Games

Analyzing audio with Fast Fourier Transform (FFT) windows

Audio spectrum

Deconstructing signals using FFT and windowing

Examining an audio visualizer

Uncovering the details

Visualization performance and windowing

Audio-driven lighting

Microphone-driven visualizations

Summary

Character Lip Syncing and Vocals

Real-time lip syncing

Speech and phonemes

Blend shape animation

Real-time character lip sync

Recording vocals

Summary

Composing Music

Getting started with Reaper

MIDI and virtual instruments

Virtual instruments

Basic music theory

Chords and chord progressions

Chord progression

Melody and scale

Enhancing the composition

Recording music and vocals

Recording and optimizing vocals

Summary

Audio Performance and Troubleshooting

Audio performance considerations

Profiling performance with Unity

Audio optimization tips and tricks for Unity

Memory optimization tips and tricks

Effects optimization tips and tricks

FMOD performance and optimization

Audio troubleshooting

Summary

Preface

From those exotic sound effects that improve game fun and playability to that dark musical score that sets the entire atmosphere of a scene or game audio is essential to any great game. Yet it is perhaps one of the most often overlooked assets in the development of a game by new or indie developers. Instead, they dedicate the bulk of their effort to graphics and other visuals, often deferring the audio portion until the later stages of production. They do this not because good audio is not a critical aspect to any good game, but as a single or indie developer they feel AAA game quality audio is out of reach. Of course, that is far from the truth, especially with the great audio system built into Unity and the many freely available commercials plugins and tools.

This book was written to introduce the reader to the extensive audio framework built within Unity and other freely available commercials tools and plugins. Often, audio development tools expect a certain level of knowledge in sound, mixing and music. By following through the books material and exercises a reader should be able to master all the essentials of audio development. From the basics of implementing an audio source; to spatial sound, mixing, effects and dynamic and adaptive audio system. As well there will be time spent learning professionals like FMOD Studio for game audio and Reaper for music composition. While the book assumes no prior knowledge of working with Unity or audio, there will be enough new and interesting content that even the more advanced developer will find useful.

What this book covers

This book starts from the fundamentals of starting game audio development with Unity and progresses to using advanced commercial tools for professional game audio and music composition. It is assumed the reader will follow the chapters in sequential order as many chapters build from previous exercises. Each of the chapters is listed below with a quick summary:

Chapter 1, Introducing Game Audio in Unity, Unity is introduced and the reader is guided through installation of the software and setup of the first project. Which includes importing audio assets, audio source essentials and setting up spatial sounds.

Chapter 2, Scripting Audio, the basics of scripting in Unity is introduced with the writing of a simple musical keyboard. Followed by; scripting weapons, sound effects, physics and implementing ambient sounds and music.

Chapter 3, Introduction to the Unity Audio Mixer, introduces the basics of the Audio Mixer, mixing audio sources and effects, with further coverage on mixer signal routing and using the Duck Volume effect.

Chapter 4, Advanced Audio Mixing, covers using advanced capabilities of the Audio Mixer. From mixer parameter scripting, snapshots, snapshot transitions, and developing audio transition zones.

Chapter 5, Using the Audio Mixer for Adaptive Audio, introduces adaptive audio and covers techniques for mixing adaptive music.The rest of the chapter is spent implementing adaptive audio in sound and music.

Chapter 6, Introduction to FMOD, starts with the installation and setup of FMOD Studio. Then, it goes over the similarities and differences between the Unity Audio Mixer and FMOD.

Chapter 7, FMOD for Dynamic and Adaptive Audio, builds upon previous advanced examples and converts or adapts them to use FMOD. The chapter covers several advanced techniques of working with FMOD Studio.

Chapter 8, Visualizing Audio in Games, starts with a background of how sound can be broken down by frequency with mathematical techniques know as FFT Windowing. Those techniques are then used to create stunning audio-visual dancing lights and graphics.

Chapter 9, Character Lip Syncing and Vocals, builds upon previous work and builds a real-time character lip syncing demo. By covering character bone and vertex animation, lip-sync animation with phonemes, and recording with Unity.

Chapter 10, Composing Music, introduces the basics of music composition with Reaper using some simple music theory. It covers the installation and setup of Reaper, MIDI basics, virtual instruments, audio rendering and recording.

Chapter 11, Audio Performance and Troubleshooting, covers the fundamentals of audio performance with Unity and FMOD. From performance profiling to the tips and tricks of optimizing and troubleshooting performance issues.

What you need for this book

In order to be successful with this book you will need to have an eagerness to learn the basics and master game audio development. No previous game or audio development knowledge is required. Although, it may be helpful to have some knowledge of scripting with a C language like C#, JavaScript or C++, but it is not essential. Covering some of the material may be easier if you know how to play an instrument or understand sound or music theory, but again this is not required. You should have a desktop or laptop computer running Windows XP+, Mac OS, or Linux to complete the book's essential exercises.

Who this book is for

This book is for anyone who wants to learn how to create better sound for their games or just have a better understanding of how audio works in games. While this book is directed at the individual or indie development team, it certainly could be put to good use by sound designers or audio enthusiasts.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

 

You can download the code files by following these steps:

Log in or register to our website using your e-mail address and password.

Hover the mouse pointer on the

SUPPORT

tab at the top.

Click on

Code Downloads & Errata

.

 

Enter the name of the book in the

Search

box.

Select the book for which you're looking to download the code files.

Choose from the drop-down menu where you purchased this book from.

Click on

Code Download

.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for Windows

Zipeg / iZip / UnRarX for Mac

7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Game-Audio-Development-with-Unity-5X. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/GameAudioDevelopmentwithUnity5X_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.

Introducing Game Audio with Unity

Welcome to our journey into game audio and audio development with Unity. It is the leading cross-platform game engine that provides an abundance of features to make developing games easy. For this book, it doesn't matter if you are completely new to game audio, Unity, or game development. We will start with the assumption that you are a complete novice and build from there. With each new chapter, we will be introducing new concepts and additional material. Of course, if you are an experienced Unity developer with basic knowledge of audio development, you may want to skim over the first couple of chapters. Regardless of if you are a novice or master, the later chapters in this book will cover plenty of Unity features and tools to give you the knowledge of developing AAA game quality audio for your games.

In this chapter, we will cover the basics of Unity and add audio to a project and scene in Unity. As this is the first chapter, we will be covering a quick introduction to game audio and then spend some time installing and configuring Unity. From there, we will introduce the core Unity components and how they function. Here is a summary of what we will cover in this chapter:

Introduction to game audio

Getting started with unity

Importing audio into unity

Audio sources and listeners

3D sound and spatial blending audio

As with most of the chapters in this book, it is expected that you follow along and complete each of the exercises. Completing the exercises hands on will reinforce all the concepts and provide you with a good foundation for the more complex material introduced in later chapters. All the material required to complete the exercises will either be provided via the book's downloaded source code or will be freely available online. Therefore, in almost all cases, you will be required to have an internet connection. If you feel that you understand the content in a chapter and just want to review the completed examples, then follow the instructions provided in the book's download to build the final examples.

Introduction to game audio

Chances are, if you have played a few computer, video, or mobile games in your life, you are already quite familiar with what great game audio should sound like. Perhaps; you even cherish the audio from a couple of your favorite games. However, if someone asked you how they composed or mixed that audio, unless you were a professional audio technician, you would likely be at a loss on how the audio in a game mixes together. Fortunately, in this section, we will start to introduce some of the basic concepts of game audio, which we will of course build upon in later chapters in this book.

Main game audio components

Game audio, unlike audio a sound designer would compose for film or television, will typically be broken down into three distinct areas as listed here:

Music

: This includes content such as theme or background music, in-game music such as a radio or a band playing, and can even include certain audio effects. Creating or obtaining unique music for your game could be as complex as recording a music track in a sound studio to purchasing rights to a music track of the asset store. In

Chapter 10

,

Composing Music

,

we will explore how to compose your own unique tunes.

Sound

: This generally includes sound effects, such as creaking doors, explosions, footsteps, clicking, beeping, and many others. Most sound designers or developers will often browse through many of the free or paid sound effects sites to find a sound they like. Another option is to record your own sound effects, essentially becoming a

Foley

artist. In

Chapter 10

,

Composing Music

,

we will look at some techniques to create some unique sound effects in software.

Foley artists are traditionally people who create sound effects for film, television, and now games. The term Foley was coined from the originator, Jack Foley, who created real-time sound effects for early motion pictures. Today, the practice is no longer real time, but the name "Foley" is still synonymous with recording and creating sound effects.

Vocals

: The addition of vocals to games is a relatively new addition. Vocals were first introduced in cut or intro game scenes but now they are a main element in any AAA title. Furthermore, most AAA titles will enlist a well-known actor to provide vocals for further enhancement of the game. In

Chapter 9

,

Character Lip Syncing and Vocals

,

we will cover some details about generating vocals. As well in several other chapters of this book, we will highlight the use of vocal cues in scenes.

While game audio design is similar to film and television, in many components, it differs primarily by its implementation. Audio for film follows a linear well-defined pattern, whereas in games audio is non-linear and may even be dynamic or adaptive. We will of course cover many aspects of how game audio is dynamic and adaptive in the Adaptive Sound and Music section.

Diegetic versus non-diegetic sound

If you have never heard of the term diegetic, you may just have gotten a queasy feeling in your stomach wondering what you got yourself into. Do not worry, the term diegetic refers to audio that is audible in the scene or screen as a part of the action or interaction. Conversely, non-diegetic refers to sounds that are added to the scene or screen and are not visible. Perhaps; it is more helpful if we look at some examples of diegetic and non-diegetic sounds, listed here:

Diegetic sounds include:

Sound effects

: Explosions, gun fire, car engine, or collisions

Music

: Band playing, musical instruments onscreen playing, or car radio

Vocals

: Character dialogue, voices, or crowds

Non-diegetic sounds include:

Sound effects

: Off screen sound effects such as coins entering a purse, tones to denote activity changes in a game, or footsteps

Music

: Scary background theme music, a novelty theme, or boss theme music

Vocals

: Narration, character vocal cues, or haunting voices

These terms may sound rather abstract right now, but be rest assured, we will get fairly intimate with the use of non-diegetic sounds in the adaptive sound and music section. As you will learn, one of the cornerstones of developing great game audio is building up good non-diegetic sounds.

You may have already noticed that game audio borrows or shares a number of common film and television terms sound designers use. That, of course, is not by accident. Games have been using the same principals of audio design established for movies and television for many years. In fact, later on in this book, we will explore the use of various commercial Digital Audio Workstations (DAW) traditionally used for film or television and now plugins to Unity.

Audio layers or groups

In virtually all digital games, the three base audio components we defined earlier may also include effects that will be broken into distinct layers or groups. This not only simplifies audio composition and development, which can become quickly complex as we will see, but also separates out critical audio elements. While you can think of each layer of audio playing separately during the game, from the player's perspective they will hear all the layers mixed together. The following list defines a set of basic layers we will use to group our audio:

Ambient and environmental audio

: This includes both diegetic and non-diegetic audio such as waterfalls, ocean waves, birds chirping, a rowdy tavern, crowds, a humming power plant, or a band playing music. This group is not just limited to audio sound clips but may also include effects such as reverb, echo, distortion, or other environmental audio effects. We will cover ambient audio effects in more detail starting in

Chapter 2

,

Scripting Audio

.

Direct feedback audio

: This will include any sound elements that that need to react directly to player input in a scene or on the interface. Diegetic examples of this would be shooting/reloading a gun, throwing a grenade, or watching something explode. Non-diegetic examples of this would be the sound of character getting shot, boss music playing, vocal cues, or dialog. Starting in a

Chapter 2

,

Scripting Audio

,

we will cover several examples of this type of audio.

Interface audio

: This includes sounds activated as part of the game interface. This typically would include items such as button clicks or notifications. We really won't go into too much depth in this area, as interface sounds are fairly standard and use the same principals you learn to manage other audio that is easily transferable to the interface.

Background or theme music

: This area is relatively self-explanatory and immediately conjures up your favorite game theme music. However, background music can be used to dynamically change and thus alter the tone of a game during various conditions. This form of audio change is known as adaptive music and is something we will spend a great deal of time on, starting in the

Adaptive sound and music section

. In

Chapter 2

,

Scripting Audio

, we will introduce the use of background music in a scene.

Remember, this is only a basic definition of layers we have grouped our basic audio components into. As you will see through the rest of this book, there are a number of other ways we can group or layer audio. In Chapter 3, Introduction to the Unity Audio Mixer, we will cover the use and definition of audio groups in more detail.

Now that we have some very basic audio terminology defined, let's get into putting some of this knowledge to use in Unity. In the next section, we will look at downloading and setting up Unity.

Getting started with unity

This section assumes that you have never installed Unity before and will take you through a step-by-step exercise on download and installation. If you have installed Unity before, you may still want to quickly review this section, just to confirm you have installed the required components.

Downloading unity

Follow the instructions to download Unity:

Enter the following URL,

https://store.unity.com/

, into your favorite web browser or just click on the link.

After the page loads, you will see several licensing options. For the purposes of this book, all you need is the

Personal

Unity license. So, just click on the

Download now

button on the

Personal

license as shown in the following screenshot:

Screenshot from Unity store showing Personal license Download now button

A new page will load, showing a big green button labeled

Download Installer

. Click on the button to download the Unity Download Assistant with your web browser.

After the package has completed downloading, open it as you would any other program. The Unity Download Assistant is relatively small so it should download quite quickly.

 

Agree to any security notifications or notifications you normally encounter when installing new software on your computer. After the installer launches, you will see a screen similar to the following screenshot:

Unity Download Assistant starting
If you are unable to install software on your computer due to security restrictions or other account settings, be sure to contact your administrator and ask them to give you access or have them install the software. During the course of this book, we will be downloading several software packages so it is advisable that you have the ability to install new software on your machine in order to complete all the exercises in the book.

Click on the

Next

button to continue. Then on the next page, select the checkbox to agree to the Unity license as shown in the following screenshot:

Unity terms of service page

Click on the

Next

button to continue. The next page will likely offer you an option to choose between 32 and 64-bit architecture. It is usually best to take the default (64 bit in most cases) and click on the

Next

button to continue.

The next page will allow you to choose the Unity components you want to install. This page allows you to choose from a number of components to install along with Unity. For the purposes of this book, you only need to install the default components. However, if you feel you may need or want other components, such as Android or iOS, feel free to select those as well. Just be sure to have the three main components selected as shown in the following screenshot:

The Choose Components section of the Unity install

After you have made your component selections, click on the

Next

button to continue. For the next couple of dialog pages, just keep the defaults and let the installation download and install Unity. Since this can take a while, feel free to grab your beverage of choice while you wait for the installation to complete.

The Unity installation will generally run very smoothly, but if you do encounter some issues, it is best to follow the recovery instructions the installer may provide. If that doesn't fix the issue, just do a quick search and check the Unity forums. Unity has a huge community of developers that are very eager to assist newcomers with any issues, and it is almost certainly likely someone has already encountered a similar issue to yours.

Once the Unity installer has finished installing Unity, follow the instructions here:

On the last page of the installer, you will usually be prompted with an option to launch Unity right away. Be sure that option is selected and then exit the installer.

As the program launches, you may get a notice to provide an exception in your firewall; be sure to allow this. After Unity launches, you will be welcomed by a login screen as shown in the following screenshot:

Unity login or welcome screen

If you have never installed Unity before, you will need to create a Unity Account. Just click on the blue create one text as shown in the preceding screenshot. This will take you to a registration area of the Unity site. From there, complete that account setup, and when you are done, return to this item.

Now that you have a Unity account created, enter your email and password in the dialog and then click on the Sign In button. After you sign in, you will be directed to the project page.

That completes your first step to becoming a Unity developer. In the next section, we will create a new project and explore the Unity interface.

An introduction to unity

Now that we have Unity installed, let's dive right in and create a project and then take a quick overview of the interface. Perform the following directions to create a new Unity project:

If this is your first time running Unity, at this stage, you will have a dialog with a button allowing you to create a new project; click on the

NEW

. For those of you who have jumped here from another section in the book, be sure to launch Unity and make sure you are logged in with your Unity account. From there select the

NEW

project button at the top of the Unity start page.

The project dialog will open. Enter the project name as

GameAudioBasics

and then keep the defaults for all the other settings as shown in the following screenshot:

Creating a new project in Unity

After you fill in the Project name, click on the

Create Project

button.

Unity will close the dialog, and you will see a progress dialog flash as the project is initialized and the interface loads. When Unity is done loading, you will see a screen that looks similar to the following window:

Unity interface
If you have run Unity before or if you are using a different license, such as pro, your screen may appear to be quite different. Aside from any themes applied, you can return to the default layout by selecting from the menu Window | Layouts | Default.

Now that we have Unity running, let's review what each of the main windows or elements are for. You can follow along using the reference numbers shown in the preceding window screenshot to match the items in the list here:

Hierarchy window (1)

: This window shows the currently displayed scenes and scene elements called a

GameObject

in Unity. Currently, there should be a scene labeled

Untitled

in the window. Click on the arrow beside the scene to expand it and then click on the items beneath the scene. Notice how the other windows change depending on your selection.

Scene view (2)

: You can think of the scene window or the view as the design canvas for your game project. In this view, you can select and move objects around using the mouse or the principal direction arrows (the colored arrows). Feel free to select objects in the view and move them around. Don't worry about moving things out of place or getting lost as we are creating a new scene before we start building anything of importance.

Inspector window (3)

: This window exposes and allows you to edit the properties and components of the currently selected GameObject. A lot of the time you spend working in Unity will be editing values in this window. Again, feel free to explore this window by editing some properties of a GameObject.

Project window (4)

: This window shows all the resources or assets you have in the entire Unity project. As you can, see the project is currently quite bare. Not to worry, we will be quickly adding new assets.

Game view (5)

: This window or view shows how the game will look to the player. It differs from the

Scene

view because it only shows what the player sees. If you click on the game window tab, you will see a sparse view of the ground layer and sky. Again, this is because we have yet to add anything interesting.

Play mode (6)

: This is the set of buttons at the top of the Unity interface control running the game in the editor. The buttons allow you to play and pause the game play. If you click on the play button right now, not much will happen other than the

Game

view will present itself.

At an advanced level, that covers the main elements of the Unity interface without getting bogged down in too many details. It could very well take you months or years to become an expert in using all the features of Unity. So, in order to not overwhelm you, we will only focus on the relevant information you need to complete an exercise.

So far we have been looking at an empty project and scene. In the next section, we will import a project from the Unity Asset Store.

Downloading and importing project assets

One of the really great features of Unity is the Unity Asset Store. Game development is a complex process that requires many artistic skills in multiple areas to develop quality assets, such as 3D models, animation, textures, sound, music, shaders, and more. Chances are, if your development team is just you or a small group of developers and artists, your team will lack the skillset or time to develop all the assets for your project. Fortunately, the Unity Asset Store provides professional game quality assets at very competitive pricing or in some cases for free. Unity itself also provides a number of high-quality sample projects free of charge on the store. We will be using a couple of those projects in this book as the base for our exercises in audio development.

Follow the instructions here to download and import the project we will use for the rest of the exercises in this chapter:

From the menu select

Window

|

Asset Store

. This will open a new tab beside the

Scene

and

Game

views called

Asset Store

.

After the page loads in the window, there should be a search box visible at the top of the window. Enter the text

unity viking village

in the search box and click on the search button as shown in the following screenshot:

Searching in the Unity Asset Store

When the search completes, there will be a list of search results. The first result in the list should match

Viking Village

from Unity Technologies. Click on this item, and you should see the asset page as shown in the following screenshot:

Viking Village asset page

Click on the blue button labeled

Download

, as shown in the screenshot to start downloading the asset.

As the asset downloads, the button will show the progress. The download may take a while, so be patient and of course feel free to grab another one of your favorite beverages.

 

When the download completes, the button will read

Import

. Click on the button to import the project into Unity. You will be immediately prompted by a dialog informing you that this is a complete project, as shown here:

Project import warning

Click on the

Import

button on the dialog to continue the project import. Importing a new project over our project is entirely okay since we have nothing we wanted to save at this point.

A dialog will appear showing you the progress of the import. This take a couple minutes after which you will be prompted with the

Import Unity Package

dialog, as shown here:

Import Unity Package dialog

The

Import Unity Package

dialog shows all the assets to be imported as a part of the project. Feel free to scroll through the list and review the items being imported. Then, click on the

Import

button on the dialog to complete the project import.

Yet another dialog will open showing you the progress of the last stage of the import. Just be patient and enjoy that beverage or grab another, the asset will load in several more minutes.

This project asset we are importing is on the large side, at around 900 MB. Fortunately, we will only need to do this once. As we will continue to reuse this project throughout the book. Generally, the assets you download from the Asset Store will often be under 100 MB.

The amount of time to import a project will be determined by the size of the asset and the content. Assets such as textures, for instance, will be compressed and often take extra time to load. Unfortunately, the sample project we are loading is composed of several compressed assets.

When the import is complete, you will now find that the

Project

window is now showing several new asset folders.

Now, that we have our base project imported, in the next section, we take a quick look at the main scene and several features that will help us going forward.

A tour of the village

After doing all that work getting the project loaded; okay, perhaps not so much work as waiting, let's load the project scene and take a quick tour of the asset by following the directions here:

Click on the

Scenes

folder in the

Project

window and then double-click on the

The_Viking_Village.unity

file to open the scene. The screenshot here shows the

Project

window:

Opening the project scene

After the scene loads, you will notice that the

Hierarchy

window is now filled with objects. Click on the

Scene

view tab to open the view and you should now see something very similar to what is shown in the following screenshot:

Hierarchy window and Scene view

Press the editor play button, as shown in the preceding screenshot to start the scene and run the game.

As the game is running, the

Game

view will automatically present itself. Use the following commands to move around the game and explore the environment and features:

W

,

A

,

S

,

D

: The standard first person movement commands. Use these keys or the arrow keys to move around the scene.

Mouse

: This controls the look direction.

Spacebar

: This is used to jump up. Quickly taping the

Spacebar

key will cause the camera to hover/fly while in manual mode.

C

: This toggles between a controlled camera walkthrough and the manual or keyboard movement (first person).

Esc

: This exits the mouse lock and makes the mouse visible in the editor again.

Take your time to explore the environment and feel free to move around as much as you like. When you are ready to move on, press the

Esc

key to make the mouse visible again and then press the play button again to stop the game running.

Hopefully, you noticed, as you were moving around the game, how quiet everything was. Fortunately, that makes this scene the perfect canvas for us to develop our own game audio. This is exactly what we will do for the next several chapters in this book.

Installing Unity and getting your first project loaded is a great first step to becoming a Unity game developer. Congratulate yourself for your patience in spending the time to work through this section. In the next section, we will get back to more audio development basics.

Importing audio into unity

Aside from downloading content from the Asset Store, there are a number of ways of introducing content into a Unity project. Most often, the simplest way of adding content to your project is placing the appropriate files into the relevant project folders. Unity is then smart enough to inspect the new files, provided the file type is supported by Unity, and determine the asset type to automatically import the content. Since there are a number of audio file types out there, let's take a look at the audio file format Unity currently supports in the following list:

.wav

/

.aif

: Both of these formats are uncompressed, lossless formats, which means they are exact copies of the original audio. The

.aif

originated on the Mac, while

.wav

came from the PC. Now both formats are supported by either operating system.

Compressing audio or other forms of media is done in order to reduce the file size for easy transport or download. Since media compression will cause a loss of quality to the media, the term lossy is used to denote a compressed media format. Whereas, lossless or no loss, denotes a media format with no compression and thus no loss in quality.

.mp3

: This is the most common compressed or lossy format for audio. This format became very popular for transferring/downloading music.

.ogg

: This, also known as

Ogg Vorbis

, was developed as a patent free alternative to mp3. The standard format is lossy but it can support lossless as well.

Unity can also import tracker module formats such as impulse tracker (.it), scream tracker (.s3m), extended module file format (.xm), and the original module file format (.mod). We won't cover these file types until later, in Chapter 10, Composing Music.

Now that you have a better understanding of the supported audio files types, let's import a couple of files into our project in the following exercise here:

Before importing any content, we will create a new set of folders in the project. This will help us organize and find this content later. As you can see, by just taking a quick look through the

Project

window, a game project may contain numerous assets in multiple areas.

Right-click (c

ontrol

+ Click on Mac) on the root

Assets

folder in the

Project

window. Then, select

Create

|

Folder

from the context menu.

A new folder will be created under the

Assets

folder with the cursor prompting for input. Name the new folder

Audio

.

Right-click (c

ontrol

+ Click on Mac) on the new

Audio

folder and select

Create

|

Folder

from the context menu. Name the folder

Ambient

and your

Project

window now look like the following screenshot:

New Audio and Ambient folders created in Project window

Right-click [c

ontrol

+ Click on Mac] on the

Ambient

folder and select

Show in Explorer

from the context menu. This will open a file explorer on your desktop. Double-click on on the

Ambient

folder to open it; the folder should be empty.

Go to your desktop and open the books downloaded source code

Chapter_1_Audio

folder in another file explorer window. Drag the folders so that they are adjacent to each other and both visible. A sample screenshot is shown here:

Ambient and source code folder: Chapter_1_Audio side by side

Drag and drop all the files from the

Chapter_1_Audio

folder into the

Ambient

folder. Then, switch back to the Unity editor. After a couple seconds, you should see the

Ambient

folder in the

Project

window update with the imported audio files, as shown here:

Imported audio files showing in project folder

Select the

lake-shore-waves2.wav