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/alu.h | |
parent | 64f0630fef7fadc8c30a0bd02cde37aa69ac64da (diff) |
Calculate the output limiter gain using the RMS
Diffstat (limited to 'OpenAL32/Include/alu.h')
-rw-r--r-- | OpenAL32/Include/alu.h | 18 |
1 files changed, 18 insertions, 0 deletions
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, |