@@ -213,6 +213,13 @@ Plateau2::Plateau2(const InstanceInfo& info)
213213
214214 const ISVG HelpButtonSVG = pGraphics->LoadSVG (HELPBUTTON_FN);
215215
216+ const ISVG CopyOffSVG = pGraphics->LoadSVG (COPYOFF_FN);
217+ const ISVG CopyOnSVG = pGraphics->LoadSVG (COPYON_FN);
218+
219+ const ISVG SwapOffSVG = pGraphics->LoadSVG (SWAPOFF_FN);
220+ const ISVG SwapOnSVG = pGraphics->LoadSVG (SWAPON_FN);
221+
222+
216223 // Main page Switches
217224 Switches[0 ] = new LEDSwitch (IRECT::MakeXYWH (-11 .526f , 404 .802f -45 , 102 , 102 ), LEDScale, LedOffSVG, LedOnBothSVG, LedOnBothSVG, kFreeze , kFreeze );
218225 Switches[1 ] = new LEDSwitch (IRECT::MakeXYWH (-11 .526f , 404 .802f +30 , 102 , 102 ), LEDScale, LedOffSVG, LedOn1SVG, LedOn2SVG, kFreeze1 , kFreeze2 );
@@ -238,11 +245,47 @@ Plateau2::Plateau2(const InstanceInfo& info)
238245
239246 // Help Button
240247 Buttons[2 ] = new LEDButton (IRECT::MakeXYWH (129 .5f , 535 , 56 , 56 ), 1 , HelpButtonSVG, HelpButtonSVG, HelpButtonSVG, [this ](IControl* button) {this ->GetUI ()->OpenURL (" https://github.com/rubyswolf/iPlateau/wiki" );});
241- Buttons[2 ]->Hide (true );
242248
243- for (int i = 0 ; i < kNumButtons ; i++) {
249+ // Tank Copy Button
250+ Buttons[3 ] = new LEDButton (IRECT::MakeXYWH (15 , 460 , 80 , 80 ), 1 , CopyOffSVG, CopyOnSVG, CopyOnSVG, [this ](IControl* button) {
251+ for (int i = kEnable1 ; i <= k1to2HighDamp; i++) {
252+ GetParam (i + offset)->Set (GetParam (i)->Value ());
253+ }
254+ for (int i = 0 ; i < kNumKnobs ; i++) {
255+ Knobs[i]->SetValue (GetParam (tank2Selected ? Knobs[i]->Param2Idx : Knobs[i]->Param1Idx )->GetNormalized ());
256+ Knobs[i]->SetDirty (true );
257+ }
258+ for (int i = 0 ; i < kNumSwitches ; i++) {
259+ Switches[i]->SetValue (GetParam (tank2Selected ? Switches[i]->Param2Idx : Switches[i]->Param1Idx )->GetNormalized ());
260+ Switches[i]->SetDirty (true );
261+ }
262+ });
263+
264+ // Tank Swap Button
265+ Buttons[4 ] = new LEDButton (IRECT::MakeXYWH (220 , 460 , 80 , 80 ), 1 , SwapOffSVG, SwapOnSVG, SwapOnSVG, [this ](IControl* button) {
266+ for (int i = kEnable1 ; i <= k1to2HighDamp; i++) {
267+ double temp = GetParam (i)->Value ();
268+ GetParam (i)->Set (GetParam (i + offset)->Value ());
269+ GetParam (i + offset)->Set (temp);
270+ }
271+ for (int i = 0 ; i < kNumKnobs ; i++) {
272+ Knobs[i]->SetValue (GetParam (tank2Selected ? Knobs[i]->Param2Idx : Knobs[i]->Param1Idx )->GetNormalized ());
273+ Knobs[i]->SetDirty (true );
274+ }
275+ for (int i = 0 ; i < kNumSwitches ; i++) {
276+ Switches[i]->SetValue (GetParam (tank2Selected ? Switches[i]->Param2Idx : Switches[i]->Param1Idx )->GetNormalized ());
277+ Switches[i]->SetDirty (true );
278+ }
279+ });
280+
281+ for (int i = 0 ; i <= 1 ; i++) {
244282 pGraphics->AttachControl (Buttons[i]);
245283 }
284+ for (int i = 2 ; i <= 4 ; i++) {
285+ pGraphics->AttachControl (Buttons[i]);
286+ Buttons[i]->Hide (true );
287+ }
288+
246289
247290 // Dump Preset Button
248291 // pGraphics->AttachControl((new LEDButton(IRECT::MakeXYWH(0, 40, 102, 102), LEDScale, LedOffSVG, LedOnBothSVG, LedOnBothSVG, [this](IControl* button) {DumpMakePresetSrc("C:/dev/Plugins/Plateau/Plateau2/preset.txt");})));
@@ -303,25 +346,25 @@ Plateau2::Plateau2(const InstanceInfo& info)
303346
304347void Plateau2::SelectTank (bool tank2) {
305348 tank2Selected = tank2;
349+ bool linkedTank2 = link1to2 ? false : tank2;
306350 for (int i = kDryKnob ; i <= kWetKnob ; i++) {
307351 Knobs[i]->SelectTank (tank2);
308352 }
309353 for (int i = kInputLowDampKnob ; i <= kVarianceKnob ; i++) {
310- Knobs[i]->SelectTank (link1to2 ? false : tank2 );
354+ Knobs[i]->SelectTank (linkedTank2 );
311355 }
312356 for (int i = kInputKnob ; i < kNumKnobs ; i++) {
313357 Knobs[i]->SelectTank (tank2);
314358 }
315359
316-
317360 Switches[0 ]->SelectTank (tank2);
318361 Switches[1 ]->SelectTank (tank2);
319- Switches[2 ]->SelectTank (link1to2 ? false : tank2 );
320- Switches[3 ]->SelectTank (link1to2 ? false : tank2 );
362+ Switches[2 ]->SelectTank (linkedTank2 );
363+ Switches[3 ]->SelectTank (linkedTank2 );
321364 Switches[4 ]->SelectTank (tank2);
322- Switches[5 ]->SelectTank (link1to2 ? false : tank2 );
365+ Switches[5 ]->SelectTank (linkedTank2 );
323366 Switches[6 ]->SelectTank (tank2);
324- Switches[7 ]->SelectTank (link1to2 ? false : tank2 );
367+ Switches[7 ]->SelectTank (linkedTank2 );
325368 Switches[8 ]->SelectTank (tank2);
326369 Switches[9 ]->SelectTank (tank2);
327370
@@ -369,7 +412,9 @@ void Plateau2::UpdatePageVisibility()
369412 for (int i = 5 ; i <= 8 ; i++) {
370413 Switches[i]->Hide (currentPage != 1 );
371414 }
372- Buttons[2 ]->Hide (currentPage != 1 );
415+ for (int i = 2 ; i <= 4 ; i++) {
416+ Buttons[i]->Hide (currentPage != 1 );
417+ }
373418
374419 // Routing page
375420 Switches[9 ]->Hide (currentPage != 2 );
@@ -403,7 +448,6 @@ void Plateau2::OnParamChange(int index) {
403448 if (index >= kInputLowDamp1 && index <= kSoftClip1 && index != kFreeze1 && index != kClear1 ) // Tank 1 range
404449 {
405450 UpdateParameter (index, index);
406- constexpr int offset = kEnable2 - kEnable1 ;
407451 UpdateParameter (index, index + offset); // Copy to tank 2
408452 }
409453 else if (!(index >= kInputLowDamp2 && index <= kSoftClip2 && index != kFreeze2 && index != kClear2 )) // Not tank 2 range
@@ -436,7 +480,6 @@ void Plateau2::UpdateParameter(int sourceIndex, int targetIndex)
436480 case kLink1to2 :
437481 {
438482 link1to2 = GetParam (kLink1to2 )->Value () >= 0.5 ;
439- constexpr int offset = kEnable2 - kEnable1 ;
440483 if (link1to2) {
441484 for (int i = kInputLowDamp1 ; i <= kModVariance1 ; i++) {
442485 UpdateParameter (i, i + offset); // Copy to tank 2
@@ -708,7 +751,7 @@ void Plateau2::UpdateParameter(int sourceIndex, int targetIndex)
708751 SetParameterValue (kDiffusionDecay1 , clip<double >(GetParam (kDiffusionDecay1 )->Value (), 23.0769 , 76.92307 ) / 100 );
709752 SetParameterValue (kDiffusionDecay2 , clip<double >(GetParam (kDiffusionDecay2 )->Value (), 23.0769 , 76.92307 ) / 100 );
710753
711- Knobs[kDiffusionDecayKnob ]->SetValue ((tank2Selected ? GetParam ( kDiffusionDecay2 )-> Value () : GetParam ( kDiffusionDecay1 )->Value () ) / 100 );
754+ Knobs[kDiffusionDecayKnob ]->SetValue (GetParam (tank2Selected ? kDiffusionDecay2 : kDiffusionDecay1 )->Value () / 100 );
712755 Knobs[kDiffusionDecayKnob ]->SetDirty (false );
713756 }
714757 break ;
0 commit comments