Skip to content

Commit cb5342e

Browse files
committed
Add Balance parameter on CostelloReverb
1 parent f6db4ce commit cb5342e

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

Sources/CSoundpipeAudioKit/Effects/CostelloReverbDSP.mm

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@
77
enum CostelloReverbParameter : AUParameterAddress {
88
CostelloReverbParameterFeedback,
99
CostelloReverbParameterCutoffFrequency,
10+
CostelloReverbParameterBalance,
1011
};
1112

1213
class CostelloReverbDSP : public SoundpipeDSPBase {
1314
private:
1415
sp_revsc *revsc;
1516
ParameterRamper feedbackRamp;
1617
ParameterRamper cutoffFrequencyRamp;
18+
ParameterRamper balanceRamp{1.0};
1719

1820
public:
1921
CostelloReverbDSP() {
2022
parameters[CostelloReverbParameterFeedback] = &feedbackRamp;
2123
parameters[CostelloReverbParameterCutoffFrequency] = &cutoffFrequencyRamp;
24+
parameters[CostelloReverbParameterBalance] = &balanceRamp;
2225
}
2326

2427
void init(int channelCount, double sampleRate) override {
@@ -47,14 +50,20 @@ void process(FrameRange range) override {
4750
float leftIn = inputSample(0, i);
4851
float rightIn = inputSample(1, i);
4952

50-
float &leftOut = outputSample(0, i);
51-
float &rightOut = outputSample(1, i);
53+
float leftWet;
54+
float rightWet;
5255

53-
sp_revsc_compute(sp, revsc, &leftIn, &rightIn, &leftOut, &rightOut);
56+
sp_revsc_compute(sp, revsc, &leftIn, &rightIn, &leftWet, &rightWet);
57+
58+
float bal = balanceRamp.getAndStep();
59+
60+
outputSample(0, i) = bal * leftWet + (1-bal) * leftIn;
61+
outputSample(1, i) = bal * rightWet + (1-bal) * rightIn;
5462
}
5563
}
5664
};
5765

5866
AK_REGISTER_DSP(CostelloReverbDSP, "rvsc")
5967
AK_REGISTER_PARAMETER(CostelloReverbParameterFeedback)
6068
AK_REGISTER_PARAMETER(CostelloReverbParameterCutoffFrequency)
69+
AK_REGISTER_PARAMETER(CostelloReverbParameterBalance)

Sources/SoundpipeAudioKit/Effects/CostelloReverb.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ public class CostelloReverb: Node {
4646
/// Low-pass cutoff frequency.
4747
@Parameter(cutoffFrequencyDef) public var cutoffFrequency: AUValue
4848

49+
/// Dry/wet mix.
50+
public static let balanceDef = NodeParameterDef(
51+
identifier: "balance",
52+
name: "Balance",
53+
address: akGetParameterAddress("CostelloReverbParameterBalance"),
54+
defaultValue: 1,
55+
range: 0 ... 1,
56+
unit: .percent
57+
)
58+
59+
/// Dry/wet mix. Should be a value between 0-1.
60+
@Parameter(balanceDef) public var balance: AUValue
61+
4962
// MARK: - Initialization
5063

5164
/// Initialize this reverb node

Tests/SoundpipeAudioKitTests/GenericNodeTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class GenericNodeTests: XCTestCase {
121121
nodeParameterTest(md5: "ffd48f502e2a5b2a7027d42b917a6667", factory: { ChowningReverb(input) })
122122
nodeParameterTest(md5: "56e76b5bd1d59d77ad4bd670f605f191", factory: { Clipper(input) })
123123
nodeParameterTest(md5: "c9ab35b7818db6a9af4edfbe2cb83927", factory: { CombFilterReverb(input) })
124-
nodeParameterTest(md5: "1d47a6a4a24667064b747cd6571d0874", factory: { CostelloReverb(input) })
124+
nodeParameterTest(md5: "bfdb04ada04582bac1c59626207726c2", factory: { CostelloReverb(input) })
125125
nodeParameterTest(md5: "6d17509eee0059105454f3cad4499586", factory: { DCBlock(input) })
126126
nodeParameterTest(md5: "fd4e315defe463bd643dd0c797cfd1f2", factory: { Decimator(input) })
127127
nodeParameterTest(md5: "4e240310041e20bdc886dd5eb285e89c", factory: { Distortion(input) })

0 commit comments

Comments
 (0)