diff options
author | Chris Robinson <[email protected]> | 2017-05-05 07:38:26 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-05-05 07:38:26 -0700 |
commit | 074e4496ba1136b5c9590dff21b6c1181b2a5541 (patch) | |
tree | 61b3fcf25fd735ce166d4549380f0ce763fc0b7e /OpenAL32/Include | |
parent | 64f0630fef7fadc8c30a0bd02cde37aa69ac64da (diff) |
Calculate the output limiter gain using the RMS
Diffstat (limited to 'OpenAL32/Include')
-rw-r--r-- | OpenAL32/Include/alMain.h | 3 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 18 |
2 files changed, 20 insertions, 1 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 1b1b1909..55f52bef 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -391,6 +391,7 @@ extern "C" { struct Hrtf; struct HrtfEntry; +struct OutputLimiter; #define DEFAULT_OUTPUT_RATE (44100) @@ -793,7 +794,7 @@ struct ALCdevice_struct ALsizei NumChannels; } RealOut; - ALfloat LimiterGain; + struct OutputLimiter *Limiter; /* The average speaker distance as determined by the ambdec configuration * (or alternatively, by the NFC-HOA reference delay). Only used for NFC. diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 8e2fe1e9..6fdbac6f 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -297,6 +297,24 @@ typedef struct ALvoice { void DeinitVoice(ALvoice *voice); +#define LIMITER_WINDOW_SIZE (1<<7) /* 128 */ +#define LIMITER_WINDOW_MASK (LIMITER_WINDOW_SIZE-1) +struct OutputLimiter { + /* RMS detection window and the next write pos. */ + alignas(16) ALfloat Window[LIMITER_WINDOW_SIZE]; + ALsizei Pos; + + /* In milliseconds. */ + ALfloat AttackRate; + ALfloat ReleaseRate; + + /* The gain last used for limiting. */ + ALfloat Gain; +}; + +struct OutputLimiter *alloc_limiter(void); + + typedef void (*MixerFunc)(const ALfloat *data, ALsizei OutChans, ALfloat (*restrict OutBuffer)[BUFFERSIZE], ALfloat *CurrentGains, const ALfloat *TargetGains, ALsizei Counter, ALsizei OutPos, |