N64® Functions Menu

al - Audio Library Functions
gDP - DP GBI Macros
gdSP - General GBI Macros
gSP - SP GBI Macros
gt - Turbo Microcode RDP
gu - Graphics Utilities
Math - Math Functions
Mus - Mus Library
nuSys - NuSystem
os - N64 Operating System
sp - Sprite Library Functions
uh - Host to Target IO
64DD - N64 Disk Drive

Nintendo® Confidential




Mus Library Reference


MusHandleSetVolume()

Set the volume scale value using a sound handle.

Syntax

  int MusHandleSetVolume(musHandle handle, int volume);

Arguments

  • handle is the sound handle

  • volume is the volume scale

Explanation
Set the volume scale value for the channels associated with the specified sound handle. This function allows the programmer to change the volume of songs and sound effects relevant to the values originally defined within the sound data.

The handle must be a sound handle returned by MusStartSong(), MusStartEffect() or MusStartEffect2(). If an handle of zero is supplied, this function will always return zero.

The volume value should be within the range of 0 to 0x100 (256), with this range representing 0% to 200% of the value defined in the original sound data. The default volume scale value for all channels is 0x80 (100%).

Return Value
Number of channels which have been changed.

Example

  unsigned long SongCrossFade(unsigned long handle, int *song)
  {
    int I;
    unsigned long new_handle;

    new_handle = MusStartSong(song);
    MusHandleSetVolume(song, 0);
    for (I=0x10; I<0x80; I+=0x10)
    {
      WaitForVsync();
      MusHandleSetVolume(handle, 0x80-i);
      MusHandleSetVolume(new_handle, I);
    }
    MusHandleStop(handle,0);
    return (new_handle);
  }

  void VolFromDistance(unsigned long handle, float distance)
  {
    int scale;
    int volume;

    /* calculate distance scale */
    if (distance>=MAX_DISTANCE)
      return (0); /* sound is too far away! */
    distance = (MAX_DISTANCE-distance)*(65536.0/MAX_DISTANCE);
    scale = (int)distance;

    /* calculate volume level */
    volume = (0x80*scale)>>16;

    MusHandleSetVolume(handle, volume);
  }

See Also
MusHandleSetPan()
MusStartSong()
MusStartEffect()
MusStartEffect2()


Nintendo® Confidential

Warning: all information in this document is confidential and covered by a non-disclosure agreement. You are responsible for keeping this information confidential and protected. Nintendo will vigorously enforce this responsibility.


Copyright © 1998-1999
Nintendo of America Inc. All rights reserved
Nintendo and N64 are registered trademarks of Nintendo
Last updated March 1999