Hi guys
Does anyone know of a script available which will add a low pass filter effect to all audio sources outwith the view of the main camera? Ideally one which will gradually increase attenuation of high frequencies, peaking at 180 degrees from the camera view.
Hope that makes sense
Thanks
Not offhand, but it sounds like it’d be reasonably straightforward to create. The degrees-from-camera-view thing just needs a dot product for attenuation. The out-of-view thing is simple too. Both could operate on the AudioSource’s script or in a single loop through a list of all active sources in the scene. You could even base volume and the low-pass parameters on a raycast from the listener to the source - if it hits something, modify the variables thus and so because it’s behind a wall.
Thanks for your reply, do you know if its possible to add a script to the listener itself in order to do this?? Sorry if that is a daft question, I specialise in sound not code and am using playmaker to build a prototype.
Thanks
Well, all the necessary scripts could go on the listener object, yes. However, doing it that way requires that you maintain a list of all the active AudioSource objects in the scene which you want to affect, and make calculations / changes to every one of them each frame in a loop.
I would recommend creating a class that goes on all your AudioSource objects, rather than trying to do all of this on a monobehaviour or FSM on the listener. Even if you insist upon doing the angle/distance/physics calculations on the listener - by keeping a list of AudioSources and iterating through them each frame - you will still benefit from having a helper class on each AudioSource object.
Why? Because if you keep a list of the helper class objects (as opposed to a list of the AudioSource objects themselves) you can iterate over that list instead, and the helper class could keep references to and have convenience methods for tweaking the various effects on each AudioSource Game Object.
It’ll take some doing to set up, but it shouldn’t be too bad. Please share any more questions, 
Thanks very much for your help I will try to get this working today