aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/mastering.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-12-24 09:17:00 -0800
committerChris Robinson <[email protected]>2018-12-24 09:17:00 -0800
commit95631aa358a99b5f70a3edcebf2b76d1d4ae5af2 (patch)
tree686753ae4ee6e1643dfa47c82d93f4fabed5877f /Alc/mastering.h
parentd49eeb576cbcba966f56aed0dccbdd4694ffbaf7 (diff)
Make the Compressor more class-like
Diffstat (limited to 'Alc/mastering.h')
-rw-r--r--Alc/mastering.h62
1 files changed, 32 insertions, 30 deletions
diff --git a/Alc/mastering.h b/Alc/mastering.h
index 55b7c258..a9411bd0 100644
--- a/Alc/mastering.h
+++ b/Alc/mastering.h
@@ -1,6 +1,8 @@
#ifndef MASTERING_H
#define MASTERING_H
+#include <memory>
+
#include "AL/al.h"
#include "almalloc.h"
@@ -21,8 +23,8 @@ struct SlidingHold;
* http://c4dm.eecs.qmul.ac.uk/audioengineering/compressors/
*/
struct Compressor {
- ALsizei NumChans;
- ALuint SampleRate;
+ ALsizei mNumChans{0};
+ ALuint mSampleRate{0u};
struct {
bool Knee : 1;
@@ -30,36 +32,41 @@ struct Compressor {
bool Release : 1;
bool PostGain : 1;
bool Declip : 1;
- } Auto;
+ } mAuto{};
+
+ ALsizei mLookAhead{0};
+
+ ALfloat mPreGain{0.0f};
+ ALfloat mPostGain{0.0f};
- ALsizei LookAhead;
+ ALfloat mThreshold{0.0f};
+ ALfloat mSlope{0.0f};
+ ALfloat mKnee{0.0f};
- ALfloat PreGain;
- ALfloat PostGain;
+ ALfloat mAttack{0.0f};
+ ALfloat mRelease{0.0f};
- ALfloat Threshold;
- ALfloat Slope;
- ALfloat Knee;
+ alignas(16) ALfloat mSideChain[2*BUFFERSIZE]{};
+ alignas(16) ALfloat mCrestFactor[BUFFERSIZE]{};
- ALfloat Attack;
- ALfloat Release;
+ SlidingHold *mHold{nullptr};
+ ALfloat (*mDelay)[BUFFERSIZE]{nullptr};
+ ALsizei mDelayIndex{0};
- alignas(16) ALfloat SideChain[2*BUFFERSIZE];
- alignas(16) ALfloat CrestFactor[BUFFERSIZE];
+ ALfloat mCrestCoeff{0.0f};
+ ALfloat mGainEstimate{0.0f};
+ ALfloat mAdaptCoeff{0.0f};
- SlidingHold *Hold;
- ALfloat (*Delay)[BUFFERSIZE];
- ALsizei DelayIndex;
+ ALfloat mLastPeakSq{0.0f};
+ ALfloat mLastRmsSq{0.0f};
+ ALfloat mLastRelease{0.0f};
+ ALfloat mLastAttack{0.0f};
+ ALfloat mLastGainDev{0.0f};
- ALfloat CrestCoeff;
- ALfloat GainEstimate;
- ALfloat AdaptCoeff;
- ALfloat LastPeakSq;
- ALfloat LastRmsSq;
- ALfloat LastRelease;
- ALfloat LastAttack;
- ALfloat LastGainDev;
+ ~Compressor();
+ void process(const ALsizei SamplesToDo, ALfloat (*OutBuffer)[BUFFERSIZE]);
+ ALsizei getLookAhead() const noexcept { return mLookAhead; }
DEF_PLACE_NEWDEL()
};
@@ -88,7 +95,7 @@ struct Compressor {
* ReleaseTimeMin - Release time (in seconds). Acts as a maximum when
* automating release time.
*/
-Compressor* CompressorInit(const ALsizei NumChans, const ALuint SampleRate,
+std::unique_ptr<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,
@@ -97,9 +104,4 @@ Compressor* CompressorInit(const ALsizei NumChans, const ALuint SampleRate,
const ALfloat Ratio, const ALfloat KneeDb,
const ALfloat AttackTime, const ALfloat ReleaseTime);
-void ApplyCompression(Compressor *Comp, const ALsizei SamplesToDo,
- ALfloat (*OutBuffer)[BUFFERSIZE]);
-
-ALsizei GetCompressorLookAhead(const Compressor *Comp);
-
#endif /* MASTERING_H */