aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALc.c1
-rw-r--r--Alc/ALu.c1
-rw-r--r--Alc/mastering.c31
-rw-r--r--Alc/mastering.h57
-rw-r--r--OpenAL32/Include/alMain.h28
5 files changed, 63 insertions, 55 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index cca88a8f..3de59521 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -37,6 +37,7 @@
#include "alBuffer.h"
#include "alAuxEffectSlot.h"
#include "alError.h"
+#include "mastering.h"
#include "bformatdec.h"
#include "alu.h"
diff --git a/Alc/ALu.c b/Alc/ALu.c
index a4e9c1a4..bd1bf79a 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -34,6 +34,7 @@
#include "alu.h"
#include "bs2b.h"
#include "hrtf.h"
+#include "mastering.h"
#include "uhjfilter.h"
#include "bformatdec.h"
#include "static_assert.h"
diff --git a/Alc/mastering.c b/Alc/mastering.c
index 9de5fd5f..91267d83 100644
--- a/Alc/mastering.c
+++ b/Alc/mastering.c
@@ -2,37 +2,19 @@
#include <math.h>
+#include "mastering.h"
#include "alu.h"
#include "almalloc.h"
+
+extern inline ALuint GetCompressorSampleRate(const Compressor *Comp);
+
#define RMS_WINDOW_SIZE (1<<7)
#define RMS_WINDOW_MASK (RMS_WINDOW_SIZE-1)
#define RMS_VALUE_MAX (1<<24)
-#define LOOKAHEAD_SIZE (1<<13)
-#define LOOKAHEAD_MASK (LOOKAHEAD_SIZE-1)
-
static_assert(RMS_VALUE_MAX < (UINT_MAX / RMS_WINDOW_SIZE), "RMS_VALUE_MAX is too big");
-typedef struct Compressor {
- ALfloat PreGain;
- ALfloat PostGain;
- ALboolean SummedLink;
- ALfloat AttackMin;
- ALfloat AttackMax;
- ALfloat ReleaseMin;
- ALfloat ReleaseMax;
- ALfloat Ratio;
- ALfloat Threshold;
- ALfloat Knee;
- ALuint SampleRate;
-
- ALuint RmsSum;
- ALuint *RmsWindow;
- ALsizei RmsIndex;
- ALfloat Envelope[BUFFERSIZE];
- ALfloat EnvLast;
-} Compressor;
/* Multichannel compression is linked via one of two modes:
*
@@ -209,11 +191,6 @@ Compressor *CompressorInit(const ALfloat PreGainDb, const ALfloat PostGainDb,
return Comp;
}
-ALuint GetCompressorSampleRate(const Compressor *Comp)
-{
- return Comp->SampleRate;
-}
-
void ApplyCompression(Compressor *Comp, const ALsizei NumChans, const ALsizei SamplesToDo,
ALfloat (*restrict OutBuffer)[BUFFERSIZE])
{
diff --git a/Alc/mastering.h b/Alc/mastering.h
new file mode 100644
index 00000000..0a7b4901
--- /dev/null
+++ b/Alc/mastering.h
@@ -0,0 +1,57 @@
+#ifndef MASTERING_H
+#define MASTERING_H
+
+#include "AL/al.h"
+
+/* For BUFFERSIZE. */
+#include "alMain.h"
+
+typedef struct Compressor {
+ ALfloat PreGain;
+ ALfloat PostGain;
+ ALboolean SummedLink;
+ ALfloat AttackMin;
+ ALfloat AttackMax;
+ ALfloat ReleaseMin;
+ ALfloat ReleaseMax;
+ ALfloat Ratio;
+ ALfloat Threshold;
+ ALfloat Knee;
+ ALuint SampleRate;
+
+ ALuint RmsSum;
+ ALuint *RmsWindow;
+ ALsizei RmsIndex;
+ ALfloat Envelope[BUFFERSIZE];
+ ALfloat EnvLast;
+} Compressor;
+
+/* The compressor requires the following information for proper
+ * initialization:
+ *
+ * PreGainDb - Gain applied before detection (in dB).
+ * PostGainDb - Gain applied after compression (in dB).
+ * SummedLink - Whether to use summed (true) or maxed (false) linking.
+ * RmsSensing - Whether to use RMS (true) or Peak (false) sensing.
+ * AttackTimeMin - Minimum attack time (in seconds).
+ * AttackTimeMax - Maximum attack time. Automates when min != max.
+ * ReleaseTimeMin - Minimum release time (in seconds).
+ * ReleaseTimeMax - Maximum release time. Automates when min != max.
+ * Ratio - Compression ratio (x:1). Set to 0 for true limiter.
+ * ThresholdDb - Triggering threshold (in dB).
+ * KneeDb - Knee width (below threshold; in dB).
+ * SampleRate - Sample rate to process.
+ */
+Compressor *CompressorInit(const ALfloat PreGainDb, const ALfloat PostGainDb,
+ const ALboolean SummedLink, const ALboolean RmsSensing, const ALfloat AttackTimeMin,
+ const ALfloat AttackTimeMax, const ALfloat ReleaseTimeMin, const ALfloat ReleaseTimeMax,
+ const ALfloat Ratio, const ALfloat ThresholdDb, const ALfloat KneeDb,
+ const ALuint SampleRate);
+
+void ApplyCompression(struct Compressor *Comp, const ALsizei NumChans, const ALsizei SamplesToDo,
+ ALfloat (*restrict OutBuffer)[BUFFERSIZE]);
+
+inline ALuint GetCompressorSampleRate(const Compressor *Comp)
+{ return Comp->SampleRate; }
+
+#endif /* MASTERING_H */
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 7af7b4bb..bbf64349 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -959,34 +959,6 @@ vector_al_string SearchDataFiles(const char *match, const char *subdir);
typedef ALfloat ALfloatBUFFERSIZE[BUFFERSIZE];
typedef ALfloat ALfloat2[2];
-
-/* The compressor requires the following information for proper
- * initialization:
- *
- * PreGainDb - Gain applied before detection (in dB).
- * PostGainDb - Gain applied after compression (in dB).
- * SummedLink - Whether to use summed (true) or maxed (false) linking.
- * RmsSensing - Whether to use RMS (true) or Peak (false) sensing.
- * AttackTimeMin - Minimum attack time (in seconds).
- * AttackTimeMax - Maximum attack time. Automates when min != max.
- * ReleaseTimeMin - Minimum release time (in seconds).
- * ReleaseTimeMax - Maximum release time. Automates when min != max.
- * Ratio - Compression ratio (x:1). Set to 0 for true limiter.
- * ThresholdDb - Triggering threshold (in dB).
- * KneeDb - Knee width (below threshold; in dB).
- * SampleRate - Sample rate to process.
- */
-struct Compressor *CompressorInit(const ALfloat PreGainDb, const ALfloat PostGainDb,
- const ALboolean SummedLink, const ALboolean RmsSensing, const ALfloat AttackTimeMin,
- const ALfloat AttackTimeMax, const ALfloat ReleaseTimeMin, const ALfloat ReleaseTimeMax,
- const ALfloat Ratio, const ALfloat ThresholdDb, const ALfloat KneeDb,
- const ALuint SampleRate);
-
-ALuint GetCompressorSampleRate(const struct Compressor *Comp);
-
-void ApplyCompression(struct Compressor *Comp, const ALsizei NumChans, const ALsizei SamplesToDo,
- ALfloat (*restrict OutBuffer)[BUFFERSIZE]);
-
#ifdef __cplusplus
}
#endif