Runtime Revolution
 
Articles Other News

Add Snap to your Games with Audio

by Malte Brill

 

I am happy that Runtime Revolution and Mojo Audio teamed up to introduce Audio packs into RevSelect.

After listening to the audio demos in the store, I instantly went to purchase a few of the audio packs, as I see they really can improve my work. If you buy the mojo packs, you get high quality samples that you can use as they are.

If you like to work with them to tweak them a bit you might want to use an audio editor and play with the pitch or time stretching functions in that editor to modify the audio files. A good choice is the free Audacity editor, which is quite powerful. However that editor can have problems on a Mac. Some versions of Audacity set the sampling rate for audio playback to a very high value, which will result in loss of the ability to playback audio in a couple of applications including Revolution. So if you work with Audacity and suddenly Revolution and other applications go silent, make sure to reset it in your system settings.

Getting back to writing applications using audio in Revolution. Audio is a useful way to give feedback to the user. Using sound is a nice way to guide a user through your interface and give feedback to user interaction. As you may know my company creates games. The latest game we built is ZACK!

 

ZACK! is based on the concept of placing tiles to build bridges, and each tile must match the color of adjacent pieces. Four basic colors to tiles in the beginning make building bridges simple, but as players progress the game adds two more colors alongside 60 "combo" colors. Once a complete row or column is filled, it is removed from the grid. Occasional joker tiles work next to any color, helping players get out of tough situations.

ZACK! makes heavy use of animation engine, so most of the development time could be put into the game logic. Using the Mojo sounds in the game added a whole new layer to the user experience. Just writing code is not all that makes a game fun to play where audio is a crucial factor in game experience. Basically it comes down to four things:

  1. Game Idea
    Your game idea is vitally important. You can easily find out if your game is fun to play, if you give prototypes to friends and family. Watch them play and you'll quickly see what works and what doesn't.
  2. Graphics
    You will need to make your game look good. If you manage to add nice animations even better. It's easy to dismiss graphics as "eye-candy" but good graphics make the difference between a mediocre game, and one that sells.
  3. Audio
    The audio components of your game can really make a difference. Given the same visual experience, you can drastically change the mood of what your user sees by changing the aural media you are using. The same sequence can either look funny, neutral or menacing, depending on the soundtrack you use.
  4. Code
    (Finally) the code you write. You will need to make sure your game runs flawlessly on a wide range of machines. This requires a lot of testing and it is a good idea to test your work on machines that are *not* the most recent machines you can get. It is a good idea to have your game tested on machines that are older than 3 years.

So you sit there, with your idea for an addictive game, you've already coded the first prototype and it is looking good. You may even have the graphics integrated already and are ready to add sound. How would you do that in Revolution? Basically you have two options: audioclips or Players. Both have advantages and disadvantages.

You need to understand how Revolution handles multichannel audio. You are able to use multiple player objects, but this requires you to rely on the presence of QuickTime. If you target Windows versions of your game you need to make sure that QuickTime is present on the host machine. The property you will need to check here is

the QTVersion

If the QTVersion = 0.0 on a windows machine, you are out of luck and will need to prompt the user to install QuickTime, or be limited to a single player object playing at a time.

I rarely use players in my games. Mostly I use them only if I want to play long atmospheric sounds or background music. If I want to play sound effects, which normally are short samples of less than a second up to 2 seconds length, I import the audiofiles I want to use as an audioclip and use the command

play audioclip "myclip.wav"

Audioclips do not rely on the presence of QuickTime, however, Revolution can only play one audioclip at a time. Also, you cannot import just any audioformat as an Audioclip into Revolution. The safest formats to use are uncompressed .aif or .wav files.

An important thing when you work with audio in a game is not to annoy the user. If you play the same audioclip over and over again you might bore your users to death. React on your gameplay. Use audioclips to give feedback, when the user interaction is not allowed by the game. Use audioclips to reward players. Most important: Give your users the option to turn audio off! A quick method to do this is to set a custom property of the stack. You could have a button in your user interface that enables or disables audio playback for the game. Lets look at the audio button in ZACK!

on mouseUp
  set the uDontPlayAudio of this stack to not the uDontPlayAudio of this stack
  writePreferences
end mouseUp

Using this script the customproperty uDontPlayAudio alternates between the boolean values true and false, when the button has been clicked. Afterwards the current state is stored in the preference file using the writePreference handler.

You can now simply check if the property is true or false and decide if you need to play the audioClip, start your Player object or not.

if not the uDontPlayAudio of this stack then
  -- need to play audio
  play audioclip "myClip.wav"
end if

Runtime Revolution are currently offering a special deal on getting Mojo audio packs with Animation Engine. You can get 2 audio packs plus Animation Engine at a discount, plus a free copy of ZACK! if you buy before the end of the month

Have fun!

Find out more about Mojo Audio
Find out more about Animation Engine

 
©2005 Runtime Revolution Ltd, 15-19 York Place, Edinburgh, Scotland, UK, EH1 3EB.
Questions? Email info@runrev.com for answers.