Commit Graph

202 Commits

Author SHA1 Message Date
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
Chris Robinson
36f133a5ae Use a modulo to keep the buffer position in range for looping sources
A high pitch and low buffer size can cause a lot of unnecessary iterations
otherwise, that just decrement the position
2008-10-10 01:13:32 -07:00
Chris Robinson
74a58c0d09 Clamp source position to the buffer size when it stops 2008-10-09 23:54:31 -07:00
Chris Robinson
bfa1107781 Remove unneeded source member variable 2008-10-09 23:44:48 -07:00
Chris Robinson
6e9e8239ef Only send one channel through the wet path 2008-10-09 04:02:34 -07:00
Chris Robinson
af9932d28b Increase max pitch to 65536
This should be safe now
2008-10-09 02:50:00 -07:00
Chris Robinson
87ff8a65e9 Simplify the lerp function 2008-10-09 02:32:47 -07:00
Chris Robinson
7b6f207790 Don't apply the wet path for multi-channel buffers 2008-10-09 02:28:52 -07:00
Chris Robinson
8672008e43 Skip mixing if the read position is beyond the end of the buffer 2008-10-09 01:17:39 -07:00
Chris Robinson
c8cd193346 The wet path should be silent if no effect is set on the slot 2008-10-09 01:07:02 -07:00
Chris Robinson
be292e5f0b Don't hold the whole-number position in the fractional value
This will help prevent overflows when the max pitch is increased
2008-10-02 23:53:46 -07:00
Chris Robinson
3863dcc9cb Use a new low-pass filter, based on the I3DL2 spec
Many thanks to Christopher Fitzgerald, for helping with it
2008-10-02 22:20:42 -07:00
Chris Robinson
6567cdd7b5 Air absorption factor is applied to the dB value, not linear gain 2008-09-22 17:01:47 -07:00
Chris Robinson
4a530e2146 Fixup some source parameter calculations 2008-09-16 07:36:48 -07:00
Chris Robinson
6bfdb57a5b Use a 12dB/oct rolloff instead of 24 for the lowpass filter 2008-09-13 02:46:14 -07:00
Chris Robinson
fa76168683 Clear the end of the buffer when at the end of the queue and not looping 2008-09-06 14:08:53 -07:00
Chris Robinson
db541f3cfa Remove unneeded source struct member 2008-08-15 17:43:07 -07:00
Chris Robinson
ac8c082b89 Overwrite the input wet sample with the output 2008-08-14 20:44:55 -07:00
Chris Robinson
22557070ec Ramp channel gains to remove pops and clicks from abrupt changes
Thanks to Christopher Fitzgerald for helping me work on it
2008-08-14 05:43:52 -07:00
Chris Robinson
ef59901e7c Set FPU mode to round toward zero for mixing 2008-08-08 07:32:21 -07:00
Chris Robinson
cfe620ccb5 Remove unnecessary casting 2008-08-08 00:21:25 -07:00
Chris Robinson
453b015225 Prevent a 0 or negative increment for the buffer position
Thanks to Christopher Fitzgerald for pointing these last two problems out
2008-08-05 20:51:30 -07:00
Chris Robinson
d3e5fcd13e Fix some calculations for the reverb buffer 2008-07-26 01:57:04 -07:00
Chris Robinson
3e0f9cc716 Make the filter processing function inline 2008-07-26 00:58:54 -07:00
Chris Robinson
c7e49c9f57 Implement yet another low-pass filter
This one using the Butterworth IIR filter design
2008-07-25 19:31:12 -07:00
Chris Robinson
559c786d0c Specify padding per buffer, and make sure it's large enough for the filter step 2008-07-24 00:41:25 -07:00
Chris Robinson
c3a7480961 Don't advertise extra samples for mixing 2008-07-23 23:27:38 -07:00
Chris Robinson
a75e75aef5 Implement an alternative low-pass filter
This method samples from the buffer so that it gets a time-correct 5khz stream,
which is subtracted from the original sample and has the high-frequency gain
applied, then added back.
A better method may be to average all the samples from the current one to the
one freq/5000 away, instead of bilinear filtering the two nearest freq/5000
apart. Processing cost will need to determine its viability
2008-07-23 22:29:53 -07:00
Chris Robinson
0042b1f80d Implement doppler factor source property 2008-07-15 02:33:05 -07:00
Chris Robinson
6d416ee734 Add the reverb room rolloff to the source room rolloff, not override 2008-07-15 02:23:53 -07:00
Chris Robinson
f369be148f Reduce the mix buffer sizes by half
Nearly 3MB is a bit much. Could reduce it further, but this is good enough for now.
2008-07-08 19:37:14 -07:00
Chris Robinson
3a09e446b3 Leave SourceToListener untransformed for use with untransformed velocities
Distance is also left untransformed so cone calculations with SoundToListener
are correct
2008-07-03 03:13:43 -07:00
Chris Robinson
fed346c285 Fix source calculations for AL_SOURCE_RELATIVE mode
Make sure the source position and direction are properly put into listener-
space before working with them, and don't calculate the listener velocity for
relative coordinates
2008-05-18 16:52:38 -07:00
Chris Robinson
49d9695ad9 Check the right struct member for the filter type 2008-04-12 07:25:18 -07:00
Chris Robinson
ec7f20644d Fast float-to-int function is no longer needed 2008-02-08 21:03:48 -08:00
Chris Robinson
3d5fa91703 Remove unnecessary casting 2008-02-08 21:01:05 -08:00
Chris Robinson
b4ffdfab81 Add an option for duplicating stereo sources on the back speakers 2008-02-06 22:18:50 -08:00
Chris Robinson
e8b576bc25 Use the correct channel ordering for Windows 2008-01-27 07:04:13 -08:00
Chris Robinson
01404ed7af Fix output channel order for 6.1 and 7.1 2008-01-27 06:49:48 -08:00
Chris Robinson
781e4e5be4 Remove an unneceesary pointer check and decrease indentation 2008-01-21 14:54:15 -08:00
Chris Robinson
f3dddb5e99 Remove unnecessary duplicate thunk lookups 2008-01-21 14:33:42 -08:00
Chris Robinson
9a5e892cad Small formatting updates 2008-01-20 22:16:28 -08:00
Chris Robinson
0317362662 Remove duplicate function 2008-01-20 19:22:39 -08:00
Chris Robinson
6b403a76e8 Don't access ALSource for every sample mix 2008-01-20 19:20:24 -08:00
Chris Robinson
1a3e39e452 Remove some unnecessary duplicate math, which was making long lines 2008-01-19 00:49:05 -08:00
Chris Robinson
7dc73815ae Remove some branches 2008-01-18 21:39:09 -08:00
Chris Robinson
4caf2c7edd Implement AL_EFFECT_REVERB
Here is a quick description of how the reverb effect works:

 +--->---+*(4)
 |       V       new sample
 +-----+---+---+    |
 |extra|ltr|ref| <- +*(1)
 +-----+---+---+
   (3,5)*|   |*(2)
         +-->|
             V
         out sample

 1) Apply master reverb gain to incoming sample and place it at the head of the
    buffer. The master reverb gainhf was already applied when the source was
    initially mixed.
 2) Copy the delayed reflection sample to an output sample and apply the
    reflection gain.
 3) Apply the late reverb gain to the late reverb sample
 4) Copy the end of the buffer, applying a decay gain and the decay hf ratio,
    and add to the late reverb.
 5) Copy the late reverb sample, adding to the output sample.

 Then the head and sampling points are shifted forward, and done again for each
 new sample. The extra buffer length is determined by the Reverb Density
 property. A value of 0 gives a length of 0.1 seconds (long, with fairly
 distinct echos) , and 1 gives 0.075 seconds (short, indistinct echos).
 The decay gain is calculated such that after a number of loops to satisfy the
 Decay Time, a sample will be 1/32768th as powerful (virtually insignificant to
 the resulting output, and only getting further reduced). It is calculated as:

 DecayGain = pow(1.0f/32768.0f, 1.0/(DecayTime/ExtraLength));

 Things to note: Reverb Diffusion is not currently handled, nor is Decay HF
 Limit. Decay HF Ratios above 1 probably give incorrect results. Also, this
 method likely sucks, but it's the best I can come up with before release. :)
2008-01-18 21:25:40 -08:00
Chris Robinson
43cfc097de Don't dereference ALContext if there's no context yet
Patch by Evgeny A. Marchenko
2008-01-17 12:57:22 -08:00
Chris Robinson
be34dbe608 Don't include alAuxEffectSlot.h in alSource.h 2008-01-16 14:01:24 -08:00
Chris Robinson
4742dedb45 Don't clamp wet gain if there's no send slot, and move slot gain calculation
To remove an extra if check
2008-01-16 13:00:35 -08:00
Chris Robinson
10a9bc62bf Store a reference to the effect slot in a source's send, not a copy 2008-01-16 12:43:25 -08:00
Chris Robinson
24f433b938 Remove unneeded variables 2008-01-15 21:57:50 -08:00
Chris Robinson
abc69dd3d0 Use acosf when available 2008-01-15 21:23:14 -08:00
Chris Robinson
03ca50fa70 Use the previous low-pass filter again, as it seems to match the intended output better 2008-01-15 18:29:21 -08:00
Chris Robinson
df07e8a65b Add support for AL_LOKI_quadriphonic 2008-01-14 16:11:15 -08:00
Chris Robinson
38db8eb64b Reorder setting of some variables 2008-01-12 07:36:22 -08:00
Chris Robinson
3bbbf8a025 Merge branch 'master' into efx-experiment 2008-01-11 17:19:08 -08:00
Chris Robinson
042ec206e7 Disable fast float-to-int hack.
Even with precautions, it's giving problems. Not worth it since I don't quite
understand how it works, or know if there's even a benefit.
2008-01-05 05:03:31 -08:00
Chris Robinson
312108a0d3 Try a different low-pass filter
Seems to be more correct, although it's not as powerful as the previous (which
may be a good thing)
2008-01-05 03:51:24 -08:00
Chris Robinson
5e48be27b8 Merge branch 'master' into efx-experiment 2008-01-04 14:40:38 -08:00
Chris Robinson
b3badbf97d Use 6 point spatialization for 6.1 and 7.1 output 2008-01-04 14:15:55 -08:00
Chris Robinson
8fe39042da Add the Bauer stereophonic-to-binaural DSP (bs2b) code and hooks 2008-01-03 05:36:51 -08:00
Chris Robinson
9ed574b399 Merge branch 'master' into efx-experiment 2008-01-01 06:29:11 -08:00
Chris Robinson
733cd120b3 Fix channel ordering for multichannel buffers 2008-01-01 06:16:19 -08:00
Chris Robinson
4e2f8e305e Fix wet volumes for multichannel path 2007-12-31 19:40:24 -08:00
Chris Robinson
3d78d93b40 Merge branch 'master' into efx-experiment 2007-12-31 19:34:52 -08:00
Chris Robinson
5a2f509104 Zero out wet send params when calculating source params
Instead of using a check in the mix loop
2007-12-31 19:13:18 -08:00
Chris Robinson
cb1d62f254 Add paths for 4 to 7.1 channel buffer mixing 2007-12-31 04:50:34 -08:00
Chris Robinson
1cbd625b4e Disable unnecessary calculations 2007-12-31 03:45:26 -08:00
Chris Robinson
73678f3b78 Allow psuedo 6.1 and 7.1 output
This only does spatial calculations on the 4 corner speakers, but it's
necessary groundwork for AL_EXT_MCFORMATS support. Spatial calculations for 6
speakers can be added later.
2007-12-31 03:29:14 -08:00
Chris Robinson
a43868c32b Use an enum list for dealing with channels
This will make it easier to remap channels, especially the center and lfe channels
2007-12-31 01:47:10 -08:00
Chris Robinson
7a99b1fa32 Make some defines local to ALu.c 2007-12-31 01:16:13 -08:00
Chris Robinson
e82c27ab04 Fix includes so alMain.h doesn't include so much by itself 2007-12-31 01:09:57 -08:00
Chris Robinson
f7ef5c169b Don't default to AL_FORMAT_STEREO16 when writing to the output buffer 2007-12-31 00:08:07 -08:00
Chris Robinson
927763902f Loop per frame, not per sample, when writing the output buffer 2007-12-31 00:05:29 -08:00
Chris Robinson
5f8e65e099 Implement AL_EXT_FLOAT32 2007-12-28 22:41:14 -08:00
Chris Robinson
8011ad97b5 Don't check explicitly against formats, but rather their byte/channel count 2007-12-26 23:29:32 -08:00
Chris Robinson
ab8d342df0 Allow 5.1 channel output
This doesn't use the center or LFE channel in spatial calculations, however
2007-12-26 23:01:22 -08:00
Chris Robinson
96bd020bd3 Use the right-channel sample... 2007-12-21 14:30:38 -08:00
Chris Robinson
8dc2aef058 Don't send stereo samples to the wet path without an auxiliary slot 2007-12-21 12:12:13 -08:00
Chris Robinson
d43486f894 Fix extrenuous comment 2007-12-21 10:52:26 -08:00
Chris Robinson
229bc0d7e1 Merge branch 'master' into efx-experiment 2007-12-20 21:48:17 -08:00
Chris Robinson
5b0514a829 Do the channel pannings based on output channel count
This should make it a bit easier to extend in the future
2007-12-20 21:40:22 -08:00
Chris Robinson
a433ae0ff4 Use the AuxSendAuto property of the effect slot 2007-12-18 19:43:54 -08:00
Chris Robinson
e5609279da Implement AL_AUXILIARY_SEND_FILTER_GAIN_AUTO property 2007-12-18 19:13:41 -08:00
Chris Robinson
afd3b71849 Implement AL_ROOM_ROLLOFF_FACTOR property 2007-12-18 19:03:40 -08:00
Chris Robinson
6aabc837a9 Fix initial WetMix setup 2007-12-18 17:21:13 -08:00
Chris Robinson
233e6f1765 Implement AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO property 2007-12-18 16:54:22 -08:00
Chris Robinson
9adc20e4e7 Implement AL_EFFECTSLOT_GAIN property 2007-12-18 15:47:24 -08:00
Chris Robinson
bdf16bf601 Add initial auxiliary send paths 2007-12-18 15:10:21 -08:00
Chris Robinson
ebb30ec5b0 Implement AL_AIR_ABSORPTION_FACTOR source property 2007-12-18 13:37:07 -08:00
Chris Robinson
168d8e3bee Add AL_FILTER_LOWPASS support
Direct filters only, since auxiliary sends and slots aren't available yet
2007-12-17 22:42:38 -08:00
Chris Robinson
654788f2cf Implement AL_CONE_OUTER_GAINHF source property 2007-12-17 21:56:31 -08:00
Chris Robinson
fc43a13927 Implement basic lowpass filter path 2007-12-17 21:00:52 -08:00
Chris Robinson
28f80fa113 Add AL_METERS_PER_UNIT listener property 2007-12-17 19:40:43 -08:00
Chris Robinson
18f05cc1d1 Prevent some ICC warnings 2007-12-06 22:49:23 -08:00
Chris Robinson
d608df5b22 More casts 2007-12-06 22:32:02 -08:00
Chris Robinson
15019b3871 Allow aluMixData to accept a NULL context for silence 2007-12-05 00:29:20 -08:00
Chris Robinson
e0d3102009 Move ALu.c to the Alc directory 2007-11-15 01:45:54 -08:00