568 Commits

Author SHA1 Message Date
Chris Robinson
6083a684d1 Use a method to set omni-directional channel gains 2014-11-04 03:33:35 -08:00
Chris Robinson
deba996769 Add some missing breaks 2014-11-02 02:30:45 -08:00
Chris Robinson
c82f39decd Avoid the ALCdevice_Lock/Unlock wrapper in some places 2014-11-01 15:55:18 -07:00
Chris Robinson
3d2853274d Support B-Format source rotation with AL_ORIENTATION 2014-10-31 22:43:13 -07:00
Chris Robinson
336aba6f1f Rename the source's Orientation to Direction 2014-10-31 17:24:46 -07:00
Chris Robinson
ac51c9cce6 Add preliminary AL_EXT_BFORMAT support
Currently missing the AL_ORIENTATION source property. Gain stepping also does
not work.
2014-10-31 17:18:45 -07:00
Chris Robinson
f05a2b86cd 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.
2014-10-12 12:39:27 -07:00
Chris Robinson
a77387b549 Avoid taking the square-root of the ambient gain
Although it is more correct for preserving the apparent volume, the ambisonics-
based panning does not work on the same power scale, making it louder by
comparison.
2014-10-11 09:35:32 -07:00
Chris Robinson
70b23ab77f Add a helper to search for a channel index by name 2014-10-02 21:19:34 -07:00
Chris Robinson
95ba18cf4e Make ComputeAngleGains use ComputeDirectionalGains 2014-10-02 18:05:42 -07:00
Chris Robinson
918c773a59 Use helpers to set the gain step values 2014-10-02 00:56:29 -07:00
Chris Robinson
2d89d33dd1 Add a cast for MSVC 2014-09-30 21:50:29 -07:00
Chris Robinson
4d36ef65b2 Use an ambisonics-based panning method
For mono sources, third-order ambisonics is utilized to generate panning gains.
The general idea is that a panned mono sound can be encoded into b-format
ambisonics as:

w[i] = sample[i] * 0.7071;
x[i] = sample[i] * dir[0];
y[i] = sample[i] * dir[1];
...

and subsequently rendered using:

output[chan][i] = w[i] * w_coeffs[chan] +
                  x[i] * x_coeffs[chan] +
                  y[i] * y_coeffs[chan] +
                  ...;

By reordering the math, channel gains can be generated by doing:

gain[chan] = 0.7071 * w_coeffs[chan] +
             dir[0] * x_coeffs[chan] +
             dir[1] * y_coeffs[chan] +
             ...;

which then get applied as normal:

output[chan][i] = sample[i] * gain[chan];

One of the reasons to use ambisonics for panning is that it provides arguably
better reproduction for sounds emanating from between two speakers. As well,
this makes it easier to pan in all 3 dimensions, with for instance a "3D7.1" or
8-channel cube speaker configuration by simply providing the necessary
coefficients (this will need some work since some methods still use angle-based
panpot, particularly multi-channel sources).

Unfortunately, the math to reliably generate the coefficients for a given
speaker configuration is too costly to do at run-time. They have to be pre-
generated based on a pre-specified speaker arangement, which means the config
options for tweaking speaker angles are no longer supportable. Eventually I
hope to provide config options for custom coefficients, which can either be
generated and written in manually, or via alsoft-config from user-specified
speaker positions.

The current default set of coefficients were generated using the MATLAB scripts
(compatible with GNU Octave) from the excellent Ambisonic Decoder Toolbox, at
https://bitbucket.org/ambidecodertoolbox/adt/
2014-09-30 07:33:13 -07:00
Chris Robinson
4e66224d6c Combine some fields into a struct 2014-09-10 17:53:01 -07:00
Chris Robinson
01adfde199 Invert the ChannelOffsets array 2014-09-10 16:52:54 -07:00
Chris Robinson
259e265920 Rename activesource to voice 2014-08-21 03:41:13 -07:00
Chris Robinson
65d2e0eb8d Use an array of objects for active sources instead of pointers 2014-08-21 02:27:56 -07:00
Chris Robinson
b92e643e97 Use a NULL source for inactive activesources
Also only access the activesource's source field once per update.
2014-08-21 00:29:42 -07:00
François Cami
3c13e1e333 Update COPYING to the latest https://www.gnu.org/licenses/old-licenses/lgpl-2.0.txt to fix the FSF' address Fix the FSF' address in the source 2014-08-18 11:34:29 -07:00
Chris Robinson
87423f046e Use atomics for the device and context list heads 2014-08-01 02:04:40 -07:00
Chris Robinson
15a58eb383 Make the source's buffer queue head and current queue item atomic 2014-07-31 07:20:36 -07:00
Chris Robinson
531c0d8e6b Explicitly pass the address of atomics and parameters that can be modified 2014-07-26 03:00:49 -07:00
Chris Robinson
e4b779c492 Use generic atomics in more places 2014-07-22 18:57:51 -07:00
Chris Robinson
5a339a2a5b Add macros for generic atomic functionality 2014-07-22 00:20:28 -07:00
Chris Robinson
f4cdecebcf Add a source radius property that determines the directionality of a sound
At 0 distance from the listener, the sound is omni-directional. As the source
and listener become 'radius' units apart, the sound becomes more directional.

With HRTF, an omni-directional sound is handled using 0-delay, pass-through
filter coefficients, which is blended with the real delay and coefficients as
needed to become more directional.
2014-07-11 00:03:13 -07:00
Chris Robinson
0fd215cb84 Remove unused variables 2014-06-13 22:50:14 -07:00
Chris Robinson
57c683f822 Get the mixer and resampler functions when needed 2014-06-13 16:07:25 -07:00
Chris Robinson
a8deaf12f4 Combine the direct and send mixers 2014-06-13 13:34:19 -07:00
Chris Robinson
c29eb63489 Combine some dry and wet path types 2014-06-13 11:42:04 -07:00
Timothy Arceri
fc0be88c0f Add SSE2 and SSE4.1 linear resamplers
Currently the only way SSE 4.1 is detected is by using __get_cpuid, i.e. with
GCC. Windows' IsProcessorFeaturePresent does not report SSE4.1 capabilities.
2014-06-06 07:15:00 -07:00
Chris Robinson
3b2fcb3ef6 Avoid a loop when updating the source position variables 2014-06-02 19:19:22 -07:00
Chris Robinson
2e38de349c Don't clear the current and step gain values when updating a source 2014-05-21 16:32:24 -07:00
Chris Robinson
8e04a8a022 Put per-channel filter properties together 2014-05-19 02:24:31 -07:00
Chris Robinson
c9083d04fa Don't pass the DirectParams to the dry-path mixer 2014-05-18 10:24:07 -07:00
Chris Robinson
5a1abf6918 Use different parameters for HRTF mixers 2014-05-18 09:31:08 -07:00
Chris Robinson
82dd2d875e Apply high-pass source filters as needed 2014-05-17 07:54:25 -07:00
Chris Robinson
0b5b39d5e6 Add a flag to specify when the low-pass filter needs to apply 2014-05-17 07:17:48 -07:00
Chris Robinson
343200d229 Store the filter reference frequency in the source 2014-05-11 10:07:17 -07:00
Chris Robinson
58235bec17 Update the source send target gains properly 2014-05-11 09:45:07 -07:00
Chris Robinson
851a917b03 Use a struct to store the source's direct gain/gainhf properties 2014-05-11 01:40:44 -07:00
Chris Robinson
9e25ea8666 Update the output buffer pointer in the Write_* methods 2014-05-10 07:52:02 -07:00
Chris Robinson
67b4bd1031 Add a couple consts 2014-05-10 07:25:05 -07:00
Chris Robinson
c4383b65e2 Store the current buffer queue item, rather than played buffer count 2014-05-10 03:21:40 -07:00
Chris Robinson
d066c7b124 Better pack HRTF mixing properties 2014-05-03 18:59:26 -07:00
Chris Robinson
b2e533fbfc Clamp the current and target gain lower bound to epsilon
Should give a bit more wiggle room for the gain stepping to get lower than the
silence threshold.
2014-05-03 17:51:06 -07:00
Chris Robinson
5e0fc84f49 Make HRTF stepping values per-channel 2014-04-05 10:24:13 -07:00
Chris Robinson
72986882f5 Remove the click removal buffers for auxiliary effect slots 2014-03-23 16:28:55 -07:00
Chris Robinson
52deb557d5 Add gain stepping to the send mixers 2014-03-23 16:11:21 -07:00
Chris Robinson
55f851093f Remove the now-unneeded click removal buffers for the device
They are still there for auxiliary sends. However, they should go away soon
enough too, and then we won't have to mess around with calculating extra
"predictive" samples in the mixer.
2014-03-23 07:31:33 -07:00
Chris Robinson
81e049bd47 Step mixing gains per-sample for non-HRTF mixing
This fades the dry mixing gains using a logarithmic curve, which should produce
a smoother transition than a linear one. It functions similarly to a linear
fade except that

step = (target - current) / numsteps;
...
gain += step;

becomes

step = powf(target / current, 1.0f / numsteps);
...
gain *= step;

where 'target' and 'current' are clamped to a lower bound that is greater than
0 (which makes no sense on a logarithmic scale).

Consequently, the non-HRTF direct mixers do not do not feed into the click
removal and pending click buffers, as this per-sample fading would do an
adequate job of stopping clicks and pops caused by extreme gain changes. These
buffers should be removed shortly.
2014-03-23 06:57:00 -07:00