2.3 Playing Sound Effects with Attached Parameters

In the previous section we explained how to change the audio playback parameters using sound handles. However, with sound effects, often the parameters are frequently changed. In these cases, the parameters can be set simultaneously at the time of playback.

By using the MusStartEffect2 function, the volume and pan can be set ahead of time. Moreover, if a sound effect with the same number is currently being played back, a flag can be set to cancel (overwrite and playback) that sound effect, and the priority can be changed.


Start sound effect with parameters attached
Function name: MusStartEffect2
Syntax: musHandle MusStartEffect2(s32 number, s32 volume, s32 pan,
s32 restartflag,s32 priority)
Arguments: number Start sound effect number
  volume Volume ((0 to 0x100)
  pan Pan (0 to 0x100)
  restartflag Overwrite flag
  0  Do not overwrite
  non-zero  Overwrite
  priority The priority (-1 implies no change in priority)
Return value: Sound handle value


Setting the volume and pan like this provides an easy way of simulating 3D sound effects.

The priority argument specifies the priority of a sound effect. When there are not enough channels, this value is used to decide whether or not to end another sound effect and begin playback of this one. The higher the value the higher the priority. The priority is set with the tools. If nothing needs to be changed, set this argument to -1. MusStartEffect(number) is the same as MusStartEffect2(number, 0x80, 0x80, 0, -1).