Chapter 7. Adding Sound and Video

Your game may look stunning, but if it's silent your audience will probably find it a dull experience. Fortunately, Marmalade allows us to remedy this with its support for sound and video playback. In this chapter we will learn about the following:

  • Playing back audio files recorded in formats such as MP3
  • Adding multiple simultaneous sound effects using sound samples
  • Playing back full-motion video clips

Multimedia support in Marmalade

Modern mobile phones and tablet devices are now capable of playing back good quality music and video, so it makes sense that Marmalade should provide ways in which we can harness these abilities.

Marmalade provides three different API layers that apply to multimedia support. These are s3eSound, s3eAudio, and s3eVideo. Unsurprisingly, the latter relates to the playback of video files, but you may be wondering why there are two APIs provided relating to sound.

The difference between s3eSound and s3eAudio is that the former is generally used for sound effects while the latter is normally used for music. The s3eSound API allows us to play several different sound effects at the same time, but by default only provides support for 16-bit mono-PCM sound samples. The s3eAudio API on the other hand allows us to play compressed formats such as MP3, but we are limited (on most devices) to playing a single audio track.

The good news is that most modern devices lets us have the best of both worlds by allowing both s3eSound and s3eAudio to be used at the same time.

In the following sections we'll look at how to make use of all three of these APIs and will also take a look at another module called SoundEngine, that makes using the s3eSound API a bit easier.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.200.109