How to Make Game Music for Beginners
Learn how to make your own game music even if you’re a complete beginner, using the Korg Gadget app for iPad! By Tim Mitra.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
How to Make Game Music for Beginners
25 mins
- Getting Started
- Adding a Simple Drone
- Adding a Melody to your Song
- Adding Another Low Drone
- Stripping Down Your Song
- Changing the Bar Count of a Scene
- Breaking Down Your Song
- Exporting to an Audio File
- Trimming Your Song in QuickTime Player
- Adding Your Song to a Sprite Kit App
- Where To Go From Here?
Breaking Down Your Song
Duplicate Scene 5 twice using the same steps as before. If things are getting a little tight and you need more space on the screen, tap the Expand icon to hide the instrument mixer:
Use Function to clear the drone on Track 4 in Scenes 6 and 7. Clear the melody track in Scene 7 as well. Try to see if you can figure it out yourself without looking at the spoiler below!
[spoiler title=”Solution”]Press Function to open the edit overlay. Then press Clear on Track 4 in Scene 6 and 7. Finally, press Clear on Track 3 of Scene 7.[/spoiler]
Duplicate Scene 7 to create Scene 8. Delete everything from Scene 8 except for the drum track. While you’re at it, modify Scene 6 and 7 to be four bars in length. Your finished piece should look like the following screenshot:
Play your finished masterpiece all the way through; it sounds like you’re done!
Now that you have a great-sounding track, all you need to do is export it to an audio file and include it in your app.
Exporting to an Audio File
To export your song to file, press the Document icon and tap Export. You can export your song to GadgetCloud which is hosted on SoundCloud. Alternately, you can export your song as an Audio File using iTunes export, DropBox or AudioCopy, which lets you paste your composition into a compatible app.
Export the file to the destination of your choice. Now that you have a physical file you can work with, you can clean it up a little before using it in your game.
Trimming Your Song in QuickTime Player
You’ll likely need to trim your audio file a little as the export process adds a few seconds of dead air to the end of the file — this won’t sound very good when it loops!
Fortunately, it’s easy to trim your song in QuickTime player.
Open the file in QuickTime Player and set it to Loop under the View menu. Then select Trim from the Edit menu and adjust the length of your song. Listen carefully as the song loops; try to trim your song so that there isn’t a break or a choppy transition when the song loops.
Once you’re satisfied, you can Export the trimmed file. Choose Export from the File menu, then select Audio Only as the Format and save it as an m4a file.
If you’d like to see how I trimmed my file, you can check it out here: RW Game Track
All that’s left is to add the song to your app!
Adding Your Song to a Sprite Kit App
Download the completed SpriteKit Space Invaders app; if you’d like some background on the app you can read about it in this tutorial by Joel Shapiro.
Open GameScene.m in Xcode and add the following import to the top of the file:
@import AVFoundation;
Next add a private instance variable to store the music player as shown below:
@interface GameScene () {
AVAudioPlayer *_backgroundMusicPlayer;
}
Add the following helper method to play the background music:
- (void)playBackgroundMusic:(NSString *)filename{
NSError *error;
NSURL *backgroundMusicURL = [[NSBundle mainBundle] URLForResource:filename withExtension:nil];
_backgroundMusicPlayer = [[AVAudioPlayer alloc]
initWithContentsOfURL:backgroundMusicURL error:&error];
_backgroundMusicPlayer.numberOfLoops = -1;
[_backgroundMusicPlayer prepareToPlay];
[_backgroundMusicPlayer play];
}
Finally, add the following to createContent
in GameScene.m, immediately after the call to setupHud (change the filename to whatever you called yours):
[self playBackgroundMusic:@"RW Game Track.m4a"];
Note: In an app built with a standard Sprite Kit template, you could call the method in initWithSize:
instead.
Note: In an app built with a standard Sprite Kit template, you could call the method in initWithSize:
instead.
Build and run the app; you’ll hear the music playing as you play the game. Satisfying, isn’t it? :]
Once the game is over, the music will stop playing as the Sprite Kit scene is replaced.
Where To Go From Here?
Here is the finished RW Game Track.gdproj. You can add it to your own Korg Gadget app with iTunes sharing.
To further refine your tune, you can tweak the notes in each scene to simplify or enhance your tracks. Experiment with adding notes and drones in different places. Try the Amsterdam gadget to add some interesting sounds and effects. Most of all, have fun and get creative!
If you have any questions or comments, or would like to share your creations with us, feel free to join the discussion below!