184 Commits

Author SHA1 Message Date
Chris Robinson
43682a8c3e Rework source send distance attenuation handling
Specifically, AL_[EAX]REVERB_ROOM_ROLLOFF_FACTOR always applies to an inverse
distance rolloff model, where the source's AL_ROOM_ROLLOFF_FACTOR applies to
the selected distance model. Consequently, the normal distance and cone
attenuation only needs to be calculated once for all sends, with the effect's
room rolloff calculated and applied separately.
2022-03-02 11:14:59 -08:00
Chris Robinson
fbac67a6a0 Rework the initial reverb decay
The idea here is that the initial reverb decay can't become less than the dry
path distance attenuation, as the dry attenuation represents the audio that has
not yet had a chance to start reflecting in the environment. As well, the
reference distance indicates where there is no distance attenuation, with any
initial attenuation set by the environment itself.

So what we do is use the dry path attenuation as the baseline for what's mixed
to the reverb, with the decay rate indicating how much of the remaining room
(non-direct) energy attenuates with distance.

This may be over-complicating it. Other sources hint at a more typical XdB per
doubling of distance, with X varying depending on environment properties (room
size, absorbancy, etc). This could be handled by applying a normal inverse
distance attenuation model, with a rolloff factor generated from the reverb
properties (density, decay rate, etc). Will need more testing and research.
2022-03-01 15:38:04 -08:00
Chris Robinson
cadf0d1de5 Make some local constexpr variables static 2022-02-23 01:29:28 -08:00
Chris Robinson
3c9a705210 Handle AirAbsorptionGainHF as a native context property 2022-02-08 22:41:44 -08:00
Chris Robinson
256ea81dbe Combine listener and context updates 2022-02-08 20:43:05 -08:00
Chris Robinson
f63594d027 Avoid a magic number 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
f1aa10ff0b Use a bitset instead of a plain uint for flags 2021-12-23 13:43:10 -08:00
Chris Robinson
0af1b5f721 Don't do direct channels with UHJ output
Directly mixing a non-UHJ stereo signal into a UHJ stereo signal results in a
non-UHJ stereo signal. Such a mix can't be properly decoded anymore.

An option can probably be added for users that intend to listen to UHJ output
undecoded and let a stereo sound come through as-is on their speakers, but it
probably shouldn't be the default for cases where the output may be decoded
back.
2021-12-21 08:18:07 -08:00
Chris Robinson
d16b61dffb Move the effects base and effectslot to core 2021-12-17 17:13:59 -08:00
Chris Robinson
54c4bea487 Add source properties for Super Stereo
When playing a stereo format, enabling Super Stereo causes the source to behave
as a B-Format source, with a variable width control.
2021-12-15 02:01:22 -08:00
Chris Robinson
953745d386 Make an inline function to check for 2D ambisonic formats 2021-12-12 15:53:53 -08:00
Chris Robinson
01dd34f305 Add an internal Super Stereo format
It's not available as an AL buffer format (yet) since I'm not sure how to
expose it. Internally it seems fine as a separate channel configuration, but
because OpenAL combines the channel configuration and sample type, a flag may
work better there.
2021-12-11 17:50:24 -08:00
Chris Robinson
bfaa28af18 Don't clamp the distance with distance attenuation disabled 2021-11-30 22:55:17 -08:00
Chris Robinson
f1380d830a Avoid passing spans unnecessarily 2021-11-25 20:29:50 -08:00
Devin Braune
0e9ce1aa83
Fix cone angle calculation (#605) 2021-10-14 11:18:54 -07:00
Chris Robinson
92b65fa15f Avoid manually prefixing EventType_ enums
And use a better fitting type that matches how it's used
2021-10-10 05:07:31 -07:00
Chris Robinson
e3b8f8fe27 Make a construct_at method amd use it 2021-10-08 11:05:36 -07:00
Chris Robinson
fb1ad483d3 Ensure unused output channels are cleared when rendering 2021-07-24 18:15:02 -07:00
Chris Robinson
d998c03a27 Add a UHJ-specific coefficient scaling array 2021-07-13 06:31:13 -07:00
Chris Robinson
41add63728 Don't attenuate spatialized multichannel sources
It's inconsistent behavior with spatialized B-Format sources, and causes a very
apparent gain disparity between such a source on the listener compared to just
barely off-origin. It's also not something an app can easy correct for if it
doesn't want that behavior, since the source gain clamps to 1 by default. In
contrast, an app can attenuate sources as they want with little issue.
2021-06-24 08:21:25 -07:00
Chris Robinson
debb932573 Add an option to mix directly in the JACK callback 2021-06-08 10:52:37 -07:00
Chris Robinson
58a9549a58 Handle the listener position separate from the rotation matrix
It's too unstable with larger vectors. Even when the source and listener
positions are the same, floating point precision can cause noticeable rounding
errors.
2021-05-25 14:08:16 -07:00
Chris Robinson
ff380298e4 Move BufferStorage and Voice to core 2021-04-27 08:26:42 -07:00
Chris Robinson
99157f149f Move ContextBase and VoiceChange to core 2021-04-27 08:04:09 -07:00
Chris Robinson
26c8c50c26 Partially implement an extension to hold sources on disconnect
Rather than stopping voices/sources when the device becomes disconnected, the
context can be set to leave them alone. As a consequence, their state will
remain as playing and they'll keep their last known sample offset indefinately.
For applications mindful of this behavior, it will allow resetting or reopening
the device to reconnect and automatically resume where it left off.
2021-04-26 20:25:24 -07:00
Chris Robinson
22a8ebff80 Move GetChannelIdxByName and clean up some more includes 2021-04-26 08:04:50 -07:00
Chris Robinson
2479483645 Move bformatdec to core 2021-04-25 18:08:08 -07:00
Chris Robinson
8d09d03ed3 Move async_event.h to core 2021-04-25 14:29:21 -07:00
Chris Robinson
0fe38c053d Move some functions to core
And clean up more includes
2021-04-25 11:36:37 -07:00
Chris Robinson
b54bb388a3 Create a base the ALCdevice and ALCcontext structs
A base that contains the API-agnostic data, with ALCdevice and ALCcontext being
for AL-specific data.
2021-04-24 08:28:13 -07:00
Chris Robinson
65b85f7cb9 Move hrtf.cpp/h to core 2021-04-22 10:26:20 -07:00
Chris Robinson
c6dbc487b3 Rename Uhj2Encoder to UhjEncoder 2021-04-01 05:37:54 -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
727503acdb Avoid making BSincPointsMax public 2021-03-01 17:48:07 -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
dfe627133c Use spans instead of references to arrays 2021-02-06 14:39:30 -08:00
Chris Robinson
3702ee669b Add a panning "deadzone" for spatialized sources
It is now the greater of 'epsilon' (1 / 2**23) or ref_distance/1024.
2021-01-28 08:36:49 -08:00
Chris Robinson
20f5e7c1fa Avoid global constexpr arrays 2021-01-21 04:03:30 -08:00
Chris Robinson
20ef8bf390 Move cpu_caps and fpu_ctrl to core 2020-12-31 16:47:12 -08:00
Chris Robinson
04358890d9 Use a unique_ptr to hold DistanceComp data 2020-12-27 11:30:45 -08:00
Chris Robinson
cd2ebb9c3a Use a uint for a bitfield 2020-12-27 01:05:16 -08:00
Chris Robinson
54719de132 Avoid AL enums for the EffectSlot type 2020-12-26 09:21:30 -08:00
Chris Robinson
204f7d8811 Rename From2D to FromACN2D 2020-12-25 06:40:13 -08:00
Chris Robinson
efc9c146c3 Move AsyncEvent to a separate header 2020-12-16 13:58:51 -08:00
Chris Robinson
02be0149f1 Send stop events when stopping paused voices 2020-12-16 02:12:18 -08:00