Parented mono-source fading restriction removed.

Phobius

23-03-2009 22:59:13

I have just removed a restriction that prohibited fading from being applied on mono sources attached to scene-nodes. I believe the reason Casey (the creator of the library) originally disallowed this is because, due to the nature of mono sources in the 3D world, the maximum gain may not be reached even after a full fade-in. Say you have a source that's 100 units away, and the source has it's min-gain set to 0.0 and max-gain set to 1.0. If the max-distance/ref-distance/rolloff/attenuation-algorithm calculate your gain as 0.5 at 100 units, the actual fade will be from 0.0 to 0.5, regardless of your max-gain on the source.

Anyway, that's just my explanation of why I think it was disallowed. It is now enabled, for one core reason: I needed it :D. There's actually a perfectly legitimate use for this feature, anyway. Clamped-Inverse-Exponential attenuation, the default OpenAL attenuation mode, is the most realistic of them all as far as I know (regardless of the fact that it's clamped at ref-dist). If you have a look at the specs, and this is indeed the case in real life, you can never get gain to go to or below zero. Meaning that at some stage you have to switch on the sound source, and just like that it's audible; no fade. Even if it's 1000 units away, gain will not be zero. At this stage, and this is what i'm doing with it, I switch on the source through fadeIn(), which brings it up from 0.0 to whatever the gain at that distance is (let's say 0.001) and from there on all gain control is as per the distance-relative algorithm. Once I don't need it anymore (Too far away), I again don't just want to cut it out, so I fade it from the 0.001 (1.0 source max-gain attenuated by distance) to 0.0.

Works for me. Let me know if you have issues.