Commit Graph

162 Commits

Author SHA1 Message Date
Chris Robinson
a095645970 Don't bother with LFE in the channel setup, set the values explicitly 2014-11-12 19:26:53 -08:00
Chris Robinson
e036cca1c9 Add the ability to use custom output channel coefficients
I'm not sure exactly how I want to do this yet, but this is a good starting
point.
2014-11-10 17:53:42 -08:00
Chris Robinson
713e9dd4cc Rename speakers to channels, and remove an old incorrect comment 2014-11-07 03:12:32 -08:00
Chris Robinson
4c3f27193f Use a separate macro for the max output channel count 2014-11-07 02:18:24 -08:00
Chris Robinson
0051a96376 Fix 5.1 surround sound
Apparently, 5.1 surround sound is supposed to use the "side" channels, not the
back channels, and we've been wrong this whole time. That means the "5.1 Side"
is actually the correct 5.1 setup, and using the back channels is anomalous.

Additionally, this means the 5.1 buffer format should also use the the side
channels instead of the back channels.

A final note: the 5.1 mixing coefficients are changed so both use the original
5.1 surround sound set (with the surround channels at +/-110 degrees). So the
only difference now between 5.1 "side" and 5.1 "back" is the channel labels.
2014-11-07 00:54:16 -08:00
Chris Robinson
ad247fe5cd Initialize a couple variables mingw complains about 2014-11-06 23:05:21 -08:00
Chris Robinson
da765ec53b Remove the channel name from ChannelConfig 2014-11-05 03:46:00 -08:00
Chris Robinson
e39117467c Fix panning of multi-channel sources 2014-11-05 03:06:32 -08:00
Chris Robinson
c834c3fae5 Set gains using the device channel index 2014-11-05 02:54:11 -08:00
Chris Robinson
e5016f814a Add LFE to the speaker arrays 2014-11-04 04:33:35 -08:00
Chris Robinson
6083a684d1 Use a method to set omni-directional channel gains 2014-11-04 03:33:35 -08:00
Chris Robinson
d8cfdb3f34 Use COUNTOF to set the number of speakers 2014-11-04 03:00:15 -08:00
Chris Robinson
857d68b0ce Minor update for ambisonics coefficients
Small tweaks to balance the left and right speakers, and change
unreasonably small values to 0.
2014-11-02 00:58:48 -07:00
Chris Robinson
3d2853274d Support B-Format source rotation with AL_ORIENTATION 2014-10-31 22:43:13 -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
79163b0755 Fix stereo device configuration 2014-10-11 04:07:33 -07:00
Chris Robinson
79fb86d8f7 Store default speaker configurations in a struct 2014-10-02 20:25:30 -07:00
Chris Robinson
95ba18cf4e Make ComputeAngleGains use ComputeDirectionalGains 2014-10-02 18:05:42 -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
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
d3c70e63b4 Use C99 inline in more places 2013-11-04 13:44:46 -08:00
Chris Robinson
a421e515be Use a helper macro for pi*2 2013-10-08 16:31:23 -07:00
Chris Robinson
11365b42c7 Use helper macros to convert between degrees and radians 2013-10-08 12:39:22 -07:00
Chris Robinson
764ea95781 Use helpers to set channel gain arrays
Also avoid unnecessary clearing.
2013-10-03 05:02:16 -07:00
Chris Robinson
a371de080b Silence some clang warnings 2013-06-05 01:52:49 -07:00
Chris Robinson
0dde7dd88a Use a more efficient method to offset the speaker angles when computing gains 2012-08-09 02:31:19 -07:00
Chris Robinson
6bd535bed0 Use wrappers for float-typed math functions 2012-06-29 02:12:36 -07:00
Chris Robinson
583dc8dbca Don't use all caps for enum value names 2012-06-28 18:49:49 -07:00
Chris Robinson
aed35fd811 Use ComputeAngleGains for multi-channel sources and remove the unused lookup table stuff 2012-04-29 05:04:46 -07:00
Chris Robinson
57d36ec582 Fix a couple comment typos, and a minor cleanup 2012-04-29 03:39:08 -07:00
Chris Robinson
74e128bd0f Fix ComputeAngleGains
The old code would improperly handle speakers just inside or outside the
coverage area if it had to be inverted. It also didn't properly handle when
only one speaker was outside of the covered area.
2012-04-28 12:12:02 -07:00
Chris Robinson
611bd0b2d3 Add a method to calculate gains given a sound point and its half-width, and use it for reverb
The half-width ranges from 0 to pi, and essentially specifies the coverage area
around the listener. At 0, it's an infinitely small point sound and behaves
like a usual panning sound. At pi/2 it covers half the area, and at pi it
covers the whole area.
2012-04-28 08:21:53 -07:00
Chris Robinson
267d38cf20 Flip the parameters to aluCart2LUTpos, so it behaves a bit more like atan2 2012-04-28 03:58:58 -07:00
Chris Robinson
67f1cdfcbe Store the speaker angles in the device 2012-04-27 07:38:17 -07:00
Chris Robinson
305d790a19 Revert the default stereo layout back to -90 and +90 degrees
For the time being, until better stereo spatialization can be implemented and
headphones can be better detected.
2012-03-12 22:49:10 -07:00
Chris Robinson
6ffaabeb75 Update the layout config option names 2012-03-01 10:06:55 -08:00
Chris Robinson
504cdadd60 Use an enum for the device type 2012-02-23 15:25:30 -08:00
Chris Robinson
18f87b97d5 Always use the default speaker layout for loopback devices 2012-02-07 07:29:34 -08:00
Chris Robinson
7ad1b45d11 Change the default stereo speaker positions to match the stereo channel positions
A separate "headphones" configuration may be nice to add for -90,+90, however
not many audio APIs can detect this. Ideally HRTF would be used with
headphones too, which largely ignores the speaker positions, however there
could be situations where this is unfeasible or unwanted.
2012-02-04 10:29:19 -08:00
Chris Robinson
3bbde05e0e Use the square root to build the panning table instead of sin/cos 2011-10-10 09:39:02 -07:00
Chris Robinson
470b506952 Use macros for float-typed PI values, to avoid manual casts everywhere 2011-09-22 11:17:01 -07:00
Chris Robinson
de8a447ea5 More MSVC precision casts 2011-09-22 01:20:49 -07:00
Chris Robinson
a4b1239f45 Use cosf and sinf when available
Also clear away a few more MSVC precision warnings
2011-09-22 01:00:44 -07:00
Chris Robinson
edb386eb1e Add a ConfigValueStr function, to return the string through a parameter 2011-09-19 11:29:18 -07:00
Chris Robinson
3ab20d4ccb Print an error for invalid speaker layout keys 2011-08-28 10:25:40 -07:00
Chris Robinson
17773c5644 Rename the ERROR macro to ERR 2011-07-13 01:43:00 -07:00
Chris Robinson
7bedd9ef7a Replace some AL_PRINT calls with proper logging 2011-07-10 22:32:44 -07:00
Chris Robinson
ac7ca07221 Get rid of a couple typedefs 2011-07-02 21:33:53 -07:00
Chris Robinson
7da2eea8f0 Add a 5.1 device format that uses side channels instead of back 2011-05-28 19:35:32 -07:00
Chris Robinson
a9d9553fff Use a multi-dimensional array for the panning LUT 2011-05-21 17:45:54 -07:00
Chris Robinson
4198f3062c Remove the device channel matrix 2011-05-06 04:42:54 -07:00
Chris Robinson
319dfce300 Fix LFE channel output 2011-04-14 15:20:25 -07:00
Chris Robinson
c3e86933d0 Only set relevant device matrix entries 2011-04-12 17:08:02 -07:00
Chris Robinson
4eeed5376f Invert the device matrix row/column
It is accessed now as mat[target][source]
2011-03-13 08:46:54 -07:00
Chris Robinson
02e0223fe8 Re-enable channel-config-specific layout options 2011-01-23 23:57:39 -08:00
Chris Robinson
88e3a22772 Separate device format into 'channel config' and 'sample type' components 2010-12-04 19:50:00 -08:00
Chris Robinson
9e8fb89a52 Rename OUTPUTCHANNELS to something more descriptive 2010-12-01 18:33:17 -08:00
Chris Robinson
da4f5c6f96 Uninline some functions
Also add -Winline to the compiler command line to watch for future inline problems
2010-11-28 19:52:17 -08:00
Chris Robinson
03f56419d0 Duplicate stereo sources by default
The mixer is smart enough now to handle proper volume adjustments depending on
the number of output speakers
2010-09-22 11:09:34 -07:00
Chris Robinson
762bdaeee1 Panning init cleanup 2010-08-07 08:49:29 -07:00
Chris Robinson
2af39e51f8 Separate speaker/panning initialization into another source file 2010-08-03 00:21:36 -07:00