aboutsummaryrefslogtreecommitdiffstats
path: root/core/mastering.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/mastering.h')
-rw-r--r--core/mastering.h27
1 files changed, 19 insertions, 8 deletions
diff --git a/core/mastering.h b/core/mastering.h
index 1a36937c..ca7266a3 100644
--- a/core/mastering.h
+++ b/core/mastering.h
@@ -1,10 +1,14 @@
#ifndef CORE_MASTERING_H
#define CORE_MASTERING_H
+#include <array>
#include <memory>
#include "almalloc.h"
+#include "alnumeric.h"
+#include "alspan.h"
#include "bufferline.h"
+#include "vector.h"
struct SlidingHold;
@@ -21,7 +25,7 @@ using uint = unsigned int;
*
* http://c4dm.eecs.qmul.ac.uk/audioengineering/compressors/
*/
-struct Compressor {
+class Compressor {
size_t mNumChans{0u};
struct {
@@ -44,11 +48,11 @@ struct Compressor {
float mAttack{0.0f};
float mRelease{0.0f};
- alignas(16) float mSideChain[2*BufferLineSize]{};
- alignas(16) float mCrestFactor[BufferLineSize]{};
+ alignas(16) std::array<float,BufferLineSize*2_uz> mSideChain{};
+ alignas(16) std::array<float,BufferLineSize> mCrestFactor{};
- SlidingHold *mHold{nullptr};
- FloatBufferLine *mDelay{nullptr};
+ std::unique_ptr<SlidingHold> mHold;
+ al::vector<FloatBufferLine,16> mDelay;
float mCrestCoeff{0.0f};
float mGainEstimate{0.0f};
@@ -60,12 +64,19 @@ struct Compressor {
float mLastAttack{0.0f};
float mLastGainDev{0.0f};
+ Compressor() = default;
+ void linkChannels(const uint SamplesToDo, const FloatBufferLine *OutBuffer);
+ void crestDetector(const uint SamplesToDo);
+ void peakDetector(const uint SamplesToDo);
+ void peakHoldDetector(const uint SamplesToDo);
+ void gainCompressor(const uint SamplesToDo);
+ void signalDelay(const uint SamplesToDo, FloatBufferLine *OutBuffer);
+
+public:
~Compressor();
void process(const uint SamplesToDo, FloatBufferLine *OutBuffer);
- int getLookAhead() const noexcept { return static_cast<int>(mLookAhead); }
-
- DEF_PLACE_NEWDEL()
+ [[nodiscard]] auto getLookAhead() const noexcept -> uint { return mLookAhead; }
/**
* The compressor is initialized with the following settings: