XBox - Firelight Technologies Pty, Ltd.

# XBOX SPECIFIC ISSUES / FEATURES

Introduction

This section describes how to get started with FMOD for XBox, and also some of the XBox specific features available.

Getting Started

This section describes what you will need to link, and what you need to call to get up and running for XBox specifically.
FMOD comes with 2 libraries. One is release and one is debug. The main difference is that the debug version outputs debug information to the debug window of your debugger.
This is useful for tracing what fmod is doing if something ever went wrong and you wanted to know where FMOD was at the time.
- /api/lib/fmodxbox.lib - This is the library you will link to most of the time. Use this for shipping.
- /api/lib/fmodxboxD.lib - This is debug version of FMOD. It is slower, and prints out a log of FMOD progress through the debug window, along with english explanations on errors if they occur.

Memory Management

On FMOD XBox, you must call FSOUND_SetMemorySystem, and supply a pool of memory with a length.
for example.
#define AUDIO_MEMLENGTH (4*1024*1024)
char *mem = malloc(AUDIO_MEMLENGTH);
FSOUND_SetMemorySystem(mem, AUDIO_MEMLENGTH, NULL, NULL, NULL);
then,
FSOUND_Init(....);
etc.
The reasoning for this is for performance issues.
FMOD must be able to access sample data within its own memory block to avoid a slowdown issue in DirectSound XBox.
The memory provided must be enough to store all samples and extra system memory overhead for FMOD.
You can call FSOUND_GetMemoryStats to determine what FMOD needs as a game runs.
You could run FMOD and supply it with an unrealistically high memory pool (say 8 megabytes), and then call FSOUND_GetMemoryStats to determine the maximum amount of RAM fmod needs to store sounds and for FMOD system overhead.
8mb Memory Limitation.
Currently for hardware sound effects, there is an 8mb limit for sound effects.
This is due to the XBox DirectSound architecture.
From the XDK Documentation : "DirectSound buffers are managed in a scatter gather entry (SGE) list.
There is a maximum of 2,047 SGEs, which each point to a 4-KB page.
This means that a maximum of 8 MB are available for allocating or playing DirectSound buffers simultaneously"
Future versions may have multiple 8mb pools if it is required by developers.

Special features for FMOD XBox

FMOD is fully functional on the XBox, including wma, mp3 and ogg vorbis streaming support, and with some extra functionality to take advantage of the 5.1 Dolby Digital surround sound support.
FSOUND_SetLevels. (See fmodxbox.h).
This function allows you put position a sound in any of the 5.1 speaker array in dolby digital. This can be very useful, and you can even do cool things like 5.1 music with it. For example, use FSBank to produce a 6 channel, multichannel interleaved stream, then use FSOUND_GetSubChannel to position all 5 channels into their own speaker.
ie
channel = FSOUND_Stream_PlayEx(FSOUND_FREE, stream, 0, TRUE);
FSOUND_SetLevels(FSOUND_GetSubChannel(channel, 0), 255, 0, 0, 0, 0, 0);
FSOUND_SetLevels(FSOUND_GetSubChannel(channel, 1), 0, 255, 0, 0, 0, 0);
FSOUND_SetLevels(FSOUND_GetSubChannel(channel, 2), 0, 0, 255, 0, 0, 0);
FSOUND_SetLevels(FSOUND_GetSubChannel(channel, 3), 0, 0, 0, 255, 0, 0);
FSOUND_SetLevels(FSOUND_GetSubChannel(channel, 4), 0, 0, 0, 0, 255, 0);
FSOUND_SetLevels(FSOUND_GetSubChannel(channel, 5), 0, 0, 0, 0, 0, 255);
FSOUND_SetPaused(channel, FALSE);
A musician would have to product 6 wav files for each speaker in this case before it is interleaved with FSBank into one stream.
Even if you dont go to this extent, you can do something simple like spatialize normal stereo music. Normally music is just played through the front 2 channels, so you can improve this with something like
FSOUND_SetLevels(musicchannel, 255, 255, 255, 128, 128, 255);
which puts it in all speakers and half volume in the rears.