| volume# - linear gain from 0 to 1; initially 1 |
|
Sets the master linear gain for every audio effects group. The gain is ramped over about 20 ms and affects every XAudio2 group and its tails. Gain precedes the optional master limiter and master meter. Windows volume and MIDI are separate. Call InitAudioEffects before the first WAV/Ogg playback. Configuration commands return 1 on success or 0 on failure; use AudioLastError for the reason. Finite numeric values and valid handles are required in Debug and Release. Queries preserve errors unless the query itself fails. Audio effects process decoded WAV and mono/stereo Ogg at an internal 48 kHz. MIDI uses a separate backend. Sound defaults are copied to independent playing channels. Runtime pause freezes sources, tails and transition time; pausing one channel leaves shared tails running. Event waits service transitions and release completed source resources without ChannelPlaying polling. Lightweight completed handles are retained until program shutdown. The interactive Audio Playground sample demonstrates the whole effects family together. See also: AudioGroupVolume, AudioMasterLimiter, AudioMasterMeter. |
; AudioMasterVolume Example
; -------------------------
; Effects must be initialized before the first WAV/Ogg playback
If Not InitAudioEffects() Then RuntimeError AudioLastError$()
Graphics 640,480,0,2
SetBuffer BackBuffer()
; A looping machine hum to hear the effect on
sound=LoadSound("../../../samples/audio/media/machine.wav")
If sound=0 Then RuntimeError "The audio sample media is missing."
LoopSound sound
SoundVolume sound,0.25
; Meters make the audio state visible on screen
RequireAudio AudioMasterMeter(True)
RequireAudio AudioGroupMeter(0,True)
volume#=1
channel=PlaySound(sound)
If channel=0 Then RuntimeError "Unable to play the example sound."
While Not KeyDown(1)
; [ / ] adjust the master gain over every group
If KeyDown(26) And volume>0 Then volume=volume-0.01
If KeyDown(27) And volume<1 Then volume=volume+0.01
RequireAudio AudioMasterVolume(volume)
Cls
Text 0,0,"[ / ] : master volume Esc: exit"
Text 0,20,"AudioMasterVolume "+volume
Text 0,40,"Gain precedes the optional master limiter and meter"
Text 0,80,"Group 0 peak: "+AudioGroupPeak(0)+" RMS: "+AudioGroupRMS(0)
Text 0,100,"Master peak: "+AudioMasterPeak()+" RMS: "+AudioMasterRMS()
Flip
Wend
; Let shared effect tails fade before the program ends
For group=0 To 3
RequireAudio AudioGroupClearEffects(group)
Next
StopChannel channel
FreeSound sound
End
; Stop with the recorded reason if an audio-effects call fails
Function RequireAudio(success)
If Not success Then RuntimeError AudioLastError$()
End Function