Skip to content

Commit 99cdd29

Browse files
committed
Added Stereo Settings
1 parent 6fe1dd8 commit 99cdd29

18 files changed

+1037
-89
lines changed

Plateau2/Plateau2.cpp

Lines changed: 55 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ Plateau2::Plateau2(const InstanceInfo& info)
2828
GetParam(kPreDelay1)->InitSeconds("Pre Delay 1", 0., 0., 0.5, 0.01);
2929
GetParam(kNesting1)->InitBool("Nested Tank Diffusion 1", false);
3030
GetParam(kInputNesting1)->InitBool("Nested Input Diffusion 1", false);
31-
//GetParam(kDiffusionDecay1)->InitPercentage("Tank Diffusion Decay 1", 75, 20, 130);
3231
GetParam(kDiffusionDecay1)->InitPercentage("Tank Diffusion Decay 1", 100);
32+
GetParam(kInput1)->InitPercentage("Input 1", 100);
33+
GetParam(kStereoSource1)->InitPercentage("Stereo Source 1", 0, -100, 100);
34+
GetParam(kWidth1)->InitPercentage("Stereo Width 1", 100, 0, 200);
35+
GetParam(kPan1)->InitPercentage("Pan 1", 0, -100, 100);
3336

3437

3538
GetParam(kEnable2)->InitBool("Tank 2 Enable", false);
@@ -52,6 +55,10 @@ Plateau2::Plateau2(const InstanceInfo& info)
5255
GetParam(kNesting2)->InitBool("Nested Tank Diffusion 2", false);
5356
GetParam(kInputNesting2)->InitBool("Nested Input Diffusion 2", false);
5457
GetParam(kDiffusionDecay2)->InitPercentage("Tank Diffusion Decay 2", 100);
58+
GetParam(kInput2)->InitPercentage("Input 2", 100);
59+
GetParam(kStereoSource2)->InitPercentage("Stereo Source 2", 0, -100, 100);
60+
GetParam(kWidth2)->InitPercentage("Stereo Width 2", 100, 0, 200);
61+
GetParam(kPan2)->InitPercentage("Pan 2", 0, -100, 100);
5562

5663

5764
GetParam(kDanger)->InitBool("DANGER! Allow Unsafe Feedback Settings", false);
@@ -77,9 +84,9 @@ Plateau2::Plateau2(const InstanceInfo& info)
7784
pGraphics->AttachCornerResizer(EUIResizerMode::Scale, false);
7885
pGraphics->AttachSVGBackground(BACKGROUND_FN);
7986

80-
ISVG PageBackgrounds[kNumPages] = { pGraphics->LoadSVG(PAGEMAIN_FN), pGraphics->LoadSVG(PAGEEXTRAS_FN) };
81-
ISVG NextButtons[kNumPages] = { pGraphics->LoadSVG(NEXTEXTRAS_FN), pGraphics->LoadSVG(NEXTMAIN_FN) };
82-
ISVG PrevButtons[kNumPages] = { pGraphics->LoadSVG(PREVEXTRAS_FN), pGraphics->LoadSVG(PREVMAIN_FN) };
87+
ISVG PageBackgrounds[kNumPages] = { pGraphics->LoadSVG(PAGEMAIN_FN), pGraphics->LoadSVG(PAGEEXTRAS_FN), pGraphics->LoadSVG(PAGEROUTING_FN) };
88+
ISVG NextButtons[kNumPages] = { pGraphics->LoadSVG(NEXTEXTRAS_FN), pGraphics->LoadSVG(NEXTROUTING_FN), pGraphics->LoadSVG(NEXTMAIN_FN) };
89+
ISVG PrevButtons[kNumPages] = { pGraphics->LoadSVG(PREVROUTING_FN), pGraphics->LoadSVG(PREVMAIN_FN), pGraphics->LoadSVG(PREVEXTRAS_FN) };
8390

8491
PageBackgroundControl = new ISVGControl(pGraphics->GetBounds(), PageBackgrounds[0]);
8592
pGraphics->AttachControl(PageBackgroundControl);
@@ -108,20 +115,32 @@ Plateau2::Plateau2(const InstanceInfo& info)
108115
}
109116

110117
Knobs[12] = new NeedleKnob(IRECT::MakeXYWH(140, 140, 35, 35), NeedleSVG, NeedleBGSVG, NeedleFG1PNG, NeedleFG2PNG, kPreDelay1, kPreDelay2);
111-
Knobs[13] = new NeedleKnob(IRECT::MakeXYWH(203, 310, 56, 56), NeedleSVG, NeedleBGSVG, NeedleFG1PNG, NeedleFG2PNG, kDiffusionDecay1, kDiffusionDecay2);
118+
119+
Knobs[13] = new NeedleKnob(IRECT::MakeXYWH(233, 310, 56, 56), NeedleSVG, NeedleBGSVG, NeedleFG1PNG, NeedleFG2PNG, kDiffusionDecay1, kDiffusionDecay2);
112120
Knobs[13]->StartAngle = -72.6923f;
113121
Knobs[13]->EndAngle = 72.6923f;
122+
123+
Knobs[14] = new NeedleKnob(IRECT::MakeXYWH(93, 160, 56, 56), NeedleSVG, NeedleBGSVG, NeedleFG1PNG, NeedleFG2PNG, kInput1, kInput2);
124+
Knobs[15] = new NeedleKnob(IRECT::MakeXYWH(166, 160, 56, 56), NeedleSVG, NeedleBGSVG, NeedleFG1PNG, NeedleFG2PNG, kStereoSource1, kStereoSource2);
125+
126+
Knobs[16] = new NeedleKnob(IRECT::MakeXYWH(93, 250, 56, 56), NeedleSVG, NeedleBGSVG, NeedleFG1PNG, NeedleFG2PNG, kWidth1, kWidth2);
127+
Knobs[17] = new NeedleKnob(IRECT::MakeXYWH(166, 250, 56, 56), NeedleSVG, NeedleBGSVG, NeedleFG1PNG, NeedleFG2PNG, kPan1, kPan2);
114128

115-
for (int i = 12; i <= 13; i++) {
129+
for (int i = 12; i <= 17; i++) {
116130
pGraphics->AttachControl(Knobs[i]);
117131
Knobs[i]->Hide(true);
118132
}
119133

120-
NextButtonControl = new NavigatorButton(IRECT::MakeXYWH(220.572f, 125.695f, 82.306f, 30.f), [this, PageBackgrounds, NextButtons, PrevButtons](IControl* pCaller) {
134+
NextButtonControl = new NavigatorButton(IRECT::MakeXYWH(213, 125.695f, 90, 30), [this, PageBackgrounds, NextButtons, PrevButtons](IControl* pCaller) {
121135
ChangePage(1, PageBackgrounds, NextButtons, PrevButtons);
122-
}, pGraphics->LoadSVG(NEXTEXTRAS_FN));
136+
}, NextButtons[0]);
123137
pGraphics->AttachControl(NextButtonControl);
124138

139+
PrevButtonControl = new NavigatorButton(IRECT::MakeXYWH(12, 125.695f, 90, 30), [this, PageBackgrounds, NextButtons, PrevButtons](IControl* pCaller) {
140+
ChangePage(-1, PageBackgrounds, NextButtons, PrevButtons);
141+
}, PrevButtons[0]);
142+
pGraphics->AttachControl(PrevButtonControl);
143+
125144
double LEDScale = 0.2453054f;
126145

127146
const ISVG LedOffSVG = pGraphics->LoadSVG(LEDOFF_FN);
@@ -157,10 +176,10 @@ Plateau2::Plateau2(const InstanceInfo& info)
157176
pGraphics->AttachControl(Switches[i]);
158177
}
159178

160-
Switches[5] = new LEDSwitch(IRECT::MakeXYWH(228, 216, 102, 102), LEDScale, LedOffSVG, LedOn1SVG, LedOn2SVG, kNesting1, kNesting2);
179+
Switches[5] = new LEDSwitch(IRECT::MakeXYWH(210, 170, 102, 102), LEDScale, LedOffSVG, LedOn1SVG, LedOn2SVG, kNesting1, kNesting2);
161180

162181
//DANGER switch
163-
Switches[6] = new LEDSwitch(IRECT::MakeXYWH(130, 329, 56, 56).GetScaledAboutCentre(2), 1, DangerOffSVG, DangerOnSVG, DangerOnSVG, kDanger, kDanger);
182+
Switches[6] = new LEDSwitch(IRECT::MakeXYWH(102, 301, 112, 112), 1, DangerOffSVG, DangerOnSVG, DangerOnSVG, kDanger, kDanger);
164183

165184
for (int i = 5; i <= 6; i++) {
166185
pGraphics->AttachControl(Switches[i]);
@@ -189,7 +208,7 @@ void Plateau2::SelectTank(bool tank2) {
189208
for (int i = 0; i < kNumKnobs; i++) {
190209
Knobs[i]->SelectTank(tank2);
191210
//Knobs[i]->SetValue(GetParam(Knobs[i]->GetParamIdx())->Value());
192-
IEditorDelegate::SendParameterValueFromDelegate(Knobs[i]->GetParamIdx(), GetParam(Knobs[i]->GetParamIdx())->GetNormalized(), true);
211+
//IEditorDelegate::SendParameterValueFromDelegate(Knobs[i]->GetParamIdx(), GetParam(Knobs[i]->GetParamIdx())->GetNormalized(), true);
193212
}
194213
for (int i = 0; i < kNumSwitches; i++) {
195214
Switches[i]->SelectTank(tank2);
@@ -210,8 +229,7 @@ void Plateau2::ChangePage(int direction, const ISVG PageBackgrounds[kNumPages],
210229
PageBackgroundControl->SetDirty(false);
211230

212231
NextButtonControl->SetSVG(NextButtons[currentPage]);
213-
214-
//PrevButtonControl->SetSVG(PreviousButtons[currentPage]);
232+
PrevButtonControl->SetSVG(PreviousButtons[currentPage]);
215233

216234
UpdatePageVisibility();
217235
}
@@ -236,6 +254,11 @@ void Plateau2::UpdatePageVisibility()
236254
for (int i = 5; i <= 6; i++) {
237255
Switches[i]->Hide(currentPage != 1);
238256
}
257+
258+
//Routing page
259+
for (int i = 14; i <= 17; i++) {
260+
Knobs[i]->Hide(currentPage != 2);
261+
}
239262
}
240263

241264

@@ -244,16 +267,16 @@ void Plateau2::OnParamChange(int index)
244267
switch (index) {
245268
case kClear:
246269
if (initalizedInterface) {
247-
if (GetParam(kClear)->Value() >= 1) {
248-
SetParameterValue(kClear1, GetParam(kClear)->Value());
249-
SetParameterValue(kClear2, GetParam(kClear)->Value());
270+
if (GetParam(kClear)->Value() >= 0.5) {
271+
SetParameterValue(kClear1, GetParam(kClear)->Value());
272+
SetParameterValue(kClear2, GetParam(kClear)->Value());
250273
}
251274
}
252275
break;
253276
case kFreeze:
254277
if (initalizedInterface)
255278
{
256-
if (GetParam(kFreeze)->Value() >= 1) {
279+
if (GetParam(kFreeze)->Value() >= 0.5) {
257280
SetParameterValue(tank2Selected ? kFreeze1 : kFreeze2, 1.);
258281
Switches[1]->SetValue(1.);
259282
}
@@ -293,7 +316,7 @@ void Plateau2::OnParamChange(int index)
293316
case kDecay1:
294317
{
295318
double decay = GetParam(index)->Value();
296-
reverb1.setDecay(2.f * decay - decay * decay);
319+
reverb1.setDecay(2 * decay - decay * decay);
297320
break;
298321
}
299322
case kReverbLowDamp1:
@@ -442,6 +465,7 @@ void Plateau2::ProcessBlock(sample** inputs, sample** outputs, int nFrames)
442465

443466
const bool tank1Enabled = GetParam(kEnable1)->Value();
444467
const bool tank2Enabled = GetParam(kEnable2)->Value();
468+
const double input1 = GetParam(kInput1)->Value() / 100;
445469

446470
outputs[0][s] = inputs[0][s] * dryParam;
447471
if (nChans > 1)
@@ -494,13 +518,16 @@ void Plateau2::ProcessBlock(sample** inputs, sample** outputs, int nFrames)
494518
reverb1.freeze(frozen1);
495519
}
496520

497-
reverb1.process((double)(inputs[0][s] * envelope1._value), (double)(inputs[nChans > 1 ? 1 : 0][s] * envelope1._value));
521+
reverb1.process(balance((double)(inputs[0][s] * envelope1._value * input1), (double)(inputs[nChans > 1 ? 1 : 0][s] * envelope1._value * input1), GetParam(kStereoSource1)->Value()/100));
498522

499-
outputs[0][s] += reverb1.getLeftOutput() * wet1Param;
523+
std::tuple<double, double> output = seperation(reverb1.getLeftOutput() * wet1Param, reverb1.getRightOutput() * wet1Param, GetParam(kWidth1)->Value()/100);
524+
output = balance(std::get<0>(output), std::get<1>(output), GetParam(kPan1)->Value()/100);
525+
526+
outputs[0][s] += std::get<0>(output);
500527

501528
if (nChans > 1)
502529
{
503-
outputs[1][s] += reverb1.getRightOutput() * wet1Param;
530+
outputs[1][s] += std::get<1>(output);
504531
}
505532
}
506533

@@ -509,6 +536,7 @@ void Plateau2::ProcessBlock(sample** inputs, sample** outputs, int nFrames)
509536
const bool clear2Param = GetParam(kClear2)->Value() || GetParam(kClear)->Value();
510537
const bool freeze2Param = GetParam(kFreeze2)->Value();
511538
const double wet2Param = GetParam(kWet2)->Value() / 100;
539+
const double input2 = GetParam(kInput2)->Value() / 100;
512540

513541
if (clear2Param && !clear2 && cleared2) {
514542
cleared2 = false;
@@ -550,13 +578,16 @@ void Plateau2::ProcessBlock(sample** inputs, sample** outputs, int nFrames)
550578
reverb2.freeze(frozen2);
551579
}
552580

553-
reverb2.process((double)(inputs[0][s] * envelope2._value), (double)(inputs[nChans > 1 ? 1 : 0][s] * envelope2._value));
581+
reverb2.process(balance((double)(inputs[0][s] * envelope2._value * input2), (double)(inputs[nChans > 1 ? 1 : 0][s] * envelope2._value * input2), GetParam(kStereoSource2)->Value() / 100));
582+
583+
std::tuple<double, double> output = seperation(reverb2.getLeftOutput() * wet2Param, reverb2.getRightOutput() * wet2Param, GetParam(kWidth2)->Value()/100);
584+
output = balance(std::get<0>(output), std::get<1>(output), GetParam(kPan2)->Value()/100);
554585

555-
outputs[0][s] += reverb2.getLeftOutput() * wet2Param;
586+
outputs[0][s] += std::get<0>(output);
556587

557588
if (nChans > 1)
558589
{
559-
outputs[1][s] += reverb2.getRightOutput() * wet2Param;
590+
outputs[1][s] += std::get<1>(output);
560591
}
561592
}
562593
}

Plateau2/Plateau2.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ enum EParams
3939
kNesting1,
4040
kInputNesting1,
4141
kDiffusionDecay1,
42+
kInput1,
43+
kStereoSource1,
44+
kWidth1,
45+
kPan1,
4246

4347
kEnable2,
4448
kWet2,
@@ -60,16 +64,20 @@ enum EParams
6064
kNesting2,
6165
kInputNesting2,
6266
kDiffusionDecay2,
67+
kInput2,
68+
kStereoSource2,
69+
kWidth2,
70+
kPan2,
6371

6472
kDanger,
6573

6674
kNumParams
6775
};
6876

69-
const int kNumKnobs = 14;
77+
const int kNumKnobs = 18;
7078
const int kNumSwitches = 7;
7179
const int kNumButtons = 2;
72-
const int kNumPages = 2;
80+
const int kNumPages = 3;
7381

7482
using namespace iplug;
7583
using namespace igraphics;

Plateau2/config.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,15 @@
6161
#define BACKGROUND_FN "Background.svg"
6262
#define PAGEMAIN_FN "MainPage.svg"
6363
#define PAGEEXTRAS_FN "ExtrasPage.svg"
64+
#define PAGEROUTING_FN "RoutingPage.svg"
6465

6566
#define NEXTEXTRAS_FN "ExtrasNext.svg"
6667
#define NEXTMAIN_FN "MainNext.svg"
68+
#define NEXTROUTING_FN "RoutingNext.svg"
6769

68-
#define PREVEXTRAS_FN "ExtrasPrev.svg"
6970
#define PREVMAIN_FN "MainPrev.svg"
71+
#define PREVEXTRAS_FN "ExtrasPrev.svg"
72+
#define PREVROUTING_FN "RoutingPrev.svg"
7073

7174
#define NEEDLE_FN "NeedleDial.svg"
7275
#define NEEDLEBG_FN "NeedleDial-bg.svg"

Plateau2/dsp/Dattorro.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ void Dattorro1997Tank::setTimeScale(const double newTimeScale) {
127127
}
128128

129129
void Dattorro1997Tank::setDecay(const double newDecay) {
130-
decayParam = (double)(newDecay > 1.0 ? 1.0 :
131-
(newDecay < 0.0 ? 0.0 : newDecay));
130+
decayParam = newDecay;
132131
}
133132

134133
void Dattorro1997Tank::setModSpeed(const double newModSpeed) {
@@ -293,7 +292,10 @@ Dattorro::Dattorro(const double initMaxSampleRate,
293292
rightInputDCBlock.setCutoffFreq(20.0);
294293
}
295294

296-
void Dattorro::process(double leftInput, double rightInput) {
295+
void Dattorro::process(std::tuple<double, double> input) {
296+
double leftInput = std::get<0>(input);
297+
double rightInput = std::get<1>(input);
298+
297299
leftInputDCBlock.input = leftInput;
298300
rightInputDCBlock.input = rightInput;
299301
inputLpf.setCutoffFreq(inputHighCut);
@@ -376,7 +378,7 @@ void Dattorro::enableInputDiffusion(bool enable) {
376378

377379
void Dattorro::setDecay(double newDecay) {
378380
decay = newDecay;
379-
assert(decay <= 1.0);
381+
//assert(decay <= 1.0);
380382
tank.setDecay(decay);
381383
}
382384

Plateau2/dsp/Dattorro.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class Dattorro {
165165
Dattorro(const double initMaxSampleRate = 44100.0,
166166
const double initMaxLfoDepth = 16.0,
167167
const double initMaxTimeScale = 1.0);
168-
void process(double leftInput, double rightInput);
168+
void process(std::tuple<double, double> input);
169169
void clear();
170170

171171
void setTimeScale(double timeScale);

Plateau2/dsp/Utilities.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <string>
44
#include <cmath>
55

6+
#define _TAU 6.283185307179586
7+
68
//Linearly interpolates from a to b for parameter f from 0 to 1
79
template<typename T>
810
T linterp(T a, T b, T f) {
@@ -24,6 +26,26 @@ T semitone(T x) {
2426
return ((int)(x * 12)) * 0.0833333f;
2527
}
2628

29+
std::tuple<double, double> balance(double left, double right, double pan) {
30+
//Circular Equal Power Panning from pan -1 to 1
31+
return {
32+
left * std::cos((pan + 1) * _TAU / 8),
33+
right * std::sin((pan + 1) * _TAU / 8)
34+
};
35+
}
36+
37+
std::tuple<double, double> seperation(double left, double right, double width) {
38+
double mid = (left + right) * 0.5; // Mid (Mono)
39+
double side = (left - right) * 0.5; // Side (Stereo Width)
40+
41+
side *= width; // Adjust stereo width (1.0 = original, 0.0 = mono, >1.0 = widened)
42+
43+
double newLeft = mid + side;
44+
double newRight = mid - side;
45+
46+
return { newLeft, newRight };
47+
}
48+
2749
float pitch2freq(const float pitch);
2850

2951
uint32_t mwcRand(uint32_t& w, uint32_t& z);

0 commit comments

Comments
 (0)