177 Commits

Author SHA1 Message Date
Chris Robinson
cf5856ed48 Correct conversion from polar to cartesian coords for HRTF
A functional no-op (cos(a) == cos(-a), -sin(a) == sin(-a)), but Ambisonics
expects the azimuth angle to go counter-clockwise.
2015-02-10 05:38:16 -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
d6ebf5d1b6 Make CalcHrtfDelta more generic 2014-11-24 01:53:45 -08:00
Chris Robinson
c37a971947 Rename step to steps 2014-11-24 00:24:12 -08:00
Chris Robinson
837b38b166 Swap delta and step, remove double semicolons 2014-11-23 18:07:19 -08:00
Chris Robinson
45d6bb58a4 Partially revert "Use a different method for HRTF mixing"
The sound localization with virtual channel mixing was just too poor, so while
it's more costly to do per-source HRTF mixing, it's unavoidable if you want
good localization.

This is only partially reverted because having the virtual channel is still
beneficial, particularly with B-Format rendering and effect mixing which
otherwise skip HRTF processing. As before, the number of virtual channels can
potentially be customized, specifying more or less channels depending on the
system's needs.
2014-11-23 10:49:54 -08:00
Chris Robinson
a27e5e1652 Use a different method for HRTF mixing
This new method mixes sources normally into a 14-channel buffer with the
channels placed all around the listener. HRTF is then applied to the channels
given their positions and written to a 2-channel buffer, which gets written out
to the device.

This method has the benefit that HRTF processing becomes more scalable. The
costly HRTF filters are applied to the 14-channel buffer after the mix is done,
turning it into a post-process with a fixed overhead. Mixing sources is done
with normal non-HRTF methods, so increasing the number of playing sources only
incurs normal mixing costs.

Another benefit is that it improves B-Format playback since the soundfield gets
mixed into speakers covering all three dimensions, which then get filtered
based on their locations.

The main downside to this is that the spatial resolution of the HRTF dataset
does not play a big role anymore. However, the hope is that with ambisonics-
based panning, the perceptual position of panned sounds will still be good. It
is also an option to increase the number of virtual channels for systems that
can handle it, or maybe even decrease it for weaker systems.
2014-11-22 04:20:17 -08: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
23cae7783d Properly scale the first HRTF pass-through coefficient
Coefficients are scaled by 32767. For pass-through, this is attenuated by
sqrt(0.5) to maintain a consistent perceived volume.
2014-07-17 18:02:23 -07:00
Chris Robinson
15d7ed2f0d Cleanup some HRTF code
Use loops instead of duplicating code, rewrite some lines to be clearer.
2014-07-16 13:26:47 -07:00
Chris Robinson
0d3b18b17d Fix omni-directional moving HRTF coeffs 2014-07-14 09:15:12 -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
b9462bbe3c Only set the needed HRTF coefficients 2014-06-21 19:17:39 -07:00
Chris Robinson
be903d67b8 Don't pass the device to HRTF methods 2014-06-20 16:43:14 -07:00
Chris Robinson
ea8a85b19c Move PATH_MAX fallback definitions to alMain.h 2014-02-27 18:17:20 -08:00
Chris Robinson
3867e3857d Add back the missing PATH_MAX fallback 2014-02-27 02:55:43 -08:00
Chris Robinson
a8249c3469 Move OpenDataFile to helpers.c so other sources can use it 2014-02-27 01:49:23 -08:00
Chris Robinson
99d82690ef Don't fallback to relative filename handling if opening as absolute fails 2014-02-26 17:38:19 -08:00
Chris Robinson
1b9a722601 Expand environment variables for all config option values when loading 2014-02-26 17:25:05 -08:00
Chris Robinson
89506435fa Support environment variables in the hrtf_tables config value 2014-02-25 19:18:59 -08:00
Chris Robinson
c68ce288d0 Move HRTF macros and function declarations to a separate header 2014-02-23 21:11:01 -08:00
Chris Robinson
5731534e8d Move the default hrtf table to an external file 2014-02-23 21:02:11 -08:00
Chris Robinson
9f43de62ab Add a return value to FindHrtfFormat 2014-02-23 20:14:07 -08:00
Chris Robinson
0e51becd58 Search system-dependant data paths for relative hrtf table filenames 2014-02-23 17:58:34 -08:00
Chris Robinson
a421e515be Use a helper macro for pi*2 2013-10-08 16:31:23 -07:00
Chris Robinson
7257aa3ed2 Allow enabling HRTF through a context creation attribute 2013-05-31 19:29:32 -07:00
Chris Robinson
2a6dd2f243 Fix a type mismatch 2012-10-07 08:19:09 -07:00
Chris Robinson
eedbd1e81c Improve a couple error traces with the HRTF loader 2012-09-18 12:15:43 -07:00
Chris Robinson
41f52fdd6a Restore support for the previous mhr format 2012-09-12 07:25:05 -07:00
Chris Robinson
613ce3f976 Update fnamelist after handling % markers 2012-09-12 04:55:03 -07:00
Chris Robinson
ce8a0a9fd5 Use PATH_MAX for the fname length 2012-09-12 03:45:26 -07:00
Chris Robinson
f59e4ba7c2 Improve parsing hrtf_tables filenames 2012-09-12 03:41:41 -07:00
Chris Robinson
7e81918f7b Update HRTF code
This update allows for much more flexibility in the HRTF data. It also allows
for HRTF table file names to include "%r" to represent the device's playback
rate (e.g. if you set hrtf-%r.mhr, then it will try to use hrtf-44100.mhr or
hrtf-48000.mhr depending if the device's output rate is 44100 or 48000,
respectively).

The makehrtf utility has also been updated to support more options and input
file formats, as well as the new mhr format.
2012-09-11 02:11:51 -07:00
Chris Robinson
ea84fee952 Use a more efficient method to blend HRTF delays and coefficients 2012-08-11 02:16:34 -07:00
Chris Robinson
1323e11701 Interpolate between HRTF delay samples using the delay fraction 2012-07-20 15:08:11 -07:00
Chris Robinson
7ac9944bb3 Increase the directional change sensitivity for the HRTF delta 2012-07-20 14:38:49 -07:00
Chris Robinson
6bd535bed0 Use wrappers for float-typed math functions 2012-06-29 02:12:36 -07:00
Chris Robinson
703d72f20e Use the correct loop count for reading the elevation offsets from external HRTF files 2012-03-17 03:42:07 -07:00
Chris Robinson
f7a8e3db35 Don't assume the calculated HRTF delta for the gain difference is less than 1 2012-03-12 13:31:19 -07:00
Chris Robinson
842a698f2b Add a text file explaining OpenAL Soft's HRTF support and data file format 2012-03-11 19:27:40 -07:00
Chris Robinson
e1cbf06653 Don't use a double when calculating the HRTF coefficients 2011-10-02 22:05:03 -07:00
Chris Robinson
b6b3ca6e6f Use inline assembly for fast float-to-int conversions 2011-09-29 03:51:46 -07:00
Chris Robinson
cf56b0733b Look for and use atan2f, log10f, and floorf 2011-09-24 12:17:39 -07:00
Chris Robinson
6a2b2a0aed Silence MSVC warnings in the HRTF code 2011-09-23 23:16:42 -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
edb386eb1e Add a ConfigValueStr function, to return the string through a parameter 2011-09-19 11:29:18 -07:00
Chris Robinson
a7b9ee6bcb Allow loading multiple HRTF tables through a comma-separated list 2011-09-18 11:10:32 -07:00
Chris Robinson
0e5c221a3c Dynamically allocate space for HRTF tables 2011-09-18 10:09:32 -07:00
Chris Robinson
25f7c27043 Store the HRTF tables used in the device 2011-09-18 09:52:40 -07:00
Chris Robinson
4e903c84cf Fix comment on external HRTF file format 2011-09-15 02:27:02 -07:00