Commit Graph

322 Commits

Author SHA1 Message Date
Chris Robinson
a4d357de06 Add a higher quality bsinc resampler using 24 sample points
This improves the transition width, allowing more of the higher frequencies
remain audible. It would be preferrable to have an upper limit of 32 points
instead of 48, to reduce the overall table size and the CPU cost for down-
sampling.
2017-08-27 10:16:36 -07:00
Chris Robinson
561e95528f Rename the bsinc resampler to bsinc12 2017-08-25 05:52:19 -07:00
Chris Robinson
5008024e73 Store the sinc4 table in the filter state
Also rename the resampler functions to remove the unnecessary '32' token.
2017-08-16 18:09:53 -07:00
Chris Robinson
0604b00360 Check the source type once when mixing 2017-08-14 22:58:24 -07:00
Chris Robinson
a931314d3f Add restrict to a few more parameters 2017-08-10 00:14:55 -07:00
Chris Robinson
8f2bbc434c Use a macro to apply NFC filtered mixes instead of a loop 2017-06-26 11:19:27 -07:00
Chris Robinson
49e5c53591 Reduce the amount of variables that hold the same value 2017-05-21 03:47:52 -07:00
Chris Robinson
d82e3be8f7 Increase the HRTF transition to 128 samples 2017-05-05 04:54:07 -07:00
Chris Robinson
444e9563b3 Add a mixing function to blend HRIRs
This is a bit more efficient than calling the normal HRTF mixing function
twice, and helps solve the problem of the values generated from convolution not
being consistent with the new HRIR.
2017-05-03 03:29:21 -07:00
Chris Robinson
66f9640787 Remove a duplicate check 2017-05-02 07:34:28 -07:00
Chris Robinson
1e5334176e Rename VOICE_IS_HRTF to VOICE_HAS_HRTF 2017-05-02 04:25:08 -07:00
Chris Robinson
2f8d597f4e Rename 'moving' flag to 'fading' 2017-05-02 04:09:01 -07:00
Chris Robinson
dc25370063 Fade HRTF coefficients over 64 samples at most
This greatly improves HRTF performance since the dual-mix only applies to the
64-sample coefficient transition. So rather than doubling the full mix, it only
doubles 64 samples out of the full mix.
2017-04-28 10:05:57 -07:00
Chris Robinson
ad782c0000 Skip mixing the fade out step when starting silent
Unfortunately it can't skip mixing the fade in when going to silence because
the history needs to be up to date.
2017-04-25 22:10:27 -07:00
Chris Robinson
26b49c54af Store the resampler as part of the source 2017-04-21 00:06:40 -07:00
Chris Robinson
1e8ea59564 Make the default resampler a variable 2017-04-20 23:21:46 -07:00
Chris Robinson
7776ebcedc Try NEON mixers before SSE 2017-04-20 20:58:32 -07:00
Chris Robinson
5dcbb8db38 Make the buffer list next pointer atomic 2017-04-19 19:54:17 -07:00
Chris Robinson
de62ab97e9 Store the source queue head in the voice to signify looping
This removes the need to access a couple more source fields in the mixer, and
also makes the looping and queue fields non-atomic.
2017-04-18 00:58:33 -07:00
Chris Robinson
6cc69c8d94 Add a sample converter
This is intended to do conversions for interleaved samples, and supports
changing from one DevFmtType to another as well as resampling. It does not
handle remixing channels.

The mixer is more optimized to use the resampling functions directly. However,
this should prove useful for recording with certain backends that won't do the
conversion themselves.
2017-04-10 09:26:06 -07:00
Chris Robinson
aef774a7a0 Handle the source offset fraction as an ALsizei 2017-04-08 14:29:08 -07:00
Chris Robinson
319d097198 Pre-compute the sinc4 resampler coefficient table 2017-04-08 13:43:19 -07:00
Chris Robinson
36f7dda1ca Remove another reference to the sinc8 resampler 2017-04-07 03:57:40 -07:00
Chris Robinson
ac8b4aa5f6 Convert integer samples to float using a power-of-2 divisor
This should cut down on unnecessary quantization noise (however minor) for 8-
and 16-bit samples. Unfortunately a power-of-2 multiple can't be used as easily
for converting float samples to integer, due to integer types having a non-
power-of-2 maximum amplitude (it'd require more per-sample clamping).
2017-03-31 06:54:46 -07:00
Chris Robinson
9f4e47d7be Fix HRTF interpolated gain calculation 2017-03-26 02:44:34 -07:00
Chris Robinson
56428cdb74 Use a loop to apply NFC filters 2017-03-25 23:55:44 -07:00
Chris Robinson
42bcf0870d Make DataPosInt an ALsizei 2017-03-20 19:22:41 -07:00
Chris Robinson
d7d9ad806a Use proper bools for boolean states 2017-03-20 16:53:41 -07:00
Chris Robinson
32d521d79c Check usability of MixHrtf_Neon before MixHrtf_SSE 2017-03-14 19:16:59 -07:00
Chris Robinson
7b4645f5f8 Store the HRIR coeff pointer and delays directly in MixHrtfParams 2017-03-12 06:58:27 -07:00
Chris Robinson
96aaab9366 Rework HRTF coefficient fading
This improves fading between HRIRs as sources pan around. In particular, it
improves the issue with individual coefficients having various rounding errors
in the stepping values, as well as issues with interpolating delay values.

It does this by doing two mixing passes for each source. First using the last
coefficients that fade to silence, and then again using the new coefficients
that fade from silence. When added together, it creates a linear fade from one
to the other. Additionally, the gain is applied separately so the individual
coefficients don't step with rounding errors. Although this does increase CPU
cost since it's doing two mixes per source, each mix is a bit cheaper now since
the stepping is simplified to a single gain value, and the overall quality is
improved.
2017-03-11 18:04:06 -08:00
Chris Robinson
feffe1e81a Make the voice's 'moving' state a bitflag 2017-03-11 06:26:05 -08:00
Chris Robinson
6b4b00e462 Dynamically allocate the device's HRTF state 2017-03-10 10:47:43 -08:00
Chris Robinson
583d431947 Implement NFC filters for Ambisonic rendering
NFC filters currently only work when rendering to ambisonic buffers, which
includes HQ rendering and ambisonic output. There are two new config options:
'decoder/nfc' (default on) enables or disables use of NFC filters globally, and
'decoder/nfc-ref-delay' (default 0) specifies the reference delay parameter for
NFC-HOA rendering with ambisonic output (a value of 0 disables NFC).

Currently, NFC filters rely on having an appropriate value set for
AL_METERS_PER_UNIT to get the correct scaling. HQ rendering uses the averaged
speaker distances as a control/reference, and currently doesn't correct for
individual speaker distances (if the speakers are all equidistant, this is
fine, otherwise per-speaker correction should be done as well).
2017-03-10 04:35:32 -08:00
Chris Robinson
190120dfd7 Store the channel count and sample size in the voice 2017-03-07 00:19:40 -08:00
Chris Robinson
bc0096365e Don't modify the source state in the mixer 2017-03-07 00:19:40 -08:00
Chris Robinson
5c859af24e Move the current buffer queue entry and play position to the voice
This has a couple behavioral changes. First and biggest is that querying
AL_BUFFERS_PROCESSED from a source will always return all buffers processed
when in an AL_STOPPED state. Previously all buffers would be set as processed
when first becoming stopped, but newly queued buffers would *not* be indicated
as processed. That old behavior was not compliant with the spec, which
unequivocally states "On a source in the AL_STOPPED state, all buffers are
processed."

Secondly, querying AL_BUFFER on an AL_STREAMING source will now always return
0. Previously it would return the current "active" buffer in the queue, but
there's no basis for that in the spec.
2017-02-27 15:35:15 -08:00
Chris Robinson
513c18fdc4 Ensure a non-playing or -paused source does not use a mixing voice 2017-02-25 18:10:09 -08:00
Chris Robinson
864d5387dd Dynamically allocate the ALsource Send[] array 2017-02-21 16:31:59 -08:00
Chris Robinson
d45dd9c668 Remove the sinc8 resampler option
Perf shows less than 1 percent CPU difference from the higher quality bsinc
resampler, but uses almost twice as much memory (a 128KB lookup table).
2017-02-19 16:45:17 -08:00
Chris Robinson
909193a345 Reorganize ALvoice members
This places the Send[] array at the end of the struct, making it easier to
handle dynamically.
2017-02-15 17:40:26 -08:00
Chris Robinson
0d19a20901 Make the source state atomic
Since it's modified by the mixer when playback is ended, a plain struct member
isn't safe.
2017-02-13 21:18:18 -08:00
Chris Robinson
0324712540 Put BsincState in a generic union 2017-02-13 11:29:32 -08:00
Chris Robinson
27695e2b24 Add NEON-enhanced resamplers 2017-02-12 21:03:30 -08:00
Chris Robinson
e8ac0e5bfd Replace some ALvoid with void 2017-01-18 07:19:43 -08:00
Chris Robinson
d2e5aa79dd Use ALsizei in more places 2017-01-18 07:13:23 -08:00
Chris Robinson
ba0944af9b Pass the left and right buffers to the hrtf mixers directly 2017-01-17 16:49:26 -08:00
Chris Robinson
325a49975a Use ALsizei and ALint for sizes and offsets with resamplers and filters 2017-01-16 08:54:30 -08:00
Chris Robinson
cbb796bf31 Use ALsizei for sizes and offsets with the mixer
Unsigned 32-bit offsets actually have some potential overhead on 64-bit targets
for pointer/array accesses due to rules on integer wrapping. No idea how much
impact it has in practice, but it's nice to be correct about it.
2017-01-16 08:06:25 -08:00
Chris Robinson
8f581c0e66 Use separate macros for atomics that don't take a memory order 2016-12-20 20:49:37 -08:00