Here’s a simple delay effect using a sound actuator as sound source and playing the file with AUD in python.
Property “count” for number of plays
Property “delay” for time between plays
Hit Space to test.
AUD_delay_effect.blend (706.7 KB)
import bge
import aud
cont = bge.logic.getCurrentController()
own = cont.owner
act = cont.actuators["Sound"]
SPACE = cont.sensors["Space"]
device = aud.Device()
if 'original_sound' not in own:
own['original_sound']=act.sound
factory=own['original_sound']
if SPACE.positive:
for i in range(own['count']):
handle = device.play(factory)
handle.volume=(1-(i/own['count']))**3
factory = factory.delay(own['delay'])
factory = factory.fadein(i*0.1,0.9)
factory = factory.lowpass(8000,0.9)