9
9
DynamicRangeCompressorParameterThreshold,
10
10
DynamicRangeCompressorParameterAttackDuration,
11
11
DynamicRangeCompressorParameterReleaseDuration,
12
+ DynamicRangeCompressorParameterGain,
13
+ DynamicRangeCompressorParameterDryWetMix,
12
14
};
13
15
14
16
class DynamicRangeCompressorDSP : public SoundpipeDSPBase {
19
21
ParameterRamper thresholdRamp;
20
22
ParameterRamper attackDurationRamp;
21
23
ParameterRamper releaseDurationRamp;
24
+ ParameterRamper gainRamp;
25
+ ParameterRamper dryWetMixRamp;
22
26
23
27
public:
24
28
DynamicRangeCompressorDSP () {
25
29
parameters[DynamicRangeCompressorParameterRatio] = &ratioRamp;
26
30
parameters[DynamicRangeCompressorParameterThreshold] = &thresholdRamp;
27
31
parameters[DynamicRangeCompressorParameterAttackDuration] = &attackDurationRamp;
28
32
parameters[DynamicRangeCompressorParameterReleaseDuration] = &releaseDurationRamp;
33
+ parameters[DynamicRangeCompressorParameterGain] = &gainRamp;
34
+ parameters[DynamicRangeCompressorParameterDryWetMix] = &dryWetMixRamp;
29
35
}
30
36
31
37
void init (int channelCount, double sampleRate) override {
@@ -64,6 +70,14 @@ void process(FrameRange range) override {
64
70
65
71
sp_compressor_compute (sp, compressor0, &leftIn, &leftOut);
66
72
sp_compressor_compute (sp, compressor1, &rightIn, &rightOut);
73
+
74
+ float gain = gainRamp.getAndStep ();
75
+ leftOut *= gain;
76
+ rightOut *= gain;
77
+
78
+ float dryWetMix = dryWetMixRamp.getAndStep ();
79
+ outputSample (0 , i) = dryWetMix * leftOut + (1 .0f - dryWetMix) * leftIn;
80
+ outputSample (1 , i) = dryWetMix * rightOut + (1 .0f - dryWetMix) * rightIn;
67
81
}
68
82
}
69
83
};
@@ -73,3 +87,5 @@ void process(FrameRange range) override {
73
87
AK_REGISTER_PARAMETER(DynamicRangeCompressorParameterThreshold)
74
88
AK_REGISTER_PARAMETER(DynamicRangeCompressorParameterAttackDuration)
75
89
AK_REGISTER_PARAMETER(DynamicRangeCompressorParameterReleaseDuration)
90
+ AK_REGISTER_PARAMETER(DynamicRangeCompressorParameterGain)
91
+ AK_REGISTER_PARAMETER(DynamicRangeCompressorParameterDryWetMix)
0 commit comments