Miles Sound System SDK 7.2a

RAD_IOPSetSPUVoiceLoopAddress

The function RAD_IOPSetSPUVoiceLoopAddress sets the address to loop back to for one or more SPU voices.

S32 RAD_IOPSetSPUVoiceLoopAddress(
  U32 core0_voice_mask,
  U32 core1_voice_mask,
  U32 loop_address
);

In Parameters

core0_voice_mask
Specifies the bit mask of the voices on core 0 to set.
core1_voice_mask
Specifies the bit mask of the voices on core 1 to set.
loop_address
Specifies the loop address in SPU RAM to loop back to.

Returns

Returns non-zero on success, or zero on failure.

Discussion

This function tells the SPU where to jump to when the end of playback is hit.

Unlike most sound systems, you tell the SPU to loop or not to loop in the source files. That is, inside VAGEdit, you choose whether the sound is going to be looped or not. If the sound is looped, then you can use this function to change where in SPU RAM to jump to when you hit the end of a buffer.

Since it's nice to be able to choose looping or non-looping at run-time, there is a clever trick you can use. When you create your VAG files, always make them in looping mode. Now when you do this, all of your sound samples will loop forever. However, the trick is to set the loop address back to a special SPU address that contains silence data! So, the sound plays once, and then jumps back to the SPU silence address and then just plays silence from then on.

So, this way, you can choose to loop or not loop the sound based on whether you set the loop address to the SPU silence address. You can see the MilesPS2.c example program for an example of this technique - it is much simpler than it sounds. RAD_IOP defines the constant SPU_SILENCE_ADDRESS to refer to the SPU silence address.


Group: The RAD_IOP SPU Hardware Voice API for the Sony PS2
Related Functions: RAD_IOPSetSPUVoiceStartAddress
Related Basic Types: S32, U32

For technical support, e-mail Miles3@radgametools.com
© Copyright 1991-2007 RAD Game Tools, Inc. All Rights Reserved.