Hi.
So I’ve seen in the aud documentation that there are a wide range of things to use with audio. One thing I’d want to use is the low pass filter. Now I’m not sure how to apply that filter with Python, but I assume it wouldn’t be a large script to do.
You’re right, it’s pretty easy to apply a lowpass filter to a sound using aud. You basically load a sound file into memory, apply the filters then play it. Unfortunatelly, you can’t change the filter in realtime, only before playing the sound, but it’s still possible. Example script and working example file provided below.
For other pre-precessing effects, see the reference from the aud.Factory. For realtime attributes, see aud.Handle.
import bge
import aud
from bge.logic import expandPath
def main(cont):
# Objects
own = cont.owner
# Sensors
sensor = cont.sensors[0]
### INIT PROCESSING ###
if sensor.positive:
# Sound file expanded path
path = expandPath("//whitenoise.ogg")
# Creates an audio factory in memory, then applies
# lowpass / hipass based on own properties
factory = aud.Factory(path) \
.lowpass(own['lowpass']) \
.highpass(own['hipass'])
# Plays the resulting factory
aud.device().play(factory)
Nice, thanks for this clean example. I would like to leave here, that the use of the expression controller is also a nice way of limiting the parameter ranges.