1 #ifndef CORE_MASTERING_H
2 #define CORE_MASTERING_H
7 #include "bufferline.h"
11 using uint
= unsigned int;
14 /* General topology and basic automation was based on the following paper:
16 * D. Giannoulis, M. Massberg and J. D. Reiss,
17 * "Parameter Automation in a Dynamic Range Compressor,"
18 * Journal of the Audio Engineering Society, v61 (10), Oct. 2013
20 * Available (along with supplemental reading) at:
22 * http://c4dm.eecs.qmul.ac.uk/audioengineering/compressors/
38 float mPostGain
{0.0f
};
40 float mThreshold
{0.0f
};
47 alignas(16) float mSideChain
[2*BufferLineSize
]{};
48 alignas(16) float mCrestFactor
[BufferLineSize
]{};
50 SlidingHold
*mHold
{nullptr};
51 FloatBufferLine
*mDelay
{nullptr};
53 float mCrestCoeff
{0.0f
};
54 float mGainEstimate
{0.0f
};
55 float mAdaptCoeff
{0.0f
};
57 float mLastPeakSq
{0.0f
};
58 float mLastRmsSq
{0.0f
};
59 float mLastRelease
{0.0f
};
60 float mLastAttack
{0.0f
};
61 float mLastGainDev
{0.0f
};
65 void process(const uint SamplesToDo
, FloatBufferLine
*OutBuffer
);
66 int getLookAhead() const noexcept
{ return static_cast<int>(mLookAhead
); }
71 * The compressor is initialized with the following settings:
73 * \param NumChans Number of channels to process.
74 * \param SampleRate Sample rate to process.
75 * \param AutoKnee Whether to automate the knee width parameter.
76 * \param AutoAttack Whether to automate the attack time parameter.
77 * \param AutoRelease Whether to automate the release time parameter.
78 * \param AutoPostGain Whether to automate the make-up (post) gain
80 * \param AutoDeclip Whether to automate clipping reduction. Ignored
81 * when not automating make-up gain.
82 * \param LookAheadTime Look-ahead time (in seconds).
83 * \param HoldTime Peak hold-time (in seconds).
84 * \param PreGainDb Gain applied before detection (in dB).
85 * \param PostGainDb Make-up gain applied after compression (in dB).
86 * \param ThresholdDb Triggering threshold (in dB).
87 * \param Ratio Compression ratio (x:1). Set to INFINIFTY for true
88 * limiting. Ignored when automating knee width.
89 * \param KneeDb Knee width (in dB). Ignored when automating knee
91 * \param AttackTime Attack time (in seconds). Acts as a maximum when
92 * automating attack time.
93 * \param ReleaseTime Release time (in seconds). Acts as a maximum when
94 * automating release time.
96 static std::unique_ptr
<Compressor
> Create(const size_t NumChans
, const float SampleRate
,
97 const bool AutoKnee
, const bool AutoAttack
, const bool AutoRelease
,
98 const bool AutoPostGain
, const bool AutoDeclip
, const float LookAheadTime
,
99 const float HoldTime
, const float PreGainDb
, const float PostGainDb
,
100 const float ThresholdDb
, const float Ratio
, const float KneeDb
, const float AttackTime
,
101 const float ReleaseTime
);
103 using CompressorPtr
= std::unique_ptr
<Compressor
>;
105 #endif /* CORE_MASTERING_H */