645 Commits

Author SHA1 Message Date
Chris Robinson
ac91083ceb Use 2-channel UHJ for stereo output 2016-02-26 16:09:06 -08:00
Chris Robinson
e1ce7f9180 Use an 8-channel cube for HRTF's virtual format.
There were phase issues caused by applying HRTF directly to the B-Format
channels, since the HRIR delays were all averaged which removed the inter-aural
time-delay, which in turn removed significant spatial information.
2016-02-20 00:53:01 -08:00
Chris Robinson
ecdc93f3ca Calculate HRTF stepping params right before mixing
This means we track the current params and the target params, rather than the
target params and the stepping. This closer matches the non-HRTF mixers.
2016-02-14 03:23:06 -08:00
Chris Robinson
25732d0895 Calculate channel gain stepping just before mixing 2016-02-14 01:22:01 -08:00
Chris Robinson
7f908d90af Rename ComputeBFormatGains to ComputeFirstOrderGains 2016-01-31 09:00:23 -08:00
Chris Robinson
063ef9c2fc Properly silence the LFE input channel gain on the source sends 2016-01-30 07:13:07 -08:00
Chris Robinson
729f213c09 Fix scaling for effect sends of B-Format sources 2016-01-30 07:10:36 -08:00
Chris Robinson
c1f87414c5 Mix to multichannel for effects
This mixes to a 4-channel first-order ambisonics buffer. With ACN ordering and
N3D scaling, this makes it easy to remain compatible with effects that only
care about mono input since channel 0 is an unattenuated mono signal.
2016-01-28 00:02:46 -08:00
Chris Robinson
2fa3ae85c9 Pass a pointer to the input samples array for effect processing 2016-01-27 08:16:47 -08:00
Chris Robinson
f547ef6d39 Separate calculating ambisonic coefficients from the panning gains 2016-01-25 06:11:51 -08:00
Chris Robinson
5d039309b3 Use doubles for the constructed listener matrix
This helps the stability of transforms to local space for sources that are at
or near the listener. With a single-precision matrix, even FLT_EPSILON might
not be enough to detect matching positions.
2015-11-11 08:19:33 -08:00
Chris Robinson
ffcdcbd5fa Update the bsinc table
Precision is increased to cover the full 32-bit float range.
2015-11-10 18:40:33 -08:00
Chris Robinson
ec7b21cd14 Remove a const to silence some warnings 2015-11-06 22:17:15 -08:00
Chris Robinson
de74498cd9 Use more accurate floating point literals 2015-11-06 10:27:28 -08:00
Chris Robinson
b9e192b78a Implement a band-limited sinc resampler
This is essentially a 12-point sinc resampler, unless it's resampling to a rate
higher than the output, at which point it will vary between 12 and 24 points
and do anti-aliasing to avoid/reduce frequencies going over nyquist.

Code provided by Christopher Fitzgerald.
2015-11-05 09:42:08 -08:00
Chris Robinson
c57f571920 Pass in the Q parameter for setting the filter parameters
Also better handle the peaking filter gain.
2015-11-01 05:41:06 -08:00
Chris Robinson
45f11d7b64 Set the current gain immediately if the target is close enough 2015-10-26 01:48:12 -07:00
Chris Robinson
714354caee Set XYZ channel gains for source sends to 0
It's cleaner to just set the gains to 0 rather than to special-case B-Format in
the mixer.
2015-10-23 20:16:11 -07:00
Chris Robinson
bca854baac Use one send gain per buffer channel 2015-10-23 15:11:34 -07:00
Chris Robinson
4813125d31 Return the new vector result from aluMatrixVector 2015-10-22 23:39:56 -07:00
Chris Robinson
6689c61ff4 Remove the MIDI code
The extension's not going anywhere, and it can't do anything fluidsynth can't.
The code maintenance and bloat is not worth keeping around, and ideally the AL
API would be able to facilitate MIDI-like behavior anyway (envelopes, start-at-
time, etc).
2015-10-20 18:01:27 -07:00
Chris Robinson
2730d8e76f Round the calculated stepping value 2015-10-15 15:38:07 -07:00
Chris Robinson
67455c66a1 Replace the resample_fir6 declaration with resample_fir8 2015-10-12 06:34:55 -07:00
Chris Robinson
dc10e56bab Implement a 6-point sinc-lanczos filter 2015-09-29 20:39:12 -07:00
Aaron Jacobs
a7084b1051 Fix resample_fir4 link error 2015-09-29 12:34:03 -07:00
Chris Robinson
86ff35bf71 Increase the max pitch to 255
Note that this is the multiple above the device sample rate, rather than the
source property limit. It could theoretically be increased to 511 by testing
against UINT_MAX instead of INT_MAX, since the increment and positions are
using unsigned integers. I'm just being paranoid about overflows.
2015-09-26 11:18:30 -07:00
Chris Robinson
17e2b4b3a5 Remove unneeded clamping 2015-09-24 13:44:28 -07:00
Chris Robinson
4bdd58bc83 Use N3D scaling instead of FuMa 2015-09-23 15:03:53 -07:00
Chris Robinson
db0f29f6d8 Fix updating listener params when forcing updates 2015-09-18 00:48:43 -07:00
Chris Robinson
2763f4096c Update properties and clear wet buffers before mixing/processing 2015-09-13 06:51:55 -07:00
Chris Robinson
d240077bc5 Explicitly convert to int in the aluF2I/S/B functions 2015-09-07 03:27:25 -07:00
Chris Robinson
bbc16e2c15 Use ACN ordering for ambisonics coefficients arrays
Note that it still uses FuMa scalings internally. Coefficients loaded from
config files specify if they're FuMa (in both ordering and scaling) or N3D,
and will get reordered or rescaled as needed.
2015-08-28 10:58:30 -07:00
Chris Robinson
baf1bd5b54 Avoid temporary vector objects 2015-08-24 03:02:58 -07:00
Chris Robinson
c292b9e4ff Revert "Fix B-Format rotation"
This reverts commit 7ffb9b3056ab280d5d9408fd023f3cfb370ed103.

It was behaving as appropriate before (orienting left did pan it left for the
listener), I was apparently just misinterpreting the matrix.
2015-08-24 00:19:47 -07:00
Chris Robinson
7ffb9b3056 Fix B-Format rotation
The rotation erroneously specified the orientation of the source relative to
the sound field, whereas it should be the orientation of the sound field *and*
source relative to the listener. So now when the source is oriented left, the
front of the sound field is to the left of the listener.
2015-08-23 22:01:29 -07:00
Chris Robinson
f58d985789 Change source radius behavior
For sources with a non-0 radius:
When distance <= radius, factor = distance/radius*0.5
When distance > radius, factor = 1 - asinf(radius/distance)/PI

Also, avoid using Position after calculating the localized direction and
distance.
2015-07-05 08:54:29 -07:00
Chris Robinson
4efe0d8696 Update a couple comments 2015-07-04 10:12:57 -07:00
Chris Robinson
71b6e9bfe0 Add an option for "basic" HRTF rendering
This method is intended to help development by easily testing the quality of
the B-Format encode and B-Format-to-HRTF decode. When used with HRTF, all
sources are renderer using the virtual B-Format output, rather than just
B-Format sources.

Despite the CPU cost savings (only four channels need to be filtered with HRTF,
while sources all render normally), the spatial acuity offered by the B-Format
output is pretty poor since it's only first-order ambisonics, so "full" HRTF
rendering is definitely preferred.

It's /possible/ for some systems to be edge cases that prefer the CPU cost
savings provided by basic over the sharper localization provided by full, and
you do still get 3D positional cues, but this is unlikely to be an actual use-
case in practice.
2015-02-11 09:32:05 -08:00
Chris Robinson
3ed79cc229 Use a single statement to declare the buffer format channel maps 2015-02-10 10:04:59 -08:00
Chris Robinson
a1d4847d07 Use B-Format for HRTF's virtual output format
This adds the ability to directly decode B-Format with HRTF, though only first-
order (WXYZ) for now. Second- and third-order would be easilly doable, however
we'd need to be able to up-mix first-order content (from the BFORMAT2D and
BFORMAT3D buffer formats) since it would be inappropriate to decode lower-order
content with a higher-order decoder.
2015-02-09 15:59:29 -08:00
Chris Robinson
8933e21ef2 Properly handle a mono output buffer with the MIDI synths 2015-02-09 08:47:48 -08:00
Chris Robinson
1393af4f9f Add a comment detailing how the HRTF channel buffer is set up 2015-02-09 08:11:07 -08:00
Chris Robinson
61755f35c1 Move HRTF params and state closer together 2015-02-09 05:54:14 -08:00
Chris Robinson
6574fa4863 Cast to the pointer-to-type to increment the buffer 2014-12-21 09:48:36 -08:00
Chris Robinson
94ad5b289f Avoid duplicate calculations 2014-12-18 07:42:14 -08:00
Chris Robinson
c37275efdc Use aluVector and aluMatrix in a couple more places 2014-12-16 10:36:44 -08:00
Chris Robinson
d2adefe063 Pass a vectory to aluMatrixVector 2014-12-16 07:42:17 -08:00
Chris Robinson
3b8f54d572 Use aluVector in some more places 2014-12-16 07:20:27 -08:00
Chris Robinson
97f6d302fe Add explicit matrix and vector types to operate with 2014-12-16 06:29:31 -08:00
Chris Robinson
a606bbc7f1 Use a lookup table to do cubic resampling 2014-12-15 12:23:28 -08:00