14 Commits

Author SHA1 Message Date
Chris Robinson
240171a53d Fix the UHJ decoder parameters in uhjdecoder 2022-03-02 21:19:53 -08:00
Chris Robinson
1c9f791e4f Rename Sqrt1_2 for consistency 2022-02-01 04:04:24 -08:00
Chris Robinson
f8ac1ffe80 Get rid of MathDefs 2022-01-27 02:59:07 -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
47c20b283e Use a higher quality all-pass for the UHJ utils 2021-07-30 08:08:16 -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