Commit Graph

3359 Commits

Author SHA1 Message Date
Chris Robinson
e89c183231 Avoid including alMain.h in ringbuffer.c 2018-01-11 10:03:26 -08:00
Chris Robinson
ca9e6a4f94 Ensure NextPowerOf2 is being used correctly 2018-01-11 09:53:52 -08:00
Chris Robinson
2d2ca1d791 Remove SET_VTABLE1 2018-01-11 09:39:52 -08:00
Chris Robinson
85a8f965e5 Clean up the EffectList members and make the list size known 2018-01-11 09:34:01 -08:00
Chris Robinson
3832b25f30 Move the ringbuffer declarations to a separate header
And rename alcRing.c to ringbuffer.c for consistency.
2018-01-11 09:16:28 -08:00
Chris Robinson
15ad5245bf Move the FPU mode declarations to a separate header
Also don't use inheritance with FPUCtl.
2018-01-11 08:44:52 -08:00
Chris Robinson
8aa9e35f8c Move the config function declarations to their own header
And rename alcConfig.c to alconfig.c for consistency.
2018-01-11 07:56:54 -08:00
Chris Robinson
81b13f78ea Move the CPU capability flags to a separate header 2018-01-11 07:19:19 -08:00
Chris Robinson
9b9ec2c21a Move the compressor/limiter declarations to their own header 2018-01-11 06:50:53 -08:00
Chris Robinson
f3c9bc114c Move the polymorphic/inheritance macros to a separate header 2018-01-11 06:32:45 -08:00
Chris Robinson
ff231b42ff Reorder some loops in the equalizer and use MixSamples 2018-01-11 05:03:00 -08:00
Chris Robinson
9c33f4aea8 Use MixSamples for the dedicated and ring modulator effect output 2018-01-11 04:48:18 -08:00
Chris Robinson
f55583330b Apply the distortion gain to the mixing gains 2018-01-11 04:34:51 -08:00
Chris Robinson
2c8e4467c3 Move some HRTF structures to hrtf.h 2018-01-11 03:53:25 -08:00
Chris Robinson
15f9d15ba0 Avoid using macros to access anonymous structures 2018-01-11 03:45:23 -08:00
Chris Robinson
279799ad70 Don't return whether the bsinc filter cuts or not 2018-01-10 19:20:58 -08:00
Chris Robinson
ea6b384980 Make a function pointer static 2018-01-10 19:13:41 -08:00
Chris Robinson
ef63ec3fe9 Use one macro to handle both resample padding sizes 2018-01-09 23:55:59 -08:00
Chris Robinson
de8c5b1824 Combine the chorus and flanger processing functions
Given that they're nearly identical, it should be relatively simple to use the
same effect state to process either of them, similar to the reverbs. The big
differences seem to be the delay range (much shorter with flanger) and the
defaults.
2018-01-09 23:21:16 -08:00
Chris Robinson
9e2eb5dc23 Rename the device's temp buffer storage to be more generic 2018-01-09 22:01:46 -08:00
Chris Robinson
5d1207104a Remove standard reverb specific processing functions 2018-01-07 22:48:03 -08:00
Chris Robinson
d547f52d8f Move the UNEXPECTED macro to the main header and rename it 2018-01-07 22:20:08 -08:00
Chris Robinson
56e9cb69d3 Ensure the chorus delay and depth leave enough padding for resampling
Also use cubic resampling for the modulated tap. Applies to flanger too.
2018-01-07 21:15:18 -08:00
Chris Robinson
70973035de Use a separate function to get the cubic value 2018-01-07 17:24:29 -08:00
Chris Robinson
c423b6c8b7 Remove the sinc4 table 2018-01-07 05:58:52 -08:00
Chris Robinson
4cc1c64646 Replace the sinc4 resampler with cubic
Turns out the C version of the cubic resampler is just slightly faster than
even the SSE3 version of the FIR4 resampler. This is likely due to not using a
64KB random-access lookup table along with unaligned loads, both offseting the
gains from SSE.
2018-01-07 05:32:07 -08:00
Chris Robinson
ecd327e5e1 Test the correct offset for the loop start range 2018-01-04 21:21:48 -08:00
Chris Robinson
510bccb6ac Use the correct start point when looping 2018-01-04 20:21:46 -08:00
Chris Robinson
32330c5eef Use separate outputs for the vector reverse and scatter functions 2018-01-04 20:04:39 -08:00
Chris Robinson
e00ef16893 Avoid the modulated output tap for late reverb
And fix the output filtering. The modulation code is still there since it's
(probably) technically correct, but the interaction with the feedback loop and
filtering on the output caused improper behavior which needs to be sorted out.
2018-01-04 19:17:16 -08:00
Chris Robinson
08a4840298 Don't offset the reverb modulation sinus 2018-01-02 19:52:57 -08:00
Chris Robinson
a16f933e3a Use a float literal for float math 2018-01-02 19:44:31 -08:00
Chris Robinson
b8de63d608 Reset CompLen when loading loop repeats in the mixer 2018-01-02 19:29:58 -08:00
Chris Robinson
6dd1643a70 Avoid dereferencing a NULL pointer
Even though it's taking the address of a member, it's still technically a
derefernce and thus undefined behavior. sizeof doesn't "execute" the
expression, so derefering in it instead is fine.
2017-12-31 23:19:41 -08:00
Chris Robinson
98731bb574 Update resampler padding checks 2017-12-29 16:28:49 -08:00
Chris Robinson
27dfb7fd11 Fix up a comment 2017-12-24 20:41:20 -08:00
Chris Robinson
6457df54bb Don't make a pass-through macro for FadedDelayLineOut 2017-12-24 20:41:20 -08:00
Chris Robinson
07f3ed0419 Use linear interpolation for reverb modulation
The core LateReverb_* functions are explicitly written out now, since the
tapping and blending done by the Faded version is a bit more complex and it's
not so easy to ensure proper optimizing on the Unfaded version.
2017-12-24 20:40:53 -08:00
Chris Robinson
dabb99de8d Don't offset the chorus/flanger delay and LFO
The delay being added to the scaled LFO will ensure a proper positive result
regardless.
2017-12-24 20:40:33 -08:00
Chris Robinson
254ebe5f96 Fade between depths in the reverb modulator 2017-12-24 16:23:30 -08:00
Chris Robinson
b32a366137 Use a separate unmodulated feedback tap for reverb 2017-12-24 14:21:13 -08:00
Chris Robinson
ce74098b40 Clarify some reverb values 2017-12-23 21:13:57 -08:00
Chris Robinson
5769efe48e Reorder some global variables 2017-12-23 18:50:38 -08:00
Chris Robinson
02051ab51a Cleanup reverb modulation scaling 2017-12-23 14:18:14 -08:00
Chris Robinson
02c0620141 Add missing integer queries 2017-12-21 11:46:01 -08:00
Chris Robinson
d7895db166 Fix the lfo_offset for a 0-rate flanger 2017-12-19 19:15:34 -08:00
Chris Robinson
0f84e32520 Use MixSamples for the echo output 2017-12-19 15:13:11 -08:00
Chris Robinson
1a911be617 Update the chorus and flanger state struct less often 2017-12-19 15:12:06 -08:00
Chris Robinson
a0565dc9bb Make the echo effect only apply feedback to repeated samples 2017-12-19 14:11:37 -08:00
Chris Robinson
52569ef562 Fade gains in the chorus and flanger output 2017-12-19 13:52:05 -08:00
Chris Robinson
661bd054aa Use a single delay line for chorus feedback on a fixed tap
The outputs themselves use a variale-delay tap, but using a separate fixed-
delay tap on the feedback helps improve the perceived "wobble" with sustained
notes. This also applies to the flanger effect.
2017-12-18 13:41:12 -08:00
Chris Robinson
eee4aca40b Apply chorus and flanger feedback on the tapped re-feed 2017-12-17 22:14:20 -08:00
Chris Robinson
04cf832fe6 Use the selected mixer for chorus and flanger output 2017-12-17 22:10:58 -08:00
Chris Robinson
2346426b6e Make MixSamples non-static global 2017-12-17 21:48:07 -08:00
Chris Robinson
8253014fe9 Fix some types to make MSVC happy 2017-12-17 15:56:30 -08:00
Chris Robinson
ebd42ab619 Mix multiple buffers in each buffer list item
Basically now this just relies on being able to specify composited buffers.
2017-12-16 11:34:52 -08:00
Chris Robinson
b10780f119 Pre-clear the source temp buffer and accumulate into it 2017-12-16 09:41:27 -08:00
Chris Robinson
d657c51be8 Rename SrcDataSize to be less confusing 2017-12-16 08:58:46 -08:00
Chris Robinson
30007263e5 Allow storing multiple buffers in a ALbufferlistitem
This will be to allow buffer layering, multiple buffers of the same format and
sample rate that are mixed together prior to resampling, filtering, and
panning. This will allow composing sounds from individual components that can
be swapped around on different invocations (e.g. layer SoundA and SoundB on one
instance and SoundA and SoundC on a different instance for a slightly different
sound, then just SoundA for a third instance, and so on). The longest buffer
within the list item determines the length of the list item.

More work needs to be done to fully support it, namely the ability to specity
multiple buffers to layer for static and streaming sources. Also the behavior
of loop points for layered static sources should be worked out. Should also
consider allowing each layer to have a sample offset.
2017-12-15 22:59:51 -08:00
Chris Robinson
ff3d31e17f Update flanger with the same changes as chorus 2017-12-15 17:35:46 -08:00
Chris Robinson
d281b25723 Use a separate LFO offset in the chorus effect
Given that the LFO range is not a power-of-two, it won't correctly wrap on
overflow.
2017-12-15 17:26:03 -08:00
Chris Robinson
2a3b5ab9e9 Use linear interpolation for the chorus delay output 2017-12-15 16:50:06 -08:00
Chris Robinson
5993ef0baa It's getFactory that may be NULL, not its return value... 2017-11-26 09:59:55 -08:00
Chris Robinson
d96be76875 Don't probe a NULL backend factory 2017-11-26 09:53:26 -08:00
Chris Robinson
7c88e4a16b Properly initialize with the default distance model 2017-10-29 18:25:04 -07:00
Chris Robinson
eac0539ea0 Enable NFC filters for HRTF
Only applies to the Ambisonic mix (basic HRTF rendering, or B-Format buffers).
2017-10-23 13:30:01 -07:00
Chris Robinson
b82d2cf055 Store the HRTF distance in the Hrtf handle 2017-10-23 13:26:35 -07:00
Chris Robinson
0349bcc500 Update mhr format for 24-bit, multi-field, stereo measurements
Currently only single field HRTFs are supported, but the format now allows up
to 16.
2017-10-22 15:36:42 -07:00
Chris Robinson
5ec11a017c Add casts for assigning the SSE bsinc filter pointers 2017-10-07 15:28:35 -07:00
Chris Robinson
296abf03de Avoid a separate function to query ambisonic mode support
Now FuMa and ACN channel orders are required, as are FuMa, SN3D, and N3D
normalization schemes. An integer query (alcGetIntegerv) is added for the
maximum ambisonic order.
2017-09-27 11:58:36 -07:00
Chris Robinson
1ab8902621 Re-update effect slots when context properties change
Also keep all free property update structs together in the context instead of
per-object.
2017-09-27 11:13:18 -07:00
Chris Robinson
fd70b0bca6 Don't update context and listener props unnecessarily 2017-09-27 09:36:34 -07:00
Chris Robinson
101d284a18 Update the context state properties separately
The context state properties are less likely to change compared to the listener
state, and future changes may prefer more infrequent updates to the context
state.

Note that this puts the MetersPerUnit in as a context state, even though it's
handled through the listener functions. Considering the infrequency that it's
updated at (generally set just once for the context's lifetime), it makes more
sense to put it there than with the more frequently updated listener
properties. The aforementioned future changes would also prefer MetersPerUnit
to not be updated unnecessarily.
2017-09-27 08:55:42 -07:00
Chris Robinson
c5a917b401 Restore the original JACK message callback when possible 2017-09-23 03:56:45 -07:00
Chris Robinson
369f52a0d7 Add an option to ignore the app's speed of sound for reverb decay 2017-09-22 05:42:04 -07:00
kcat
9007b77355 Merge pull request #149 from dscharrer/master
Fix build on Gentoo FreeBSD with freebsd-lib 9.1
2017-09-21 10:28:04 -07:00
Chris Robinson
fc9cb2fbd8 Use the app-specified speed of sound for reverb decay
Specifically, the initial reverb decay as determined by the source distance,
and the reverb decayhf limit from air absorption.
2017-09-21 10:20:59 -07:00
Daniel Scharrer
46b9efc5a2 Fix build on Gentoo FreeBSD with freebsd-lib 9.1 2017-09-21 17:37:10 +02:00
Chris Robinson
90cedbea49 Pass the context to the auxiliary effect update method 2017-09-21 05:42:35 -07:00
Chris Robinson
bc386af5c5 Manually save and restore the FPU rounding mode on Windows
Apparently there is a bug with at least MinGW-W64 where fegetenv and fesetenv
do not properly save and restore the FPU rounding mode, resulting in the
rounding mode remaining as round-to-zero after certain function calls. I do not
know if this also affects MSVC, but better safe than sorry for now.
2017-09-19 03:42:00 -07:00
Chris Robinson
cd15b1775e Avoid some extraneous load calls
This likely doesn't change anything given a working optimizer, but it cleans up
the code some.
2017-08-30 11:30:19 -07:00
Chris Robinson
2916efee21 Automatically generate the bsinc table when building
This makes bsincgen a native tool like bin2h, so it can run automatically when
compiling.
2017-08-28 10:31:23 -07:00
Chris Robinson
6c367cad6e Ensure some macros have the correct size 2017-08-28 05:56:57 -07:00
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
9ea32713b5 Constify some pointers 2017-08-23 23:01:11 -07:00
Chris Robinson
921a820867 Meters per unit can't be 0 2017-08-21 00:30:14 -07:00
Chris Robinson
e7c4681e9a 0 meters per unit is invalid 2017-08-21 00:27:52 -07:00
Chris Robinson
3e56e7f562 Properly clear the extra ChannelsPerOrder entries 2017-08-19 23:52:24 -07:00
Chris Robinson
5f50d085ad Pass the filter entry to apply to resample_fir4 2017-08-18 19:20:30 -07:00
Chris Robinson
5048956ff0 Keep bsinc filter quality more consistent between scales
This generates the filters using the proper size and scale. The 'a' divisor
should represent the +/- sample range (and thus be a whole number), with the
number of sample points being double that. Increasing the filter size to a
multiple of 4 (for SIMD) can be done by padding in 0s afterward.
2017-08-17 23:21:41 -07:00
Chris Robinson
9fd3e5f529 Correct the bsinc filter order
Despite the claim that it was an 11th order filter, the transition width was
generated by specifying 12th order. A 12th order filter would need 14 sample
points rather than the 12 it had.
2017-08-17 05:51:18 -07:00
Chris Robinson
e0408d8edf Make the sinc4 table static 2017-08-16 18:19:04 -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
f9c09cc845 Simplify bsinc filter storage in the filter state
Rather than storing individual pointers to filter, scale delta, phase delta,
and scale  phase delta entries, per phase index, the new table layout makes it
trivial to access the per-phase filter and delta entries given the base offset
and coefficient count.
2017-08-16 02:45:25 -07:00
Chris Robinson
520dd5c779 Make the bsinc table layout more efficient
The old layout separated filters, scale deltas, phase deltas, and scale phase
deltas into separate segments that each contained a numbers of scale and phase
entries, Since processing a sample needed a filter and one of each delta entry
relating to a particular scale and phase, the memory needed would be spread
across the whole table. And since subsequent samples would use a different
phase, it would jump around the table a whole lot as well.

The new layout packs the data in a way more consistent with its use. The
filters, scale deltas, phase deltas, and scale phase deltas are interleaved,
such that for a particular scale and phase, the filter and delta entries used
are contiguous. And the phase entries for a particular scale are kept together,
so the ~500 to ~1000 samples processed per source update stay within the same
3KB to 6KB area of the 70+KB table, which is much more cache friendly.
2017-08-16 02:05:10 -07:00
Chris Robinson
4dd53ab942 Keep bsinc info together in a struct 2017-08-15 04:15:50 -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
2987c87645 Check the right size for the in-progress mhr update 2017-08-09 20:42:22 -07:00