8 /* For FloatBufferLine/BUFFERSIZE. */
15 /* General topology and basic automation was based on the following paper:
17 * D. Giannoulis, M. Massberg and J. D. Reiss,
18 * "Parameter Automation in a Dynamic Range Compressor,"
19 * Journal of the Audio Engineering Society, v61 (10), Oct. 2013
21 * Available (along with supplemental reading) at:
23 * http://c4dm.eecs.qmul.ac.uk/audioengineering/compressors/
38 ALfloat mPreGain
{0.0f
};
39 ALfloat mPostGain
{0.0f
};
41 ALfloat mThreshold
{0.0f
};
45 ALfloat mAttack
{0.0f
};
46 ALfloat mRelease
{0.0f
};
48 alignas(16) ALfloat mSideChain
[2*BUFFERSIZE
]{};
49 alignas(16) ALfloat mCrestFactor
[BUFFERSIZE
]{};
51 SlidingHold
*mHold
{nullptr};
52 FloatBufferLine
*mDelay
{nullptr};
54 ALfloat mCrestCoeff
{0.0f
};
55 ALfloat mGainEstimate
{0.0f
};
56 ALfloat mAdaptCoeff
{0.0f
};
58 ALfloat mLastPeakSq
{0.0f
};
59 ALfloat mLastRmsSq
{0.0f
};
60 ALfloat mLastRelease
{0.0f
};
61 ALfloat mLastAttack
{0.0f
};
62 ALfloat mLastGainDev
{0.0f
};
66 void process(const ALuint SamplesToDo
, FloatBufferLine
*OutBuffer
);
67 ALsizei
getLookAhead() const noexcept
{ return static_cast<ALsizei
>(mLookAhead
); }
72 /* The compressor is initialized with the following settings:
74 * NumChans - Number of channels to process.
75 * SampleRate - Sample rate to process.
76 * AutoKnee - Whether to automate the knee width parameter.
77 * AutoAttack - Whether to automate the attack time parameter.
78 * AutoRelease - Whether to automate the release time parameter.
79 * AutoPostGain - Whether to automate the make-up (post) gain parameter.
80 * AutoDeclip - Whether to automate clipping reduction. Ignored when
81 * not automating make-up gain.
82 * LookAheadTime - Look-ahead time (in seconds).
83 * HoldTime - Peak hold-time (in seconds).
84 * PreGainDb - Gain applied before detection (in dB).
85 * PostGainDb - Make-up gain applied after compression (in dB).
86 * ThresholdDb - Triggering threshold (in dB).
87 * Ratio - Compression ratio (x:1). Set to INFINIFTY for true
88 * limiting. Ignored when automating knee width.
89 * KneeDb - Knee width (in dB). Ignored when automating knee
91 * AttackTimeMin - Attack time (in seconds). Acts as a maximum when
92 * automating attack time.
93 * ReleaseTimeMin - Release time (in seconds). Acts as a maximum when
94 * automating release time.
96 std::unique_ptr
<Compressor
> CompressorInit(const ALuint NumChans
, const ALfloat SampleRate
,
97 const ALboolean AutoKnee
, const ALboolean AutoAttack
, const ALboolean AutoRelease
,
98 const ALboolean AutoPostGain
, const ALboolean AutoDeclip
, const ALfloat LookAheadTime
,
99 const ALfloat HoldTime
, const ALfloat PreGainDb
, const ALfloat PostGainDb
,
100 const ALfloat ThresholdDb
, const ALfloat Ratio
, const ALfloat KneeDb
, const ALfloat AttackTime
,
101 const ALfloat ReleaseTime
);
103 #endif /* MASTERING_H */