aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-09-30 12:08:01 -0700
committerChris Robinson <[email protected]>2018-09-30 12:08:01 -0700
commit1860b2ec8a1927ce98e516f498dbdf19419ae0a6 (patch)
tree85dab3bee6298b9c20cd6f1ca003b43fd56801cb /Alc
parent7ad4f753a42a4ff9c4ce2be0a848f8aaccb86454 (diff)
Make the Compressor struct opaque
Diffstat (limited to 'Alc')
-rw-r--r--Alc/ALc.c4
-rw-r--r--Alc/mastering.c69
-rw-r--r--Alc/mastering.h71
3 files changed, 71 insertions, 73 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 70663780..de6a2b75 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -2254,8 +2254,8 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
al_free(device->Limiter);
device->Limiter = CreateDeviceLimiter(device, log10f(thrshld) * 20.0f);
- device->FixedLatency += (ALuint)(device->Limiter->LookAhead * DEVICE_CLOCK_RES /
- device->Frequency);
+ device->FixedLatency += (ALuint)(GetCompressorLookAhead(device->Limiter) *
+ DEVICE_CLOCK_RES / device->Frequency);
}
else
{
diff --git a/Alc/mastering.c b/Alc/mastering.c
index b92390bb..f443de37 100644
--- a/Alc/mastering.c
+++ b/Alc/mastering.c
@@ -7,8 +7,67 @@
#include "almalloc.h"
-extern inline ALsizei GetCompressorChannelCount(const Compressor *Comp);
-extern inline ALuint GetCompressorSampleRate(const Compressor *Comp);
+/* These structures assume BUFFERSIZE is a power of 2.
+ */
+typedef struct SlidingHold {
+ ALfloat Values[BUFFERSIZE];
+ ALsizei Expiries[BUFFERSIZE];
+ ALsizei LowerIndex;
+ ALsizei UpperIndex;
+ ALsizei Length;
+} SlidingHold;
+
+/* General topology and basic automation was based on the following paper:
+ *
+ * D. Giannoulis, M. Massberg and J. D. Reiss,
+ * "Parameter Automation in a Dynamic Range Compressor,"
+ * Journal of the Audio Engineering Society, v61 (10), Oct. 2013
+ *
+ * Available (along with supplemental reading) at:
+ *
+ * http://c4dm.eecs.qmul.ac.uk/audioengineering/compressors/
+ */
+typedef struct Compressor {
+ ALsizei NumChans;
+ ALuint SampleRate;
+
+ struct {
+ ALuint Knee : 1;
+ ALuint Attack : 1;
+ ALuint Release : 1;
+ ALuint PostGain : 1;
+ ALuint Declip : 1;
+ } Auto;
+
+ ALsizei LookAhead;
+
+ ALfloat PreGain;
+ ALfloat PostGain;
+
+ ALfloat Threshold;
+ ALfloat Slope;
+ ALfloat Knee;
+
+ ALfloat Attack;
+ ALfloat Release;
+
+ alignas(16) ALfloat SideChain[2*BUFFERSIZE];
+ alignas(16) ALfloat CrestFactor[BUFFERSIZE];
+
+ SlidingHold *Hold;
+ ALfloat (*Delay)[BUFFERSIZE];
+ ALsizei DelayIndex;
+
+ ALfloat CrestCoeff;
+ ALfloat GainEstimate;
+ ALfloat AdaptCoeff;
+
+ ALfloat LastPeakSq;
+ ALfloat LastRmsSq;
+ ALfloat LastRelease;
+ ALfloat LastAttack;
+ ALfloat LastGainDev;
+} Compressor;
/* This sliding hold follows the input level with an instant attack and a
@@ -342,7 +401,7 @@ static void SignalDelay(Compressor *Comp, const ALsizei SamplesToDo, ALfloat (*r
* ReleaseTimeMin - Release time (in seconds). Acts as a maximum when
* automating release time.
*/
-Compressor* CompressorInit(const ALuint NumChans, const ALuint SampleRate,
+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,
@@ -463,3 +522,7 @@ void ApplyCompression(Compressor *Comp, const ALsizei SamplesToDo, ALfloat (*res
memmove(sideChain, sideChain+SamplesToDo, Comp->LookAhead*sizeof(ALfloat));
}
+
+
+ALsizei GetCompressorLookAhead(const Compressor *Comp)
+{ return Comp->LookAhead; }
diff --git a/Alc/mastering.h b/Alc/mastering.h
index 67738543..b68b0de1 100644
--- a/Alc/mastering.h
+++ b/Alc/mastering.h
@@ -6,68 +6,7 @@
/* For BUFFERSIZE. */
#include "alMain.h"
-/* These structures assume BUFFERSIZE is a power of 2.
- */
-typedef struct SlidingHold
-{
- ALfloat Values[BUFFERSIZE];
- ALsizei Expiries[BUFFERSIZE];
- ALsizei LowerIndex;
- ALsizei UpperIndex;
- ALsizei Length;
-} SlidingHold;
-
-/* General topology and basic automation was based on the following paper:
- *
- * D. Giannoulis, M. Massberg and J. D. Reiss,
- * "Parameter Automation in a Dynamic Range Compressor,"
- * Journal of the Audio Engineering Society, v61 (10), Oct. 2013
- *
- * Available (along with supplemental reading) at:
- *
- * http://c4dm.eecs.qmul.ac.uk/audioengineering/compressors/
- */
-typedef struct Compressor {
- ALsizei NumChans;
- ALuint SampleRate;
-
- struct {
- ALuint Knee : 1;
- ALuint Attack : 1;
- ALuint Release : 1;
- ALuint PostGain : 1;
- ALuint Declip : 1;
- } Auto;
-
- ALsizei LookAhead;
-
- ALfloat PreGain;
- ALfloat PostGain;
-
- ALfloat Threshold;
- ALfloat Slope;
- ALfloat Knee;
-
- ALfloat Attack;
- ALfloat Release;
-
- alignas(16) ALfloat SideChain[2*BUFFERSIZE];
- alignas(16) ALfloat CrestFactor[BUFFERSIZE];
-
- SlidingHold *Hold;
- ALfloat (*Delay)[BUFFERSIZE];
- ALsizei DelayIndex;
-
- ALfloat CrestCoeff;
- ALfloat GainEstimate;
- ALfloat AdaptCoeff;
-
- ALfloat LastPeakSq;
- ALfloat LastRmsSq;
- ALfloat LastRelease;
- ALfloat LastAttack;
- ALfloat LastGainDev;
-} Compressor;
+struct Compressor;
/* The compressor is initialized with the following settings:
*
@@ -93,7 +32,7 @@ typedef struct Compressor {
* ReleaseTimeMin - Release time (in seconds). Acts as a maximum when
* automating release time.
*/
-Compressor* CompressorInit(const ALuint NumChans, const ALuint SampleRate,
+struct 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,
@@ -105,10 +44,6 @@ Compressor* CompressorInit(const ALuint NumChans, const ALuint SampleRate,
void ApplyCompression(struct Compressor *Comp, const ALsizei SamplesToDo,
ALfloat (*restrict OutBuffer)[BUFFERSIZE]);
-inline ALsizei GetCompressorChannelCount(const Compressor *Comp)
-{ return Comp->NumChans; }
-
-inline ALuint GetCompressorSampleRate(const Compressor *Comp)
-{ return Comp->SampleRate; }
+ALsizei GetCompressorLookAhead(const struct Compressor *Comp);
#endif /* MASTERING_H */