78 Commits

Author SHA1 Message Date
Chris Robinson
78251fd7e6 Fix voices being forced to update without valid properties
When starting a voice, the source ID was set before its first update struct was
provided, creating a small window where a listener or effect slot update could
force a voice to update without it having any valid properties to update with.
Supplying the update struct first would create a different race, where the
mixer could see a voice without a source but with an update struct, causing the
update struct to be 'freed' without being applied.

The fix here is to provide the update struct before setting the source ID, and
change the mixer to ignore update structs for voices without a source ID. This
can pseudo-orphan the updates that get set on a voice just as it stops, leaving
the struct unusable until the voice is used again, or the voice gets deleted
which will clear it. But it allows the update struct to stay in place and get
applied once the voice gets a source ID.
2020-03-04 23:18:05 -08:00
Chris Robinson
e7405f7801 Use a new voice state to indicate a pending source offset change 2020-03-04 10:16:59 -08:00
Chris Robinson
3e1a2c0f77 Use an intrusive_ptr for the device's HrtfStore 2020-03-01 17:16:09 -08:00
Chris Robinson
4555b74bd7 Use a VoiceChange object to change the offset of a playing source 2020-02-26 03:52:40 -08:00
Chris Robinson
872096958b Rename the voice's PendingStop to PendingChange 2020-02-26 01:48:59 -08:00
Chris Robinson
90d45984dc Simplify replaying a source 2020-02-23 21:40:54 -08:00
Chris Robinson
4660819f6a Avoid a single function call in a loop 2020-02-21 22:17:29 -08:00
Chris Robinson
a8162a77c2 Use an array of ALvoice pointers for the active voices
This allows growing the array atomically with the mixer since the ALvoice
objects themselves don't move, and a new larger array of them can be swapped in
without blocking the mixer.
2020-02-21 20:14:28 -08:00
Chris Robinson
0694df9014 Handle playing and pausing with VoiceChanges 2020-02-21 04:29:32 -08:00
Chris Robinson
9b43327f56 Asynchronously stop and rewind voices 2020-02-20 23:53:56 -08:00
Chris Robinson
bdb8ef22b0 Asynchronously stop voices if its source is being deleted 2020-02-20 22:50:37 -08:00
Chris Robinson
6ebdf3ab62 Use a triplet struct array instead of separate arrays 2020-02-09 14:25:20 -08:00
Chris Robinson
f2bc24f761 Consistently use distant wavefronts for 0 distance 2020-02-08 22:39:32 -08:00
Chris Robinson
85395b23a4 Clear voice target gains earlier 2020-02-08 18:10:59 -08:00
Chris Robinson
ebb1aaa06d Make sure stereo angles are kept in-range. 2020-01-31 11:11:06 -08:00
Chris Robinson
3904289af7 Only sort active effect slots as needed 2020-01-18 18:53:58 -08:00
Chris Robinson
75a58ae333 Simplify appending delayed samples 2020-01-14 12:13:00 -08:00
Chris Robinson
5324bdb908 Signal the event handler only once per update 2020-01-14 10:39:41 -08:00
Chris Robinson
6608e5dd9f Make sure unassociated voices give back their update structs 2020-01-08 07:31:01 -08:00
Chris Robinson
cdd24c7d01 Combine identical arrays 2020-01-04 00:59:49 -08:00
Chris Robinson
c1cf10f508 Handle downmixing for mono output 2019-12-29 20:35:47 -08:00
Chris Robinson
9ac8f25a05 Ignore direct channels for mono and B-Format buffers 2019-12-29 19:17:29 -08:00
Chris Robinson
701d43b41e Start a new extension for a new direct_channels state
So existing behavior remains consistent for anything that needs it, and new
behavior is opt-in.
2019-12-28 11:33:19 -08:00
Chris Robinson
3b3d3d3a03 Use a span for the band-splitter input 2019-12-25 21:48:58 -08:00
Chris Robinson
28e68d03d3 Fix a shadowed parameter warning 2019-12-23 23:13:45 -08:00
Chris Robinson
bff6696814 Avoid reading a struct field twice 2019-12-23 23:00:59 -08:00
Chris Robinson
2e6a55a87c Handle padding between device sample frames
The padding must be constant and sample type aligned (e.g. some fixed multiple
of two bytes between the start of two consecutive frames for 16-bit output).
The intent is to always have the ability for stereo output with WASAPI even if
the device has some other unsupported configuration, as long as front-left and
front-right exist.
2019-12-21 20:43:46 -08:00
Chris Robinson
54e7f48df9 Use unique setters for biquad filter parameters
One for whether a slope parameter is used, and one for bandwidth.
2019-12-21 02:02:57 -08:00
Chris Robinson
274fd36edd Improve gain/hf/lf packing when processing voice updates 2019-12-21 00:48:58 -08:00
Chris Robinson
4634002104 Remix missing channels with direct channels enabled
Instead of dropping them.
2019-12-19 04:38:34 -08:00
Chris Robinson
6480c2c854 Don't apply direct channels with mono output 2019-12-18 23:29:52 -08:00
Chris Robinson
5e35f73cad Don't process direct channel sources with attenuation 2019-12-17 22:40:49 -08:00
Chris Robinson
a8de1570e9 Update a comment since B-Format input isn't always FuMa 2019-12-17 22:25:00 -08:00
Chris Robinson
466c6faeb5 Correctly scale spatialized B-Format sources 2019-12-17 22:20:38 -08:00
Chris Robinson
0a65ed2190 Use normal panning for B-Format output
It can never work since it only uses auxiliary channel labels.
2019-12-17 22:12:47 -08:00
Chris Robinson
2215a4072c Don't apply stereo panning with direct channels enabled 2019-12-17 21:49:58 -08:00
Chris Robinson
38037e29ba Handle the buffer's ambisonic properties 2019-12-02 12:50:18 -08:00
Chris Robinson
58e4d643d3 Make B-Format rotation more robust
This should now handle higher orders, and can be easily extended to non-FuMa
layouts and scalings.
2019-12-01 22:33:41 -08:00
Chris Robinson
0cba99ed1b Avoid static constexpr for arrays iterated over at run-time 2019-10-25 01:43:23 -07:00
Chris Robinson
33fd1f9efd Use better types for some specific sizes 2019-10-13 09:37:07 -07:00
Chris Robinson
acb6baad90 Use std::array instead of plain arrays in a couple places 2019-10-05 21:23:31 -07:00
Chris Robinson
64e2c377d8 Move ALvoice from alu.h to a separate header 2019-10-02 16:53:23 -07:00
Chris Robinson
00250042c8 Check MAX_RESAMPLER_PADDING properly to ensure it's large enough 2019-09-28 19:14:27 -07:00
Chris Robinson
cbc00bcffe Combine two function calls into one 2019-09-28 03:42:17 -07:00
Chris Robinson
882b4acae8 Add "fast" variants for the bsinc resamplers
This simply omits the scale factor from the filter, similar to how up-sampling
does. The consequence of this is less smooth transitions when ramping the
pitch while down-sampling, but otherwise behaves fine.
2019-09-28 01:58:29 -07:00
Chris Robinson
9b64e5e0db Implement a "fast" bsinc path
This takes advantage of the fact than when increment <= 1 (when not down-
sampling), the scale factor is always 0. As a result, the scale and scale-phase
deltas never contribute to the filtered output. Removing those multiply+add
operations cuts half of the work done by the inner loop.

Sounds that do need to down-sample (when played with a high pitch, or is 48khz
on 44.1khz output, for example), still go through the normal bsinc process.
2019-09-26 19:24:29 -07:00
Chris Robinson
24db8a3f4b Make the resampler type an enum class 2019-09-22 21:19:19 -07:00
Chris Robinson
1da7512628 Avoid an unnecessary multiply 2019-09-16 21:49:06 -07:00
Chris Robinson
899a414591 Remove the last uses of the system's str[n]casecmp 2019-09-16 15:10:36 -07:00
Chris Robinson
10a841cd7e Avoid an unused variable 2019-09-16 14:10:48 -07:00