diff options
author | Chris Robinson <[email protected]> | 2018-11-21 16:46:52 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-11-21 16:46:52 -0800 |
commit | cc3e2a838f245770af3d773e8d2c461b9912e392 (patch) | |
tree | 1731cb65bf0be9f3de38f90f8730059a6c50ff5c /Alc/mastering.h | |
parent | eefc379a239820a0711683455f5fadb20c8dbaf9 (diff) |
Use a unique_ptr for the Compressor
Diffstat (limited to 'Alc/mastering.h')
-rw-r--r-- | Alc/mastering.h | 68 |
1 files changed, 59 insertions, 9 deletions
diff --git a/Alc/mastering.h b/Alc/mastering.h index 7738a4aa..a6cf58ed 100644 --- a/Alc/mastering.h +++ b/Alc/mastering.h @@ -3,14 +3,68 @@ #include "AL/al.h" +#include "almalloc.h" /* For BUFFERSIZE. */ #include "alMain.h" -#ifdef __cplusplus -extern "C" { -#endif -struct Compressor; +struct SlidingHold; + +/* General topology and basic automation was based on the following paper: + * + * D. Giannoulis, M. Massberg and J. D. Reiss, + * "Parameter Automation in a Dynamic Range Compressor," + * Journal of the Audio Engineering Society, v61 (10), Oct. 2013 + * + * Available (along with supplemental reading) at: + * + * http://c4dm.eecs.qmul.ac.uk/audioengineering/compressors/ + */ +struct Compressor { + ALsizei NumChans; + ALuint SampleRate; + + struct { + ALuint Knee : 1; + ALuint Attack : 1; + ALuint Release : 1; + ALuint PostGain : 1; + ALuint Declip : 1; + } Auto; + + ALsizei LookAhead; + + ALfloat PreGain; + ALfloat PostGain; + + ALfloat Threshold; + ALfloat Slope; + ALfloat Knee; + + ALfloat Attack; + ALfloat Release; + + alignas(16) ALfloat SideChain[2*BUFFERSIZE]; + alignas(16) ALfloat CrestFactor[BUFFERSIZE]; + + SlidingHold *Hold; + ALfloat (*Delay)[BUFFERSIZE]; + ALsizei DelayIndex; + + ALfloat CrestCoeff; + ALfloat GainEstimate; + ALfloat AdaptCoeff; + + ALfloat LastPeakSq; + ALfloat LastRmsSq; + ALfloat LastRelease; + ALfloat LastAttack; + ALfloat LastGainDev; + + void *operator new(size_t size) = delete; + void *operator new(size_t /*size*/, void *ptr) noexcept { return ptr; } + void operator delete(void *block) noexcept { al_free(block); } +}; /* The compressor is initialized with the following settings: * @@ -36,7 +90,7 @@ struct Compressor; * ReleaseTimeMin - Release time (in seconds). Acts as a maximum when * automating release time. */ -struct Compressor* CompressorInit(const ALsizei NumChans, const ALuint SampleRate, +Compressor* CompressorInit(const ALsizei NumChans, const ALuint SampleRate, const ALboolean AutoKnee, const ALboolean AutoAttack, const ALboolean AutoRelease, const ALboolean AutoPostGain, const ALboolean AutoDeclip, const ALfloat LookAheadTime, @@ -50,8 +104,4 @@ void ApplyCompression(struct Compressor *Comp, const ALsizei SamplesToDo, ALsizei GetCompressorLookAhead(const struct Compressor *Comp); -#ifdef __cplusplus -} // extern "C" -#endif - #endif /* MASTERING_H */ |