340 Commits

Author SHA1 Message Date
Chris Robinson
f2858ac865 Resample before frequency analysis
We want to resample before minimum phase reconstruction since that changes the
phase relationship of the sampled signal, introducing a slight bit of noise
from truncated sampling. It's not clear that the frequency domain resampling
method is accurate, so resampling prior to frequency analysis is an alternative
to ensure the resulting frequencies are given the proper phase for sampling.

This also cleans up some micro allocations in loops.
2022-05-13 15:40:15 -07:00
Chris Robinson
593966c8db Handle 3D7.1 as a separate channel configuration
It's treated as 5.1 + 2 aux channels. This allows AL_DIRECT_CHANNELS_SOFT to
behave better, not forwarding rear left/right channel inputs to lower front and
upper rear, and allows reporting a more appropriate output mode to the app
instead of 7.1.
2022-04-26 23:32:15 -07:00
Chris Robinson
07dd62e53f Update a tooltip to match current behavior 2022-04-26 19:27:26 -07:00
Chris Robinson
9b330e4127 Add an option to alsoft-config for EAX API support 2022-04-26 14:03:24 -07:00
Chris Robinson
1050428d3d Print the output mode from openal-info 2022-04-17 13:56:30 -07:00
Chris Robinson
240171a53d Fix the UHJ decoder parameters in uhjdecoder 2022-03-02 21:19:53 -08:00
Chris Robinson
f9c45eac1a Use a more compatible method to check for EFX effects
Creative's wrapper driver doesn't seem to handle EFX enums for alGetEnumValue,
let alone return values only for what's supported. The only way to check which
filter and effect types it supports is try to set them and check for errors.
2022-02-26 07:38:36 -08:00
Chris Robinson
9ba489360c Add options to encode 3- and 4-channel UHJ to uhjencoder
The generated files won't play correctly if the player doesn't know they're 3-
and 4-channel UHJ (the third and fourth channels must be ignored, or decoded,
for playback). This is largely just for completion's sake, just in case someone
has a use for it.
2022-02-04 18:05:25 -08:00
Chris Robinson
1c9f791e4f Rename Sqrt1_2 for consistency 2022-02-01 04:04:24 -08:00
Chris Robinson
619249371a Remove math_defs.h 2022-01-27 04:04:41 -08:00
Chris Robinson
f8ac1ffe80 Get rid of MathDefs 2022-01-27 02:59:07 -08:00
Chris Robinson
481b115b96 Add an ambi-format option for ACN ordering and FuMa scaling 2022-01-12 03:25:59 -08:00
Chris Robinson
e32c214e9c Use the deprecated enum for older Qt versions 2022-01-06 17:01:26 -08:00
Chris Robinson
16ae002d0b Avoid a deprecated QString enum 2022-01-05 20:39:12 -08:00
Chris Robinson
43ec687ee9 Add a third-order ambisonic decoder for HRTF
Using the 20-channel dodecahedron, seems to be good enough to handle 16-channel
third-order ambisonics.
2022-01-05 20:32:03 -08:00
Chris Robinson
5381527303 Add the PipeWire config option to alsoft-config 2021-12-25 20:30:57 -08:00
Chris Robinson
a73b64ce3c Slight update to the UHJ coefficients
The extended precision of the encoder's 0.6512*X term was guesswork, with no
real basis for it. Switch back to the original value until something better
actually comes up. Also updates the decoder to account for the change in the
encoder.
2021-11-28 05:39:35 -08:00
Chris Robinson
bd254c5426 Recognize PipeWire in alsoft-config 2021-11-26 03:05:05 -08:00
Chris Robinson
3ef4bffaf9 Slightly improve logging on Windows
The characters won't display properly if the system codepage isn't UTF-8, but
at least it shouldn't cut the line off prematurely.
2021-11-21 21:21:46 -08:00
Chris Robinson
5eb93f6c74 Update alsoft-config 2021-11-11 22:40:10 -08:00
Chris Robinson
f963a2c543 Remove some lingering mentions of surround51rear 2021-10-21 07:38:57 -07:00
Chris Robinson
47c20b283e Use a higher quality all-pass for the UHJ utils 2021-07-30 08:08:16 -07:00
Chris Robinson
955fdebcad Add a utility to encode audio files to UHJ 2021-07-09 09:04:07 -07:00
Chris Robinson
f403fbd2e9 Fix UHJ encoding/decoding factors
Classic B-Format uses scaling factors W=1, X=sqrt(2), Y=sqrt(2), and Z=sqrt(2),
which is +3dB louder than FuMa. The base factors are designed assuming classic
scaling, so encoding a 0dBFS FuMa signal without accounting for this would
result in the UHJ signal peaking at about -3dBFS. Similarly, decoding UHJ to
FuMa B-Format would be +3dB louder than intended.

So encoding needs to implicitly boost the signal by +3dB, and decoding needs to
attenuate by -3dB.
2021-04-11 17:09:52 -07:00
Chris Robinson
e32b551944 Remove some unnecessary includes 2021-03-28 06:10:45 -07:00
Chris Robinson
8ab5e5dba2 Move the UHJ phase shifter to a common header 2021-03-28 06:09:11 -07:00
Chris Robinson
f045694ce0 Add an option to change the UHJ decoder method
For 2-channel UHJ, two decoding equations are provided in the original paper.
The alternative one is most often referenced for 2-channel UHJ decoding, but
the original/general one can also be used by assuming T is fully attenuated
(which the format allows for, as T can be variably attenuated by a factor
between 0 and 1 to deal with an imperfect transmission medium).

Neither method can be perfect for 2-channel UHJ, it's irrevocably lossy to the
original source, but my subjective testing indicates the general equation
produces less audibly errant results.
2021-03-26 02:55:45 -07:00
Chris Robinson
d681573803 Fix a comment typo 2021-03-24 04:34:01 -07:00
Chris Robinson
d732a8831e Update the UHJ decoding coefficients 2021-03-24 00:24:10 -07:00
Chris Robinson
ae43e628fb Add support for decoding 3- and 4-channel UHJ audio
There are no known file formats intended to support 3- and 4-channel UHJ, but
it is possible to store them in various audio files when a player/decoder is
aware of what it's dealing with. So there's no reason not to have it as an
option.
2021-03-21 19:37:24 -07:00
Chris Robinson
b8ede345f3 Don't assume two input channels in uhjdecoder 2021-03-21 12:36:56 -07:00
Chris Robinson
c3ee678945 Add a utility to decode UHJ sound files to AMB
Currently only supports 2-channel UHJ, and the produced .amb files shouldn't be
played as normal B-Format (decoded 2-channel UHJ needs to use different shelf
filters).
2021-03-21 02:03:45 -07:00
Chris Robinson
302e88dbf0 Add missing include 2021-02-16 05:42:14 -08:00
Chris Robinson
417d8da6f4 Avoid a deprecated function 2020-11-13 21:47:48 -08:00
Chris Robinson
af9c990277 Print the number of used measurements in sofa-info 2020-10-07 01:04:42 -07:00
Chris Robinson
02e51c0525 Avoid using a deprecated function 2020-08-31 17:48:26 -07:00
Chris Robinson
2fa842a04c Avoid allocating for each HRIR reconstruction 2020-08-14 18:22:20 -07:00
Chris Robinson
aafcb1f6fc Simplify StrSubst in makemhr 2020-08-13 16:02:13 -07:00
Chris Robinson
fd52c828a9 Improve handling main() with UTF-8 args on Windows 2020-08-12 17:40:00 -07:00
Chris Robinson
7ddd49e16a Add the jack/connect-ports option to alsoft-config 2020-08-05 00:43:08 -07:00
Chris Robinson
a0eb532100 Apply simulated HRIR occlusion in the frequency domain 2020-06-21 19:28:37 -07:00
Chris Robinson
24393ab192 Synthesize missing elevations in the frequency domain
This should help avoid destructive phase interference. The occlusion low-pass
filter is still applied in the time domain due to no clear topology (cutoff
frequency, slope, bandwidth, etc).
2020-06-21 00:29:57 -07:00
Chris Robinson
a01dbeb09f Use multiple threads for magnitude calculations
Also allow user-declarable thread count.
2020-06-19 16:43:09 -07:00
Chris Robinson
8780976979 Avoid blending multiple IRs for the -90 elevation IR 2020-06-19 15:28:22 -07:00
Chris Robinson
4cd0e333c8 Calculate the HRIR onsets and magnitudes separately from loading
This should help improve memory use a bit since the SOFA file can be unloaded
before allocating some temp buffers for onset detection and FFT calculation.
2020-06-17 17:15:26 -07:00
Chris Robinson
3f26ce4a82 Add a makemhr option to use the farthest field only
All fields are used for equalization, but only the farthest field is resampled,
reconstructed, normalized, and written to the mhr.
2020-06-17 16:25:40 -07:00
Chris Robinson
beba71a6f9 Resample HRIRs after equalization 2020-06-17 13:03:26 -07:00
Chris Robinson
4cfd63a1c7 Avoid reinitializing the resampler with each HRIR 2020-06-17 01:50:11 -07:00
Chris Robinson
cd6bb65d49 Resample HRTFs in the frequency domain in makemhr
This should produce far better results given it works directly on the frequency
response magnitudes prior to phase reconstruction, as it doesn't deal with a
linear phase filter on a truncated time-domain response (with the result also
getting truncated in both direction).

The in-library on-load HRTF resampler still uses the linear filter due to its
relative performance and simplicity benefits. It's good enough as a backup,
though users with custom HRTFs would benefit from resampling when creating the
mhr (adjusting its window size as appropriate/desired).
2020-06-17 01:15:01 -07:00
Chris Robinson
8ea7d5183b Print the synthesized elevations' azimuth counts 2020-06-16 17:33:26 -07:00