Welcome to Edge of Code’s series of Infinite Roller tutorials. If you’d prefer a video tutorial, you can find one here.
In the previous tutorial, we added scoring and recorded the player’s high score. Today, we’ll look at how to create sound effects using Audacity.
Audacity is free software that lets you record and edit sounds. If you don’t have it already, go to https://audacityteam.org/, download and install the program. You’ll obviously need a microphone to record the sound effects. If you don’t have one, or don’t want to record your own sound effects, you can get free ones online. I like http://www.freesfx.co.uk/ – the effects and music are free as long as you acknowledge them.
Open Audacity. The first thing to do is to set the recording information Audacity needs. Select the microphone you’re using from the Recording Device drop down menu, and your speakers from the Playback Device drop down menu.
Next, click on the Recording Level microphone and select Start Monitoring.
Say something or make a sound, and you should see the scale flickering green. The sound needs to be loud enough to be recorded properly, but not so loud that the output becomes distorted – the maximum the scale should reach is about -6. If your scale is too low or high, try adjusting the recording volume
at the top right. Or try moving the microphone closer or further away.
To record, click the red circular record button, and to stop, the yellow square. When you record, you’ll see waveforms like in the image below.
Any red in the waveform is clipping and means the volume was too high. If this happens, try reducing the recording volume more, or move the microphone away further.
Audacity lets you edit and manipulate your recording. You can cut the bits you don’t want and normalise the volume so that it’s as loud as it can be without clipping occurring. There are lots of other options, but these are the ones we’ll use.
We’re going to record the sound of the Infinite Roller character landing on the ground. I’ve collected a few different things to try out – a tennis ball, a beany toy giraffe and a pen – and a few surfaces to drop on – my desk, a mouse mat, and a notepad. First test each thing on each surface until you’ve found a sound you’re happy with. I’m going with the giraffe on the mouse mat.
Now make sure Start Monitoring is selected in Audacity and drop your chosen item near the microphone. Check the maximum level – you might want to change the recording volume again. Mine is about right.
Press record, drop your chosen item again, then press stop. Save the file to make sure you have a copy of the unedited version until you are happy with your edits.
Click on the zoom icon, then click on the waveform to expand it horizontally.
Click on the selection tool icon, then click on the waveform just before the sound happens (when the height of the waveform suddenly gets larger). Press Shift+J to highlight the region from the cursor to the start (Or go to the edit menu -> Select -> Track Start to Cursor). Now press delete to remove the unnecessary audio.
Next remove the extra audio at the end of the file. This time, press play, then stop (don’t pause) when the sound you wanted has played. This can take a couple of goes. To move the cursor to the beginning of the sound, press the Home key. Once you’re happy with the position, press Shift+K to highlight the region from the cursor to the end (Or go to the edit menu -> Select -> Cursor to Track End) and press delete. You now have an edited landing sound. If you are happy with it, save the file. If pressing home or other keys doesn’t work, you might have pressed pause rather than stop.
Next, we’ll normalise the volume. Go to Effect -> Normalise. Press OK on the pop up.
The volume of the recording is now as loud as possible. Save the file, then go to File -> Export Audio. I’m going to export it as an ogg file. Unity can use this type of file. If you do want to export it as an mp3, you’ll need to download LAME and follow the instructions here first.
Open the Infinite Roller project in Unity and create an Audio folder in the project window. Drag the ogg file into it.
Next we’ll find some online background music for our game. You could create it yourself if you want, and I recommend using LMMS, open source music creation software. Go to the freesfx site and create an account. Once you’ve set that up, click on the Music tab. Pick a category and then your background music. I’m going with Action and “Psyche Up” which is made by Craig Riley, because it reminds me of 80’s TV like MacGyver, and I think it’ll go with the game. Click on the profile of the person who made it – there’s often some information at the top requesting credit for their work. Download the music, then drag it into your Audio folder in Unity.
Save the project.
Today, we’ve created a sound effect for our game, downloaded background music, and imported them into Unity. In the next tutorial, we’ll discuss audio in Unity and add it to the game.
Remember you can download the files for this tutorial on the Downloads page. See you next time!