Co-existing with movie players - Firelight Technologies Pty, Ltd.

# FMOD AND MOVIE PLAYERS

Introduction

This section describes how to have FMOD happily coexist with various movie playback systems available.

PlayStation 2

The main causes on conflicts between other middleware that uses audio or the IOP, and FMOD are:
- Conflict between the SPU2 DMA channels. There are 2 of these. DMA channel 0 and DMA channel 1. By default FMOD uses SPU2 DMA channel 0 for software mixing, and DMA core 1 for uploading sample data and for streaming to. This means DMA core 1 is used when FMUSIC_LoadSong / FMUSIC_LoadSongEx is being executed to load a PS2 FSB file, or streaming using FSOUND_Stream_Open / FSOUND_Stream_Play. To work around this issue see the following tips.
  - Turn off the FMOD software mixer. This will free up DMA Channel 0. Most of the time you are not going to need this. You can do this by using FSOUND_Init with software channels set to 0.
  - Swap FMOD's mixer/upload channel usage around. If the 3rd party software still uses DMA Channel 1 (the channel FMOD uses for bank uploads and streaming), you can either change your 3rd party software to use DMA Channel 0 instead of DMA Channel 1, or tell FMOD to swap its usage around by specifying FMOD_INIT_PS2_SWAPDMACORES. If you didn't turn the software mixer off, this would make FMOD use DMA Channel 0 for streams and sample bank uploads, and DMA Channel 1 for the software mixer.
- Conflict on the SIFCMD ports. If your middleware or your own code is using the SIFCMD sony library to communicate with the IOP, then if you dont take care to share the SIFCMD buffers and ports with FMOD, messages will get lost and unexpected behaviour will occur in FMOD and your 3rd party software.
  - If you want to initialize your 3rd party software after FMOD. Use this information if the code has a way to set up its SIFCMD usage. Note that FMOD uses SIFCMD port 0 and 1, and has a buffer size of 16.
  - If you want to initialize your 3rd party software before FMOD. If FMOD is initialized first, call FSOUND_SetSifCommandInfo from fmodps2.h. Also load your FMOD.IRX or FMODSMALL.IRX with command line parameters to allow the IOP side to get the same information. For more detailed information on this see the comment above the function prototype in fmodps2.h.
- SPU2 ram usage and SPU2 hardware voice usage. Because FMOD and the middleware might not know about each other, they might allocate memory or use SPU2 voices without any regard for the other.
  - Use FSOUND_SPU2_Alloc / FSOUND_SPU2_GetRawAddress / FSOUND_SPU2_Free. Use these functions to allocate SPU2 memory for your 3rd party application. This way it will use FMOD's memory manager.
  - Use FSOUND_SetReserved. If the 3rd party software uses SPU2 voices, you can mark the literal SPU2 voice index as not to be used within FMOD. If the 3rd party software used SPU2 voice 0 for example FMOD would use FSOUND_SetReserved(number_of_software_channels + 0, TRUE); Note that the software channels value is mentioned because raw channel indicies are 0 to (maxnumsoftwarechannels - 1) = software voices, and after this are hardware voices. If you have the software mixer turned off, then 0 would be SPU2 voice 0 and 47 would be SPU2 voice 47.

XBOX

The main causes on conflicts between other middleware that uses audio on the XBox, and FMOD are:
- "DSOUND: CMcpxAPU::AllocateVoices: Error: Not enough free hardware voices". By default FMOD assumes it is in total control of the audio, so it allocates every XBox audio voice. If another 3rd party software application tries to allocate a hardware voice it will fail.
  - Use FSOUND_SetMaxHardwareChannels. To get around this issue just call FSOUND_SetMaxHardwareChannels to reduce the count. XBox has around 192 HW2D voices so you could reduce this and still have plenty of voices free.
- DSP Image incorrect. FMOD has an internal MCP DSP image that it loads. It is stripped down to save memory, (hundreds of kilobytes) by removing unnescessary features. This may conflict with other 3rd party software that relies on a standard DSP image such as Microsoft's dsstdfx.bin.
  - Use FSOUND_SpecifyEffectsImage. If the 3rd party middleware has a dsp image file that it relies on you can use FSOUND_SpecifyEffectsImage (found in fmodxbox.h) to make FMOD use that image.
  - Make the other software use FMOD's image. You can get a handle to FMOD's internal dsp image structure by calling FSOUND_GetEffectImageDesc (found in fmodxbox.h) if the 3rd party has such a facility to allow this sort of external image to be used.
- Needs access to the XBox LPDIRECTSOUND handle. If the 3rd party software is initialized second, it may want to use the XBox LPDIRECTSOUND handle.
  - Use FSOUND_GetOutputHandle. If you need to get a handle to FMOD's internal DirectSound pointer, you can share it by calling FSOUND_GetOutputHandle and casting it to the appropriate pointer type.

Win32

If you need to get a handle to FMOD's internal DirectSound pointer, you can share it by calling FSOUND_GetOutputHandle and casting it to the appropriate pointer type.
This also goes for XBox and other platforms, and depends on th

Bink on PS2

Here is a quick way to get FMOD PS2 and Bink to co-exist.
Initialize FMOD first.
FSOUND_Init(48000, 0, FSOUND_INIT_PS2_SWAPDMACORES);
FSOUND_SetReserved(0,TRUE);
Initialize Bink
MovieBuffer = sceSifAllocIopHeap( RAD_IOPMemoryAmount( RAD_IOP_NEED_CORE1 ) );
RAD_IOPMemoryAmount(RAD_IOP_NEED_CORE1) ));
if ( !RAD_IOPStartUp( 1, 2, MovieBuffer, RAD_IOP_NEED_CORE1|RAD_IOP_NO_INIT_LIBSD ) )
{

sceSifFreeIopHeap(MovieBuffer);
// error

}
RAD_IOPHardwareVolumes(1, 0x3fff, 0x3fff, 0x3fff, 0x3fff);
BinkSoundUseRAD_IOP(1);