; AudioReverb Example ; ------------------- ; Requires Extended mode. ; 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) ; The listener environment; a send is needed to hear it preset$="cave" RequireAudio AudioReverb(preset) RequireAudio SoundReverb(sound,0.6) channel=PlaySound(sound) If channel=0 Then RuntimeError "Unable to play the example sound." While Not KeyDown(1) ; 1-5 choose an environment preset (transitions crossfade over 250 ms) If KeyHit(2) Then preset="off" If KeyHit(3) Then preset="room" If KeyHit(4) Then preset="cave" If KeyHit(5) Then preset="arena" If KeyHit(6) Then preset="underwater" RequireAudio AudioReverb(preset) Cls Text 0,0,"1: off 2: room 3: cave 4: arena 5: underwater Esc: exit" Text 0,20,"AudioReverb "+Chr(34)+preset+Chr(34)+",250" Text 0,40,"Selecting a preset alone adds no reverb - this sound sends 0.6" 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