7668 Commits

Author SHA1 Message Date
Chris Robinson
e457018921 Avoid passing an array of pointers 2021-04-01 03:44:26 -07:00
Chris Robinson
f33edc3b30 Add support for 4-channel UHJ
Also add the SOFT moniker to the new macros
2021-03-31 21:02:30 -07:00
Chris Robinson
b5e36007f1 Handle 3-channel UHJ audio buffers 2021-03-31 10:03:31 -07:00
Chris Robinson
35a0f2665f Decode UHJ buffers to B-Format for mixing
This should also have an adjustment for the shelf filter. Although it's not
clear what the appropriate adjustments should be.
2021-03-31 09:37:30 -07:00
Chris Robinson
8793055e66 Start an interface for providing UHJ audio
Currently only 2-channel UHJ, which gets treated as stereo.
2021-03-31 05:37:56 -07:00
Chris Robinson
051d6fb243 Combine some duplicate code 2021-03-30 07:04:06 -07:00
Chris Robinson
7b2f194490 Rename a couple class members 2021-03-28 23:45:16 -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
819e0297ff Add the export definitions to the library projects
Instead of the config.h header.
2021-03-28 01:47:27 -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
9a31dcf84f Don't add the resampler prepadding to the source size to load 2021-03-23 19:55:44 -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
f0726f471f Use float formats in examples/alstreamcb
libsndfile apparently has issues reading floating-point wave files as 16-bit
samples (produces silence). Even on other file formats, reading float samples
as integer samples has no over/underflow protection, so this is better for
those formats too.
2021-03-21 01:38:38 -07:00
Chris Robinson
7c697b9178 Fix the UHJ all-pass delay
For real this time. The non-all-passed signal needs a one-sample delay over the
all-passed signal. Because of the way the all-pass FIR filter is structured,
it wouldn't otherwise use the last buffered sample, allowing it to be shifted
forward in time by one sample.

Also, remove a couple unnecessary buffers.
2021-03-20 03:14:10 -07:00
Chris Robinson
063da94bd8 Load/convert samples from all channels at once for mixing
This uses a bit more memory (each voice needs to hold buffers for the
deinterleaved samples of each channel, instead of just one buffer for the
current channel being mixed on the device), but it will allow for handling
formats that need or prefer their channels decoded together.
2021-03-19 23:15:27 -07:00
kcat
f7f2999960
Merge pull request #543 from ilya-fedin/dont-force-app-name
Don't force application name with pulseaudio
2021-03-17 21:22:46 -07:00
Ilya Fedin
b7ff1de48e Don't force application name with pulseaudio 2021-03-18 04:34:57 +04:00
Chris Robinson
743f0931c6 Don't activate the WASAPI device when initially opening it 2021-03-17 17:03:35 -07:00
Chris Robinson
f11fef9ee5 Avoid returning objects with a reference parameter 2021-03-16 22:40:23 -07:00
Chris Robinson
24b030d6bd Check that CoCreateInstance succeeds 2021-03-16 16:56:11 -07:00
Chris Robinson
e5833a9a68 Fix UHJ FIR filter alignment 2021-03-15 22:11:35 -07:00
Chris Robinson
c1f0555fef Workaround mingw complaining about the %z formatter 2021-03-12 03:14:29 -08:00
Chris Robinson
ca0a6024a3 Avoid shadowing variable names 2021-03-11 04:59:58 -08:00
Chris Robinson
e43bbbd3b8 Declare the attribute counts closer to where they are 2021-03-10 02:46:01 -08:00
Chris Robinson
d750983a58 Prevent querying the capture device name from a playback device
And vice-versa.
2021-03-09 07:09:27 -08:00
Chris Robinson
5e481e7654 Don't verify and hold a device reference in alcRenderSamplesSOFT
NULL devices are still checked, but invalid non-NULL device handles will invoke
undefined behavior, as will attempting to close the device while the function
is being executed (modifying the device state while the function is being
called was inadvertently already UB, and will now remain so).

This change is solely so alcRenderSamplesSOFT can be used in a buffer callback,
and other places that need functions to be real-time safe. The verification
requires locking to access the device list, which isn't allowed in a real-time
callback.
2021-03-09 06:01:27 -08:00
Chris Robinson
e824c808a0 Add a function/extension to reopen a playback device 2021-03-09 05:52:40 -08:00
Chris Robinson
e6c7cdc1ba Initialize the new audio unit before disposing the old one 2021-03-09 02:55:01 -08:00
Chris Robinson
1d57db6836 Move the ComPtr wrapper to a common header 2021-03-08 22:47:50 -08:00
Chris Robinson
730c964029 Allow calling BackendBase::open multiple times on playback devices
It will not be called while the device is running. If the first call succeeds,
a subsequent call that happens to fail must leave the existing device state as
it was so it can be resumed.

This is a rough first pass. It will fail when trying to re-open the same device
which can only be opened once (for instance, with direct hardware access, on
hardware that doesn't do its own mixing). Some backends won't guarantee the new
device is usable until the reset() or start() call.
2021-03-08 22:29:40 -08:00
Chris Robinson
0f7ed495e1 Use a fast native type for the backup popcount 2021-03-02 22:58:36 -08:00
Chris Robinson
ffc3859a8d Use the correct lock when allocating filters 2021-03-02 19:59:33 -08:00
Chris Robinson
727503acdb Avoid making BSincPointsMax public 2021-03-01 17:48:07 -08:00
Chris Robinson
9f349c21e7 Avoid cutting off the last bsinc filter coefficient 2021-03-01 01:03:44 -08:00
Chris Robinson
6102cdae02 Avoid trying to get the app path when it fails on Windows too 2021-02-27 17:10:50 -08:00
Chris Robinson
4179633440 Avoid calling readlink on platforms that don't support it
Also don't keep trying to find the path+name if it fails the first time.
2021-02-27 13:09:43 -08:00
Chris Robinson
6e676b81d5 Avoiding cutting all bsinc resampler output at scale 0
This is mostly for the SampleConverter, used by some capture backends. When
recording at really low rates, like 5512hz, with a device capturing at a higher
rate like 44100hz or 48000hz, it hits the filter's downscaling limit and
produces pure silence.

In such cases, it's better to just accept some aliasing noise so that the app
will still get some recognizable audio. The alternative would be to scale the
desired rate by 2x, 3x, etc until it's above the bsinc limit, then take every
2nd, 3rd, etc sample of the result as if by an extra simpler resampler pass.
2021-02-24 22:21:18 -08:00
Chris Robinson
5511bffdeb Use a more appropriate epsilon for Sinc() 2021-02-24 20:17:27 -08:00
Chris Robinson
e1d62e2e77 Avoid an unnecessary loop iteration 2021-02-23 21:07:34 -08:00
Chris Robinson
5647aa4042 Adjust the bsinc filter table packing
Now each scale's filter and phase delta are interleaved for each phase index,
followed by the scale and scale+phase delta for each phase index. This ensures
no holes in the filter coefficients for the fast bsinc resampler for a given
run, while keeping the scale deltas in the same vicinity for the non-fast bsinc
resampler.
2021-02-23 18:48:02 -08:00
Chris Robinson
25d25f9a80 Remove unnecessary use of SSE2 intrinsics
The compiler is producing the same results either way, since the upper bit
results are never used.
2021-02-21 07:01:10 -08:00
Chris Robinson
28aaaab434 Store the all-pass FIR results more efficiently 2021-02-18 14:58:03 -08:00
Chris Robinson
89ddad8487 Use shifts instead of shuffles with SSE where possible 2021-02-18 14:05:50 -08:00
Chris Robinson
8fd83778b8 Add some optimization hints 2021-02-16 05:49:09 -08:00
Chris Robinson
9665171ea3 Clean up some formatting 2021-02-16 05:48:42 -08:00