sound_volume

Sets the volume of a given sound.

Syntax:

sound_volume(index, value);


Argument Description
index The index of the sound to change the volume of.
value The new volume from 0 to 1.


Returns: N/A


Description

With this function you can change the volume of the given sound. This will change the volume for all further instances where the indexed sound is played and the volume can be set to a value between 0 (silent) and 1 (full volume), with a value of 1 being the default volume for the sound unless it has been previously changed in the sound resource. The volume scale is logarithmic in nature, so a volume of 0.5 is not half volume, as illustrated by the image below:




Example:

if keyboard_check_pressed(vk_add)
   {
   if vol < 1 vol += 0.1;
   sound_volume(global.Music, vol);
   }

The above code checks for a key press and when it detects one it raises the volume (to a maximum of 1) of the sound indexed in the global variable "Music".


Back: Legacy Sound
Next: sound_fade
© Copyright YoYo Games Ltd. 2015 All Rights Reserved