diff options
author | Chris Robinson <[email protected]> | 2017-07-31 23:49:48 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-07-31 23:49:48 -0700 |
commit | 8a735d0ba9db9b4b992172dc197396cc655264d5 (patch) | |
tree | 870ee7ed74e6028d92f3fc431c9b3c3243e08070 /Alc/panning.c | |
parent | 88c0d22e7c72109fb5d7b2ee3276680d36971368 (diff) |
Add a front-stablizer config option for surround sound modes
This improves a stereo (front-left + front-right) sound "image" by generating a
front-center channel signal. Done correctly, it helps reduce the comb effects
and phase errors associated with using only two speakers to simulate center
sounds.
Note that it shouldn't be used if the front-center channel is already included
in the positional audio mix (the dialog effect is okay). In general, it may
actually be better to exclude the front-center channel from the positional
audio mix and use this to generate front-center output.
Diffstat (limited to 'Alc/panning.c')
-rw-r--r-- | Alc/panning.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Alc/panning.c b/Alc/panning.c index d1cb6df4..fb510f1e 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -1006,6 +1006,9 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf device->ChannelDelay[i].Length = 0; } + al_free(device->Stablizer); + device->Stablizer = NULL; + if(device->FmtChans != DevFmtStereo) { ALsizei speakermap[MAX_OUTPUT_CHANNELS]; @@ -1084,6 +1087,43 @@ void aluInitRenderer(ALCdevice *device, ALint hrtf_id, enum HrtfRequestMode hrtf else InitCustomPanning(device, pconf, speakermap); + /* Enable the stablizer only for formats that have front-left, front- + * right, and front-center outputs. + */ + switch(device->FmtChans) + { + case DevFmtX51: + case DevFmtX51Rear: + case DevFmtX61: + case DevFmtX71: + if(GetConfigValueBool(devname, NULL, "front-stablizer", 0)) + { + /* Initialize band-splitting filters for the front-left and + * front-right channels, with a crossover at 5khz (could be + * higher). + */ + ALfloat scale = (ALfloat)(5000.0 / device->Frequency); + FrontStablizer *stablizer = al_calloc(16, sizeof(*stablizer)); + + bandsplit_init(&stablizer->LFilter, scale); + stablizer->RFilter = stablizer->LFilter; + + /* Initialize all-pass filters for all other channels. */ + splitterap_init(&stablizer->APFilter[0], scale); + for(i = 1;i < (size_t)device->RealOut.NumChannels;i++) + stablizer->APFilter[i] = stablizer->APFilter[0]; + + device->Stablizer = stablizer; + } + break; + case DevFmtMono: + case DevFmtStereo: + case DevFmtQuad: + case DevFmtAmbi3D: + break; + } + TRACE("Front stablizer %s\n", device->Stablizer ? "enabled" : "disabled"); + ambdec_deinit(&conf); return; } |