SoundVolume()

Syntax

SoundVolume(#Sound, Volume.f [, Channel])
Description
Change the sound volume, in real-time.

Parameters

#Sound The sound to use. If #PB_All is specified, all the sounds (and all channels) are affected.
Volume.f The new volume for the sound. Valid values are from 0 (no volume) to 100 (full volume).
Channel (optional) The channel to use. It's the value returned by PlaySound() when using the #PB_Sound_MultiChannel flag. If #PB_All is specified, all the channels of the sound are affected.

Return value

None.

Example

  If InitSound()           ; Initialize Sound system
    UseOGGSoundDecoder()   ; Use ogg files
    
    ; Loads a sound from a file
    If LoadSound(0, #PB_Compiler_Home +"Examples/3D/Data/Siren.ogg")
      ; The sound is playing
      PlaySound(0, #PB_Sound_Loop, 20)
      
      MessageRequester("Info", "The sound volume is at 20%")
      
      SoundVolume(0, 80)
      MessageRequester("Info", "The sound volume is at 80%")
      
      FreeSound(0) ; The sound is freed
      End
    EndIf
  Else
    Debug "Warning! The sound environment couldn't be initialized. So no sound commands can be used..."
  EndIf

See Also

LoadSound()

Supported OS

All

<- SoundStatus() - Sound Index - StopSound() ->