It's expensive to run many reverb effects in real time, so the engine will group emitters with similar reverb properties together.
To enable this, set `emitter.AffectsGroupedEAX` to true, and set `MaximumGroupedEAXCount` on the context:
```cs
var context = new RaytracingContext()
{
MaximumGroupedEAXCount = 2,
};
var emitter = new Emitter()
{
AffectsGroupedEAX = true,
};
context.AddEmitter(emitter);
```
## Grouping Logic
If there are more emitters than `MaximumGroupedEAXCount`, all emitters that have `AffectsGroupedEAX` set to true will have their EAX objects will be iteratively averaged together to produce N grouped EAX objects.
EAX objects are compared via their:
- Outside percent
- Returning percent
- EAX decay time
- EAX low-frequency gain
- EAX high-frequency gain
## Accessing Grouped EAX
These grouped EAX objects can be accessed in the `context.GroupedEAX` list. In your code, copy the EAX properties to an actual EAX reverb effect.
```cs
List<ALReverbEffect> effects = [];
context.OnReverbUpdated = () =>
{
for (int i = 0; i < context.GroupedEAX.Count; i++)
{
var grouped = context.GroupedEAX[i];
effects[i].DecayTime = grouped.DecayTime;
effects[i].GainLF = grouped.GainLF;
// etc...
}
}
```
When an emitter finishes raytracing, use its `GroupedEAXIndex` to determine which reverb effect to use for that emitter's sound:
```cs
emitter.OnRaytracedByAnotherEmitter = (Emitter other) =>
{
ALReverbEffect effect = effects[emitter.GroupedEAXIndex];
// OpenAL - apply the reverb effect to the source
AL.Source3i(sourceID, AL.AL_AUXILIARY_SEND_FILTER, effect.effectSlotID, 0, 0);
}
```
## Volume
When your listener is in the same room as an emitter, the other emitter's reverb should be loud (wet). If you're in another room, the reverb should be quieter.
The engine calculates this gain for each emitter that has `HasReverbPan` set to true (usually just your main listener emitter). You can access this gain via the `EffectSlotGain` dictionary on each object in `context.GroupedEAX`:
```cs
var listener = new Emitter()
{
HasReverbPan = true,
};
context.OnReverbUpdated = () =>
{
for (int i = 0; i < context.GroupedEAX.Count; i++)
{
// Get the gain of this EAX slot relative to this listener
effects[i].effectSlotGain = grouped.EffectSlotGain[listener];
}
}
```
This gain is in the range 0.0 to 1.0, and should control the **final output** volume of that EAX reverb effect, i.e. the `effectSlotGain`.
Note that you **should not** reduce the volume or apply a low pass filter between your audio source and the reverb effect. This allows the reverb effect to operate on the raw audio source and produce correct reverb. This allows you to hear muffled reverb on the other side of a wall.