Skip to content

Commit 974bfd3

Browse files
committed
Wet linking
1 parent daa40de commit 974bfd3

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Plateau2/Plateau2.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,9 @@ Plateau2::Plateau2(const InstanceInfo& info)
392392
void Plateau2::SelectTank(bool tank2) {
393393
tank2Selected = tank2;
394394
bool linkedTank2 = link1to2 ? false : tank2;
395-
for (int i = kDryLeftKnob; i <= kWetKnob; i++) {
396-
Knobs[i]->SelectTank(tank2);
397-
}
395+
Knobs[kDryLeftKnob]->SelectTank(tank2);
396+
Knobs[kDryRightKnob]->SelectTank(tank2);
397+
Knobs[kWetKnob]->SelectTank(linkedTank2);
398398
for (int i = kInputLowDampKnob; i <= kVarianceKnob; i++) {
399399
Knobs[i]->SelectTank(linkedTank2);
400400
}
@@ -490,12 +490,16 @@ bool Plateau2::WindowIsOpen() {
490490

491491
void Plateau2::OnParamChange(int index) {
492492
if (link1to2) {
493-
if (index >= kInputLowDamp1 && index <= kSoftClip1 && index != kFreeze1 && index != kClear1) //Tank 1 range
493+
const bool linkedTank1Param = index == kWet1 || (index >= kInputLowDamp1 && index <= kSoftClip1 && index != kFreeze1 && index != kClear1);
494+
const bool linkedTank2Param = index == kWet2 || (index >= kInputLowDamp2 && index <= kSoftClip2 && index != kFreeze2 && index != kClear2);
495+
if (linkedTank1Param)
494496
{
495497
UpdateParameter(index, index);
496498
UpdateParameter(index, index + offset); //Copy to tank 2
499+
// Keep Tank 2 parameter values in sync while linked so unlink preserves the current linked values.
500+
GetParam(index + offset)->Set(GetParam(index)->Value());
497501
}
498-
else if (!(index >= kInputLowDamp2 && index <= kSoftClip2 && index != kFreeze2 && index != kClear2)) //Not tank 2 range
502+
else if (!linkedTank2Param)
499503
{
500504
UpdateParameter(index, index);
501505
}
@@ -529,12 +533,16 @@ void Plateau2::UpdateParameter(int sourceIndex, int targetIndex)
529533
{
530534
link1to2 = GetParam(kLink1to2)->Value() >= 0.5;
531535
if (link1to2) {
536+
UpdateParameter(kWet1, kWet2); //Copy wet to tank 2
537+
GetParam(kWet2)->Set(GetParam(kWet1)->Value());
532538
for (int i = kInputLowDamp1; i <= kModVariance1; i++) {
533539
UpdateParameter(i, i + offset); //Copy to tank 2
540+
GetParam(i + offset)->Set(GetParam(i)->Value());
534541
}
535542
//Skip Freeze and Clear
536543
for (int i = kTunedMode1; i <= kSoftClip1; i++) {
537544
UpdateParameter(i, i + offset); //Copy to tank 2
545+
GetParam(i + offset)->Set(GetParam(i)->Value());
538546
}
539547
}
540548
else

0 commit comments

Comments
 (0)