diff options
author | Chris Robinson <[email protected]> | 2014-10-12 12:39:27 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-10-12 12:39:27 -0700 |
commit | f05a2b86cd59bd3827ce741dcc0da5ffdf2969e9 (patch) | |
tree | c11c90d0a86d955aaa8f2d476c9feede09c850d3 | |
parent | 4320a1483b22eff1cc49b13570054064b321473b (diff) |
Don't attempt to match a channel input to output
I don't like this, but it's currently necessary. The problem is that the
ambisonics-based panning does not maintain consistent energy output, which
causes sounds mapped directly to an output channel to be louder compared to
when being panned. The inconcistent energy output is partly by design, as it's
trying to render a full 3D sound field and at least attempts to correct for
imbalanced speaker layouts.
-rw-r--r-- | Alc/ALu.c | 31 |
1 files changed, 7 insertions, 24 deletions
@@ -453,37 +453,18 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A { MixGains *gains = voice->Direct.Mix.Gains[c]; ALfloat Target[MaxChannels]; - bool ok = false; /* Special-case LFE */ if(chans[c].channel == LFE) { for(i = 0;i < MaxChannels;i++) - Target[i] = 0.0f; + gains[i].Target = 0.0f; if(GetChannelIdxByName(Device, chans[c].channel) != -1) - Target[chans[c].channel] = DryGain; - ok = true; - } - else for(i = 0;i < Device->NumSpeakers;i++) - { - /* Attempt to match the input channel to an output based on its - * location. */ - if(Device->Speaker[i].Angle == chans[c].angle && - Device->Speaker[i].Elevation == chans[c].elevation) - { - for(j = 0;j < MaxChannels;j++) - Target[j] = 0.0f; - Target[Device->Speaker[i].ChanName] = DryGain; - ok = true; - break; - } - } - if(!ok) - { - /* All else fails, virtualize it. */ - ComputeAngleGains(Device, chans[c].angle, chans[c].elevation, DryGain, Target); + gains[chans[c].channel].Target = DryGain; + continue; } + ComputeAngleGains(Device, chans[c].angle, chans[c].elevation, DryGain, Target); for(i = 0;i < MaxChannels;i++) gains[i].Target = Target[i]; } @@ -940,7 +921,9 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte ALfloat Target[MaxChannels]; /* Normalize the length, and compute panned gains. */ - if(Distance > FLT_EPSILON) + if(!(Distance > FLT_EPSILON)) + Position[0] = Position[1] = Position[2] = 0.0f; + else { ALfloat radius = ALSource->Radius; ALfloat invlen = 1.0f/maxf(Distance, radius); |