Commit Graph

348 Commits

Author SHA1 Message Date
Chris Robinson
91278608c5 Add some spacing 2010-08-03 01:44:52 -07:00
Chris Robinson
8e2d765671 Move active source iteration to aluMixData 2010-08-03 01:09:02 -07:00
Chris Robinson
2af39e51f8 Separate speaker/panning initialization into another source file 2010-08-03 00:21:36 -07:00
Chris Robinson
41e2c41ecc Combine duplicate lines into the mixing macro 2010-07-31 21:09:59 -07:00
Chris Robinson
30108c7855 Remove an unnecessary variable 2010-07-31 19:14:27 -07:00
Chris Robinson
7eb124d99c Keep count of the number of samples played 2010-07-22 08:11:44 -07:00
Chris Robinson
6db3463d17 Fix backslash alignment for the single-channel mixer macro 2010-07-06 16:32:58 -07:00
Chris Robinson
7f6df7695c Use an array of active sources when mixing
Prevents iterating over all allocated sources during mixing updates
2010-06-06 00:17:50 -07:00
Chris Robinson
90db244b5f Skip mixing after checking looping validity 2010-06-03 03:58:04 -07:00
Chris Robinson
8cfac7c6b8 Don't bother storing the loop points in the source 2010-05-24 01:07:13 -07:00
Chris Robinson
6dab9d54d1 Use the loop start when filling in padding data for looping sources 2010-05-13 06:52:44 -07:00
Chris Robinson
7ed5d12717 Pay attention to the source loop points 2010-05-13 04:53:21 -07:00
Chris Robinson
23b2c1f902 Only use a modulo to loop when the source is static 2010-05-13 02:12:50 -07:00
Chris Robinson
af4faaf666 Use a UIntMap for the effect slot list 2010-05-12 02:20:14 -07:00
Chris Robinson
d678f1d88b Store looping locally when mixing a source 2010-05-12 00:38:04 -07:00
Chris Robinson
099c2f3593 Use a simple loop to set multi-channel dry gains 2010-05-09 22:06:10 -07:00
Chris Robinson
0378422fcb Use a map to store sources and buffers
And do a lookup using a binary search instead of linear
2010-05-01 19:59:41 -07:00
Chris Robinson
5d7815beed Only apply ambient gain to available output channels 2010-04-27 11:39:54 -07:00
Chris Robinson
110be7f500 Add an option to scale the output mix 2010-04-23 07:54:43 -07:00
Chris Robinson
a04dac670e Make stereo duplication a property of the device
Further, don't use it with mono/stereo output
2010-04-20 03:57:40 -07:00
Chris Robinson
fc2473f826 Translate the source position separately
This is to handle the case where an app specifies the same values for the
source and listener, and expects centered panning. This fails due to floating-
point errors in the matrix, causing the result to be ever-so-slightly off of 0.

This error would normally be hidden by the position normalization, which will
not lengthen a distance shorter than the reference distance so the panning
would be nearly imperceptible. But that also fails if the reference distance
is set to 0, causing the position to expand to a full unit.

Keep the 4x4 matrix calculations, however. It will still be useful for the
requested listener matrix extension.
2010-04-16 02:09:53 -07:00
Chris Robinson
000d848f0b Return immediately when no layout is specified 2010-04-11 23:03:36 -07:00
Chris Robinson
3c5007352e More type fixes 2010-04-11 20:17:43 -07:00
Chris Robinson
e0fa497948 Use a linear scaling when sending multi-channel sources to auxiliary slots 2010-04-11 15:20:46 -07:00
Chris Robinson
f082c73539 Use proper types for some variables 2010-04-11 14:33:22 -07:00
Chris Robinson
d4f8bd665f Only consider output speakers for the panning LUT 2010-04-11 14:23:10 -07:00
Chris Robinson
488ec612bb Avoid hard-coding the channel count 2010-04-09 14:21:47 -07:00
Chris Robinson
484702a2e5 Get the speaker arrangement before setting up the channel matrix 2010-04-09 12:27:30 -07:00
Chris Robinson
371058fb9e Re-enable stereo duplication 2010-04-08 23:00:14 -07:00
Chris Robinson
97b00670f5 Use the proper type for the speaker-to-channel map 2010-04-08 18:05:24 -07:00
Chris Robinson
aace50ebf4 Store the panning LUT in the device 2010-04-08 15:58:11 -07:00
Chris Robinson
49201e892b Use a single layout for the virtual speakers
The downmix should probably be improved to take the angles into account
2010-04-08 15:41:32 -07:00
Chris Robinson
068c0076af Set the device channel matrix when the device is reset 2010-04-08 15:02:03 -07:00
Chris Robinson
37c93a6ad8 Always mix internally at 8.1
The channels are remixed when writing to the output buffer. Stereo duplication
is currently broken, but this can be restored later
2010-04-08 14:47:12 -07:00
Chris Robinson
1b1c76da34 Invert device channel map array 2010-04-08 13:11:21 -07:00
Chris Robinson
eea23a012a Relax circular layout requirement 2010-03-20 00:54:44 -07:00
Chris Robinson
ec917e8e2f Rename some struct members for consistency 2010-03-16 15:37:41 -07:00
Chris Robinson
08b1bed38b Remove a couple incorrect comments 2010-03-10 07:16:53 -08:00
Chris Robinson
1f10195c47 Use powf when available 2010-03-07 22:12:33 -08:00
Chris Robinson
931f5875cd Fix speaker angle fixup 2010-01-12 09:11:46 -08:00
Chris Robinson
505f61ff43 Properly trace the invalid speaker angle 2010-01-12 08:50:32 -08:00
Chris Robinson
574792d2e1 Fix Windows compilation 2010-01-11 23:47:03 -08:00
Chris Robinson
ab2eb5a603 Check buffer size when copying padding instead of the data pointer 2010-01-11 10:58:33 -08:00
Chris Robinson
3d7f925d52 Add helpful values to the resampler enum 2010-01-11 07:02:29 -08:00
Chris Robinson
93b584ff84 Add a cosine resampler 2010-01-11 06:19:54 -08:00
Chris Robinson
705849ca73 Add an option for point resampling 2010-01-11 05:37:20 -08:00
Chris Robinson
1a57f095e8 Hold global lock during mixing only when iterating device contexts 2010-01-11 03:57:49 -08:00
Chris Robinson
a0ef7be9a5 Improve layout parsing and allow using long names for speakers 2009-12-28 11:49:55 -08:00
Chris Robinson
7f0c6629b9 Use a 64-bit value to scale potentially-large numbers 2009-12-24 15:41:45 -08:00
Chris Robinson
ddfad996a9 Don't render mono as stereo 2009-12-21 02:59:30 -08:00
Chris Robinson
d786f99094 Scale samples down when converting stereo to mono 2009-12-21 02:27:25 -08:00
Chris Robinson
008563450c Improve some indentations 2009-12-20 21:50:00 -08:00
Chris Robinson
69c238a2e6 Properly retrieve the device frequency 2009-12-20 21:19:57 -08:00
Chris Robinson
56cc038603 Improve initial decay calculations for sends to reverb 2009-12-10 18:37:36 -08:00
Chris Robinson
4c83c689a8 Use the specified reverb air absorption value for wet sends 2009-12-10 18:22:45 -08:00
Chris Robinson
368ef1cea9 Store the source state locally after making sure it needs mixing 2009-12-09 11:56:53 -08:00
Chris Robinson
656a406377 Use an inline function to calculate the low-pass filter coefficient 2009-12-09 07:21:59 -08:00
Chris Robinson
5fcd6cc510 Split non-attenuated source calculations into a separate function 2009-12-09 07:02:26 -08:00
Chris Robinson
84d2d623b6 Add a head-dampening option
This simulates occlusion of the player's head for sounds coming from behind,
when outputing to mono or stereo
2009-12-08 14:18:07 -08:00
Chris Robinson
1694e5bd12 Store the original pre-clamped distance instead of re-computing it 2009-12-08 10:12:18 -08:00
Chris Robinson
5170e251f9 Use the correct wet filter history offset 2009-12-07 12:45:23 -08:00
Chris Robinson
4697e946d3 Internally store 32-bit float buffer data, and mix accordingly 2009-12-07 10:35:30 -08:00
Chris Robinson
8138446b8c Restrict setting some wet path values to active sends only 2009-12-06 03:59:12 -08:00
Chris Robinson
b5270e0bb3 Use a channel-map to specify the output device channel order 2009-12-02 04:03:51 -08:00
Chris Robinson
d5889a941f Clamp dry gain after cone attenuation is applied 2009-12-01 03:32:04 -08:00
Chris Robinson
98ce1d14c1 Update AL_EXTX_source_distance_model to require explicit enabling
The in-progress spec has been updated to reflect this
2009-11-27 20:05:21 -08:00
Chris Robinson
69f9ab88b9 Send multi-channel sources to auxiliary effect slots
They are downmixed to mono using a volume-preserving scalar, and passed
through a 1-pole low-pass filter (not chained)
2009-11-26 00:39:32 -08:00
Chris Robinson
658923175f Update source parameters only when they need changing 2009-11-25 16:21:47 -08:00
Chris Robinson
877f4340ba Base air absorption on distance attenuation, try 2 2009-11-24 21:19:11 -08:00
Chris Robinson
35a9ccb41f Revert "Base air absorption on the distance attenuation"
This reverts commit c7c2f9385f.

Fundamentally wrong. The -6dB rolloff is every doubling of the distance, and
the (scaled) -0.05dB rolloff is supposed to be every additional unit.
2009-11-24 01:39:34 -08:00
Chris Robinson
c7c2f9385f Base air absorption on the distance attenuation 2009-11-23 16:25:37 -08:00
Chris Robinson
cfb30fe975 Use a 4x4 matrix to transform coordinates 2009-11-23 04:13:51 -08:00
Chris Robinson
2d1b378ef2 Transform all relevant vectors for converting world-space to listener-space 2009-11-22 22:36:20 -08:00
Chris Robinson
fe37f1968d Better approximate the wet attenuation model for reverb 2009-11-19 11:06:41 -08:00
Chris Robinson
5f3c07ca3b Apply the reverb room rolloff factor for EAX reverb too 2009-11-19 10:29:10 -08:00
Chris Robinson
ff8e09495d Move aluCart2LUTpos to alu.h 2009-11-19 09:24:35 -08:00
Chris Robinson
fb258a7416 Properly lock the device when setting it disconnected 2009-11-01 09:29:20 -08:00
Chris Robinson
a3fcd67a82 Remove some unneeded buffer fields, make padding a constant amount 2009-10-25 08:31:28 -07:00
Chris Robinson
fe3a43e2d4 Remove the format and frequency from the source, get them manually 2009-10-25 06:26:19 -07:00
Chris Robinson
e095047b02 Small fixups 2009-10-25 06:16:21 -07:00
Chris Robinson
31a106344f Calculate more store only once per loop 2009-10-25 05:34:47 -07:00
Chris Robinson
b0a82aa420 Store the buffer format and frequency in the source when updated 2009-10-25 05:03:22 -07:00
Chris Robinson
c003d6032d Retreive and store source params once per mix update 2009-10-25 04:39:36 -07:00
Chris Robinson
1665595138 Remove unneeded bufferlistitem properties 2009-10-25 02:59:31 -07:00
Chris Robinson
921e7ac3e9 Store the buffer handle directly in the source and buffer queue list 2009-10-22 09:31:26 -07:00
Chris Robinson
8501fce38b Remove unused source fields 2009-10-21 15:40:09 -07:00
Chris Robinson
55d7984582 Set the calculated source parameters directly 2009-10-21 15:31:21 -07:00
Chris Robinson
8dbac9c0bd Store the calculated source parameters in the source struct 2009-10-21 14:25:54 -07:00
Chris Robinson
47b8510b0c Don't assume 16-bit samples 2009-10-21 13:50:53 -07:00
Chris Robinson
4e399b41cd Calculate source filter coefficients with the source parameters 2009-10-21 13:08:50 -07:00
Chris Robinson
bdec1e037f Remove unnecessary variable 2009-10-21 12:48:04 -07:00
Chris Robinson
75b65ab2a2 Remove the Frequency field from the context 2009-10-20 13:47:55 -07:00
Chris Robinson
eca8825ab4 Explicitly suspend the context being processed for mixing 2009-10-20 13:38:02 -07:00
Chris Robinson
93361118b7 Store a device's contexts in a dynamic array 2009-10-20 11:54:04 -07:00
Chris Robinson
50f963f6c6 Don't try to clamp the listener-to-source velocity for local sources
Local sources will always have a 0 VLS value
2009-10-20 11:03:16 -07:00
Chris Robinson
67c3e47ed4 Avoid handling NaN when scaling float samples for output 2009-10-20 09:48:09 -07:00
Chris Robinson
790aa68621 Reduce indentation for CalcSourceParams 2009-10-19 13:25:40 -07:00
Chris Robinson
c7c4cf221a Make the dry buffer part of the device 2009-10-09 01:06:33 -07:00
Chris Robinson
2a77e840cc Fix type casts for 7.1 output 2009-09-30 16:02:49 -07:00
Chris Robinson
af8e7ab984 Check the source start position in alSourcePlayv instead of the mixer 2009-09-24 12:24:10 -07:00
Chris Robinson
83734aff0e Slightly improve the multi-channel mixing loops 2009-09-24 08:52:51 -07:00
Chris Robinson
8ea8b49464 Avoid locking a NULL context when a device is disconnected 2009-09-21 23:31:04 -07:00
Chris Robinson
9f037e8980 Pass the device to aluMixData 2009-09-15 19:30:27 -07:00
Chris Robinson
12f81bcbb9 Move the stereo-to-binaural filter to the device 2009-09-15 19:06:47 -07:00
Chris Robinson
6636131d3b Pass the frame count to aluMixData 2009-09-15 18:19:00 -07:00
Chris Robinson
eeea9631ce Split the source mixing loop into a separate function
Helps reduce the function size and indentation levels
2009-09-15 17:56:31 -07:00
Chris Robinson
7976de05a5 Add base support for ALC_EXT_disconnect
Individual backends need to be updated to handle disconnection events
2009-08-26 19:15:17 -07:00
Chris Robinson
dc26261065 Support 32-bit float output 2009-08-15 13:20:35 -07:00
Chris Robinson
9bea67fb1c Use a function to convert float to unsigned byte 2009-08-15 11:33:38 -07:00
Chris Robinson
0ac9e57d28 Store the requested mono/stereo source count and sends in the device
Although the properties are set as context attributes, they are queried from
the device. If multiple contexts per device are ever supported, it would not
be straight forward about where to read the values from. This way, the
attributes can be treated as device-specific attributes that are updated when
a new context is created.
2009-07-06 03:09:01 -07:00
Chris Robinson
7e01e53445 Fix parsing of layout configuration string 2009-07-02 20:31:36 -07:00
Chris Robinson
c6f3a4e062 Move a couple inline functions into the header 2009-06-07 20:16:41 -07:00
Chris Robinson
2c20f26784 Apply slot gain on slot output, not input 2009-05-29 16:51:00 -07:00
Chris Robinson
2a21a449b4 Slot gain changes should have an immediate effect 2009-05-29 13:50:58 -07:00
Chris Robinson
74dc7090fd Don't expose effect-specific structures 2009-05-29 13:30:50 -07:00
Chris Robinson
34ea7eba9e Add preliminary support for the EAX Reverb effect
Not all parameters are supported yet, though it is a little more fuctional than
standard reverb
2009-05-29 01:32:54 -07:00
Chris Robinson
923af8c3a6 Don't update the source's gains in the sample mixing loop
Update copies stored on the stack instead, then update the source after mixing
2009-05-26 09:23:49 -07:00
Chris Robinson
ac04cf57fa Make sure _CRT_SECURE_NO_WARNINGS is always defined for MSVC 2009-05-26 06:02:40 -07:00
Chris Robinson
1bfa7609d2 Make the filter functions global inline, and use it for echo 2009-05-16 23:34:26 -07:00
Chris Robinson
7e8501123a Set some common macros in alu.h 2009-05-16 23:26:39 -07:00
Chris Robinson
c447eeb2c7 Use the source reference distance to specify full panning magnitude
Sources that are closer than the specified reference distance will not pan to
full magnitude, thus providing a smoother transition as it moves around near
the listener
2009-05-16 03:54:16 -07:00
Chris Robinson
7a7a4844f4 Make the filter history buffer size flexible
This lets the filter history buffer be as big as needed for a given use, so
that it can have a size large enough for the more demanding cases, but not be
wasteful for lesser-demanding cases, while not incuring the overhead of an
added pointer indirection
2009-04-16 05:43:09 -07:00
Chris Robinson
e9a6a1d6f5 Use a 2-pole filter for the wet path low-pass filter
This should help keep CPU use from increasing a lot when the number of sends
increases. Also changes the function names to reflect the difference
2009-04-14 22:04:18 -07:00
Chris Robinson
f245f0ef87 Make the number of source sends variable
The highest value is clamped to MAX_SENDS
2009-04-13 20:33:41 -07:00
Chris Robinson
a30f431b63 Reduce the number of send loops 2009-04-13 02:50:40 -07:00
Chris Robinson
55c790c9ff Add the Echo effect 2009-04-12 16:01:10 -07:00
Chris Robinson
65b69f3308 Fix air absorption 2009-04-11 20:27:55 -07:00
Chris Robinson
c67fbd72dd Pay attention to the MAX_SENDS value 2009-04-11 20:04:46 -07:00
Chris Robinson
1c54018111 Move the WetBuffer into the effect slot object
This should make it easier to support multiple slots
2009-04-11 17:04:55 -07:00
Chris Robinson
a8a4ff8af1 Constify some parameters 2009-03-13 23:08:15 -07:00
Chris Robinson
8a857c35ee Calculate filter coefficients in aluMixData 2009-03-13 22:58:54 -07:00
Chris Robinson
8348d719cd Clamp gain of multichannel sources 2009-02-10 15:15:49 -08:00
Chris Robinson
57c2e9b5f8 Include assert.h for assert() 2009-02-02 11:18:33 -08:00
Chris Robinson
7d7fc39035 Use calculated distance from reference for air absorption 2009-01-30 10:56:25 -08:00
Chris Robinson
351105b3df Fix incorrect comment 2009-01-30 10:53:09 -08:00
Chris Robinson
cbfc33215b Use M_PI since it is sure to be defined 2009-01-27 07:11:58 -08:00
Chris Robinson
1f4c69c17a Use a matrix for up- and down-mixing channels 2009-01-25 22:11:07 -08:00
Chris Robinson
f5b19fad20 Duplicate stereo onto the side channels as well as the back 2009-01-25 19:54:50 -08:00
Chris Robinson
bc60818e9a Don't read stereo layout when output is mono 2009-01-25 19:33:52 -08:00
Chris Robinson
f82c88f016 Add options for user-configurable speaker arrangements 2009-01-25 19:20:47 -08:00
Chris Robinson
98e86decad 6.1 uses front- and back-center, not left- and right-back channels 2009-01-24 15:13:14 -08:00
Chris Robinson
aaf2c0ebd4 Seperate mixing loops depending on source channel configuration 2009-01-24 13:57:01 -08:00
Chris Robinson
778b74cae1 Reimplement panning using lookup tables, based on a patch by Christian Borss
This allows speaker positions to be specified by discrete angles around the
listener, providing more flexibility and configurability in placement.
Additional patches to take advantage of this are forthcoming.
2009-01-24 10:38:04 -08:00
Chris Robinson
3056f91ec5 Apply the dry filter to multi-channel sources
Unlike mono sources, they use 2 chained one-pole filters instead of 4
2008-12-10 11:54:13 -08:00
Chris Robinson
55b9ccc2de Implement AL_EXTX_source_distance_model
As with other EXTX extensions, this is subject to change and removal as the
spec gets worked on
2008-11-25 18:56:10 -08:00
Chris Robinson
181eb95b13 Use a better dB-to-linear gain convertion 2008-11-16 00:57:35 -08:00
Chris Robinson
c0ccd31a3e Implement a new reverb effect
Code created and graciously provided by Christopher Fitzgerald
2008-11-16 00:29:49 -08:00
Chris Robinson
010f7d12f4 Don't ramp gains when starting a sound from the beginning 2008-11-13 05:48:38 -08:00
Chris Robinson
b91c2e4a99 Include float.h if it exists, for _RC_CHOP and _MCW_RC 2008-10-14 09:47:32 -07:00
Chris Robinson
59a71b1454 Remove another unused source member 2008-10-10 01:31:31 -07:00