#include <cafe/sp.h>

void SPPrepareEnd(SPSoundEntry *sound, AXVPB *axvpb);


sound Pointer to an entry in an SP sound table.
axvpb Pointer to an AX voice parameter block.

Return Values



The SPPrepareEnd function marks a looped voice for termination.

The voice is specified by:

This function is useful for terminating a looped sound effect that is already playing. The function clears the voice’s loop flag and resets the sound effect’s end address (if necessary). The sound effect will play to the end and then stop.

This function has no effect on non-looped sound effects.

This function must only be called after a looped sound effect has been started. That is, calling the function immediately after invoking SPPrepareSound (within the same audio frame) will not work because the synchronization bits used for SPPrepareEnd have precedence over those asserted by SPPrepareSound. The initialization performed by SPPrepareSound will be lost and the sound will play incorrectly.

If you want to play a looped sound only once, clear the voice's loop flag and reset its end address manually, after calling SPPrepareSound. For example:

static void foo(SPSoundEntry *sound, AXVPB *axvpb, BOOL one_shot);
   SPPrepareSound(sound, axvpb, sound->sampleRate);
   if (TRUE == one_shot)
      // This is a looped sound, but we want to play it as a one-shot.
      // So we must revise the loop flag and end address. 
      axvpb->pb.addr.loopFlag      = AXPBADDR_LOOP_OFF;
      axvpb->pb.addr.endAddressHi  = (u16)(sound->endAddr >> 16);
      axvpb->pb.addr.endAddressLo  = (u16)(sound->endAddr & 0xFFFF);
} // end foo()
We do not have to assert synchronization bits for the revised loopFlag and endAddressHi/Lo parameters, because the preparatory SPPrepareSound function already does so.

Do Not Call From


Revision History

2013/05/08 Automated cleanup pass.
2011/02/21 Initial version.