Commit Graph

162 Commits

Author SHA1 Message Date
Chris Robinson
3761336e6c Apply distance compensation when writing to the output 2017-02-19 22:47:59 -08:00
Chris Robinson
9da152a9c8 Don't use periphonic FOA when the HOA decoder is not periphonic 2017-02-19 17:45:27 -08:00
Chris Robinson
071b83ba52 Replace more ALuint with ALsizei 2017-01-29 16:42:02 -08:00
Chris Robinson
1ebfce4cac Improve the ambisonic upscaling methods
This now takes advantage of the differences seen in generated decoder matrices
for first-order compared to second- and third-order, such that with the
appropriate frequency-dependent scaling applied to first-order content, the
result is identical with a higher-order decoder matrix compared to a first-
order matrix for the same layout.
2017-01-24 19:03:51 -08:00
Chris Robinson
f4d52f43d8 Fix coefficient counts for the built-in B-Format decoders 2017-01-21 12:28:54 -08:00
Chris Robinson
7025660e8b Use a flat sqrt(2) scale for non-directional ambient gains 2017-01-21 11:54:22 -08:00
Chris Robinson
371fda1803 Update the default basic B-Format decoders
This also converts them to ACN/N3D format.
2017-01-21 11:05:05 -08:00
Chris Robinson
aa56af1ecb Move the B-Format HRTF virtual speaker stuff to InitHrtfPanning
This keeps the decoder matrices and coefficient mapping together for if it
changes in the future.
2017-01-18 19:16:24 -08:00
Chris Robinson
d2e5aa79dd Use ALsizei in more places 2017-01-18 07:13:23 -08:00
Chris Robinson
e9009968fb More ALsizei, with the B-Format decoder 2017-01-16 09:37:55 -08:00
Chris Robinson
cbb796bf31 Use ALsizei for sizes and offsets with the mixer
Unsigned 32-bit offsets actually have some potential overhead on 64-bit targets
for pointer/array accesses due to rules on integer wrapping. No idea how much
impact it has in practice, but it's nice to be correct about it.
2017-01-16 08:06:25 -08:00
Chris Robinson
9f23d17333 Use second-order ambisonics for basic HRTF rendering
This should improve positional quality for relatively low cost. Full HRTF
rendering still only uses first-order since the only use of the dry buffer
there is for first-order content (B-Format buffers, effects).
2017-01-15 13:57:22 -08:00
Chris Robinson
2d5efe424f Be clearer about whether full or basic HRTF rendering is used 2016-11-02 16:10:02 -07:00
Chris Robinson
a758cc8243 Remove use of DECL_CONST
No idea if it was really gaining us anything, but removing it fixes a crash I
was getting with libs built with Clang.
2016-09-06 09:09:25 -07:00
Chris Robinson
8bf4a22876 Combine related members into a struct 2016-08-24 00:25:28 -07:00
Chris Robinson
770e2ff7ed Use a more specialized mixer function for B-Format to HRTF 2016-08-12 05:26:36 -07:00
Chris Robinson
c6c6e3324d Decode directly from B-Format to HRTF instead of a cube
Last time this attempted to average the HRIRs according to their contribution
to a given B-Format channel as if they were loudspeakers, as well as averaging
the HRIR delays. The latter part resulted in the loss of the ITD (inter-aural
time delay), a key component of HRTF.

This time, the HRIRs are averaged similar to above, except instead of averaging
the delays, they're applied to the resulting coefficients (for example, a delay
of 8 would apply the HRIR starting at the 8th sample of the target HRIR). This
does roughly double the IR length, as the largest delay is about 35 samples
while the filter is normally 32 samples. However, this is still smaller the
original data set IR (which was 256 samples), it also only needs to be applied
to 4 channels for first-order ambisonics, rather than the 8-channel cube. So
it's doing twice as much work per sample, but only working on half the number
of samples.

Additionally, since the resulting HRIRs no longer rely on an extra delay line,
a more efficient HRTF mixing function can be made that doesn't use one. Such a
function can also avoid the per-sample stepping parameters the original uses.
2016-08-11 23:20:35 -07:00
Chris Robinson
f1e3f0762b Use the ACN and N3D map and scale lookup tables in SetChannelMap 2016-08-02 09:16:12 -07:00
Chris Robinson
bff5268ed4 Remove DevFmtBFormat3D, which is covered by DevFmtAmbi1 2016-07-31 08:13:41 -07:00
Chris Robinson
4bcd2fbb2e Add an option to specify the ambisonic output configuration 2016-07-31 07:46:38 -07:00
Chris Robinson
33a84f17ac Add a stand-alone upsampler for higher-order ambisonic oputput 2016-07-30 09:29:21 -07:00
Chris Robinson
b5b3ea95f8 Add a config to output first-, second-, or third-order ambisonics
Currently incomplete, as second- and third-order output will not correctly
handle B-Format input buffers. A standalone up-sampler will be needed, similar
to the high-quality decoder.

Also, output is ACN ordering with SN3D normalization. A config option will
eventually be provided to change this if desired.
2016-07-29 21:55:43 -07:00
Chris Robinson
fbba2828cd Update the default quad decoder matrix 2016-07-18 19:42:11 -07:00
Chris Robinson
dc8bbca7f1 Constify and use the correct size for an array 2016-07-17 15:38:39 -07:00
Chris Robinson
e4039cb9ae Update comment about the source radius calculations 2016-07-10 22:11:11 -07:00
Chris Robinson
7ec89b4b6e Avoid function calls to get the HRTF sample rate and IR size 2016-07-07 10:26:42 -07:00
Chris Robinson
b495d80f56 Avoid using memcpy to copy a single struct 2016-07-06 13:33:40 -07:00
Chris Robinson
c63d468d4c Use a macro to specify the ambisonic periphonic channel mask 2016-06-01 05:30:06 -07:00
Chris Robinson
770bdcc108 Recognize AUX0...AUX15 for decoder speaker labels 2016-05-12 23:41:23 -07:00
Chris Robinson
f0871c8cfc Improve radius behavior with scaling of ambisonic coefficients 2016-04-24 21:42:59 -07:00
Chris Robinson
42531703cc Increase max output channels to 16
This also enables fully periphonic 3rd order HQ decoding.
2016-04-19 18:58:19 -07:00
Chris Robinson
a59332f622 Combine two if checks into one 2016-04-19 13:58:33 -07:00
Chris Robinson
cd2e9114e8 Remove unneeded ChannelMaps for BFormat formats 2016-04-17 22:11:15 -07:00
Chris Robinson
3b571e03ab Avoid storing channel names for the dry buffer 2016-04-16 17:21:31 -07:00
Chris Robinson
d1f3a15470 Reorganize a bit of aluInitRenderer code 2016-04-16 14:00:22 -07:00
Chris Robinson
325245f4b8 Silence possible out-of-bounds warning again 2016-04-16 01:24:37 -07:00
Chris Robinson
a6c70992b0 More directly map coefficients for ambisonic mixing buffers
Instead of looping over all the coefficients for each channel with multiplies,
when we know only one will have a non-0 factor for ambisonic mixing buffers,
just index the one with a non-0 factor.
2016-04-15 22:05:47 -07:00
Chris Robinson
e16032e1f0 Update some comments 2016-04-15 18:14:19 -07:00
Chris Robinson
bd65f64d05 Avoid mixing all coefficients together when only some are used 2016-04-15 17:31:04 -07:00
Chris Robinson
e27fad90de Fix possible out-of-bounds warning 2016-04-15 12:33:42 -07:00
Chris Robinson
fb97822d8c Avoid unnecessary loops for setting up effect slot b-format buffer mixing 2016-04-14 21:50:36 -07:00
Chris Robinson
21921cdaff Prepare the custom decoder in aluInitRenderer 2016-04-14 16:42:32 -07:00
Chris Robinson
65a9b97e46 Move the InitRenderer method to panning.c 2016-04-14 15:27:19 -07:00
Chris Robinson
d924e3d6c4 Split aluInitPanning into separate functions for HRTF or UHJ 2016-04-14 10:44:57 -07:00
Chris Robinson
2cd73a8d97 Allow dual-band decoders for basic rendering
Since the basic renderer does not do frequency-dependent processing, the high-
frequency matrix is used for panning.
2016-03-30 02:25:59 -07:00
Chris Robinson
6aaa11df30 Use the same option for decoder configs 2016-03-26 21:02:10 -07:00
Chris Robinson
ad7ad48bd1 Don't use custom decoder configurations with mono or stereo
By default, stereo outputs using UHJ, which renders to a B-Format buffer that
gets run through a UHJ encoder for output. It may also output using pair-wise
panning, which pans between -30 and +30 degrees with the speakers at the two
ends. In both cases, the stereo coefficients are ignored.

Mono, having only one output channel, can realistically only attenuate its
channel. Turning the volume up and down accomplishes the same result.
2016-03-26 20:23:20 -07:00
Chris Robinson
1dcb04157c Add a config option for distance compensation 2016-03-26 17:52:42 -07:00
Chris Robinson
7f4bd13f60 Allow up to third-order for horizontal-only rendering 2016-03-26 01:50:19 -07:00
Chris Robinson
e0466766d7 Include any first-order scaling in the FOAOut coefficients 2016-03-25 23:25:13 -07:00