Corona makes it easier than anything to get sound into a project. The documentation says:
- All platforms support 16-bit uncompressed .wav files.
- iOS and Mac Simulator support .mp3, .caf, and .aac.
- Windows Simulator supports .mp3 along with .wav.
- As of build 269, Android now supports .mp3 and .ogg formats.
So it looks like you can use wav, mp3, caf and aac on IOS. Since I’m focusing on the IOS platform I’ll stick with one of these formats. You can use garage band to generate AAC and MP3 files.
To get a sound to play you need to load the file creating a reference to the audio object in the process. Then tell that audio object to play.
Try it for yourself. Create a new Corona project, follow these steps:
- Create a folder to store your project.
- Create a new text file and save it into your folder with the name main.lua.
- Find a suitable sound file and copy it to the folder.
Add the following Lua code to your main.lua file. The file I for the example was named beep.mp3. Be sure to replace this name with the name of your sound file.
local mySound = audio.loadSound( "beep.mp3" ) audio.play( mySound )
Pretty simple huh? The first line loads your sound. The next line tells the sound to play.
- cfxr – A sound tool for the Mac