2.2 Changing Parameters During Playback

In this section we introduce functions that can be used to change some song and sound effect parameters. The functions explained here can be used with sound handle units.

Use MusHandleSetVolume to change the volume. The default volume is 0x80 so you can double the volume by specifying 0x100 and halve the volume by specifying 0x40. Note that if the volume was fairly loud from the beginning, the sound may not end up being any louder than the original.


Set volume using sound handle
Function name: MusHandleSetVolume
Syntax: s32 MusHandleSetVolume(musHandle handle, s32 volume)
Arguments: handleSound handle
  volumeVolume scale (0 to 0x100)
Return value: The number of channels that have been changed


Use MusHandleSetTempo to change the tempo. The default tempo is 0x80. Like with the volume, you can double the speed of playback by specifying 0x100, and halve it by specifying 0x40.


Set the tempo value using sound handle
Function name: MusHandleSetTempo
Syntax: s32 MusHandleSetTempo(musHandle handle, s32 tempo)
Arguments: handle Sound handle
  tempo Tempo offset value (0 to 0x100)
Return value: The number of channels that have been changed.


Use MusHandleSetPan to change the pan. A central pan is 0x80, while the left end is 0 and the right end is 0x100. By using this function you can move the audio completely to the left or the right.


Set the pan value using sound handle
Function name: MusHandleSetPan
Syntax: s32 MusHandleSetPan(musHandle handle, s32 pan)
Arguments: handle Sound handle
  pan Stereo pan scale (0 to 0x100)
Return value: The number of channels that have been changed.


In addition to these functions, you can use MusHandleSetFreqOffset to vary the pitch (frequency). The breadth of variation is specified in an argument in units of semitones. The limit is determined by the pitch of the original sample. This function is mainly used with sound effects when repeating the same sample to avoid redundancy.


Set offset value of frequency using sound handle
Function name: MusHandleSetFreqOffset
Syntax: s32 MusHandleSetFreqOffset(musHandle handle, f32 offset)
Arguments: handle Sound handle
  offset Frequency offset value
Return value: The number of channels that have been changed.