Skip to content

Commit

Permalink
UI Temposycn Support; More UI API cleanup
Browse files Browse the repository at this point in the history
1. Temposync now supported on the params and works for LFO rate
2. createComponent doesn't need the tedious .meta.id any more
  • Loading branch information
baconpaul committed Dec 24, 2024
1 parent 1a2c853 commit 345c1a1
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 31 deletions.
12 changes: 6 additions & 6 deletions src/ui/dahdsr-components.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ template <typename Comp, typename Patch> struct DAHDSRComponents
c->addAndMakeVisible(*slider[idx]);
c->addAndMakeVisible(*lab[idx]);
};
mk(v.delay.meta.id, 0, "D");
mk(v.attack.meta.id, 1, "A");
mk(v.hold.meta.id, 2, "H");
mk(v.decay.meta.id, 3, "D");
mk(v.sustain.meta.id, 4, "S");
mk(v.release.meta.id, 5, "R");
mk(v.delay, 0, "D");
mk(v.attack, 1, "A");
mk(v.hold, 2, "H");
mk(v.decay, 3, "D");
mk(v.sustain, 4, "S");
mk(v.release, 5, "R");

titleLab = std::make_unique<RuledLabel>();
titleLab->setText("Envelope");
Expand Down
19 changes: 15 additions & 4 deletions src/ui/lfo-components.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,31 @@ template <typename Comp, typename Patch> struct LFOComponents
void setupLFO(SixSinesEditor &e, const Patch &v)
{
auto c = asComp();
createComponent(e, *c, v.lfoRate.meta.id, rate, rateD);
createComponent(e, *c, v.lfoRate, rate, rateD);
rateL = std::make_unique<jcmp::Label>();
rateL->setText("Rate");
c->addAndMakeVisible(*rate);
c->addAndMakeVisible(*rateL);

createComponent(e, *c, v.lfoDeform.meta.id, deform, deformD);
createComponent(e, *c, v.lfoDeform, deform, deformD);
deformL = std::make_unique<jcmp::Label>();
deformL->setText("Deform");
c->addAndMakeVisible(*deform);
c->addAndMakeVisible(*deformL);

createComponent(e, *c, v.lfoShape.meta.id, shape, shapeD);
createComponent(e, *c, v.lfoShape, shape, shapeD);
c->addAndMakeVisible(*shape);

titleLab = std::make_unique<RuledLabel>();
titleLab->setText("LFO");
c->addAndMakeVisible(*titleLab);

createComponent(e, *c, v.tempoSync, tempoSync, tempoSyncD);
tempoSync->setDrawMode(jcmp::ToggleButton::DrawMode::LABELED);
tempoSync->setLabel("Sync");
c->addAndMakeVisible(*tempoSync);

rateD->setTemposyncPowerPartner(tempoSyncD.get());
}

juce::Rectangle<int> layoutLFOAt(int x, int y, int extraWidth = 0)
Expand All @@ -68,7 +75,8 @@ template <typename Comp, typename Patch> struct LFOComponents
positionTitleLabelAt(x, y, w + uicMargin + uicKnobSize + extraWidth, titleLab);

auto bx = juce::Rectangle<int>(x, y + lh, w, h - lh);
shape->setBounds(bx.withHeight(2 * uicLabeledKnobHeight + uicMargin));
shape->setBounds(bx.withHeight(2 * uicLabeledKnobHeight - uicMargin - lh));
tempoSync->setBounds(bx.withTrimmedTop(2 * uicLabeledKnobHeight - lh).withHeight(lh));

bx = bx.translated(w + uicMargin, 0);
positionKnobAndLabel(bx.getX(), bx.getY(), rate, rateL);
Expand All @@ -86,6 +94,9 @@ template <typename Comp, typename Patch> struct LFOComponents
std::unique_ptr<jcmp::MultiSwitch> shape;
std::unique_ptr<PatchDiscrete> shapeD;
std::unique_ptr<RuledLabel> titleLab;

std::unique_ptr<jcmp::ToggleButton> tempoSync;
std::unique_ptr<PatchDiscrete> tempoSyncD;
};
} // namespace baconpaul::six_sines::ui
#endif // LFO_COMPONENTS_H
2 changes: 1 addition & 1 deletion src/ui/macro-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ MacroPanel::MacroPanel(SixSinesEditor &e) : jcmp::NamedPanel("Macros"), HasEdito
auto &mn = editor.patchCopy.macroNodes;
for (auto i = 0U; i < numOps; ++i)
{
createComponent(editor, *this, mn[i].level.meta.id, knobs[i], knobsData[i], i);
createComponent(editor, *this, mn[i].level, knobs[i], knobsData[i], i);
knobs[i]->setDrawLabel(false);
addAndMakeVisible(*knobs[i]);

Expand Down
2 changes: 1 addition & 1 deletion src/ui/main-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace baconpaul::six_sines::ui
{
MainPanel::MainPanel(SixSinesEditor &e) : jcmp::NamedPanel("Main"), HasEditor(e)
{
createComponent(editor, *this, editor.patchCopy.output.level.meta.id, lev, levData);
createComponent(editor, *this, editor.patchCopy.output.level, lev, levData);
lev->setDrawLabel(false);
addAndMakeVisible(*lev);
levLabel = std::make_unique<jcmp::Label>();
Expand Down
4 changes: 2 additions & 2 deletions src/ui/main-sub-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ MainSubPanel::MainSubPanel(SixSinesEditor &e) : HasEditor(e), DAHDSRComponents()
{
setupDAHDSR(e, e.patchCopy.output);

createComponent(editor, *this, e.patchCopy.output.velSensitivity.meta.id, velSen, velSenD);
createComponent(editor, *this, e.patchCopy.output.velSensitivity, velSen, velSenD);
addAndMakeVisible(*velSen);
velSenL = std::make_unique<jcmp::Label>();
velSenL->setText("Vel Sens");
Expand All @@ -32,7 +32,7 @@ MainSubPanel::MainSubPanel(SixSinesEditor &e) : HasEditor(e), DAHDSRComponents()
velTitle->setText("Play");
addAndMakeVisible(*velTitle);

createComponent(editor, *this, e.patchCopy.output.playMode.meta.id, playMode, playModeD);
createComponent(editor, *this, e.patchCopy.output.playMode, playMode, playModeD);
playMode->direction = sst::jucegui::components::MultiSwitch::VERTICAL;
addAndMakeVisible(*playMode);
};
Expand Down
10 changes: 5 additions & 5 deletions src/ui/matrix-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ MatrixPanel::MatrixPanel(SixSinesEditor &e) : jcmp::NamedPanel("Matrix"), HasEdi
auto &mn = editor.patchCopy.selfNodes;
for (auto i = 0U; i < numOps; ++i)
{
createComponent(editor, *this, mn[i].fbLevel.meta.id, Sknobs[i], SknobsData[i], i, true);
createComponent(editor, *this, mn[i].fbLevel, Sknobs[i], SknobsData[i], i, true);
Sknobs[i]->setDrawLabel(false);
addAndMakeVisible(*Sknobs[i]);

createComponent(editor, *this, mn[i].active.meta.id, Spower[i], SpowerData[i], i, true);
createComponent(editor, *this, mn[i].active, Spower[i], SpowerData[i], i, true);
Spower[i]->setDrawMode(sst::jucegui::components::ToggleButton::DrawMode::GLYPH);
Spower[i]->setGlyph(sst::jucegui::components::GlyphPainter::POWER);
addAndMakeVisible(*Spower[i]);
Expand All @@ -43,16 +43,16 @@ MatrixPanel::MatrixPanel(SixSinesEditor &e) : jcmp::NamedPanel("Matrix"), HasEdi
auto &mx = editor.patchCopy.matrixNodes;
for (auto i = 0U; i < matrixSize; ++i)
{
createComponent(editor, *this, mx[i].level.meta.id, Mknobs[i], MknobsData[i], i, false);
createComponent(editor, *this, mx[i].level, Mknobs[i], MknobsData[i], i, false);
Mknobs[i]->setDrawLabel(false);
addAndMakeVisible(*Mknobs[i]);

createComponent(editor, *this, mx[i].active.meta.id, Mpower[i], MpowerData[i], i, false);
createComponent(editor, *this, mx[i].active, Mpower[i], MpowerData[i], i, false);
Mpower[i]->setDrawMode(sst::jucegui::components::ToggleButton::DrawMode::GLYPH);
Mpower[i]->setGlyph(sst::jucegui::components::GlyphPainter::POWER);
addAndMakeVisible(*Mpower[i]);

createComponent(editor, *this, mx[i].pmOrRM.meta.id, Mpmrm[i], MpmrmD[i], i, false);
createComponent(editor, *this, mx[i].pmOrRM, Mpmrm[i], MpmrmD[i], i, false);
Mpmrm[i]->direction = sst::jucegui::components::MultiSwitch::HORIZONTAL;
addAndMakeVisible(*Mpmrm[i]);

Expand Down
4 changes: 2 additions & 2 deletions src/ui/matrix-sub-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ void MatrixSubPanel::setSelectedIndex(int idx)
setupDAHDSR(editor, m);
setupLFO(editor, m);

createComponent(editor, *this, m.lfoToDepth.meta.id, lfoToDepth, lfoToDepthD);
createComponent(editor, *this, m.lfoToDepth, lfoToDepth, lfoToDepthD);
addAndMakeVisible(*lfoToDepth);
lfoToDepthL = std::make_unique<jcmp::Label>();
lfoToDepthL->setText("Depth");
addAndMakeVisible(*lfoToDepthL);

createComponent(editor, *this, m.envLfoSum.meta.id, lfoMul, lfoMulD);
createComponent(editor, *this, m.envLfoSum, lfoMul, lfoMulD);
addAndMakeVisible(*lfoMul);
lfoMul->direction = jcmp::MultiSwitch::VERTICAL;

Expand Down
4 changes: 2 additions & 2 deletions src/ui/mixer-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ MixerPanel::MixerPanel(SixSinesEditor &e) : jcmp::NamedPanel("Mixer"), HasEditor
auto &mn = editor.patchCopy.mixerNodes;
for (auto i = 0U; i < numOps; ++i)
{
createComponent(editor, *this, mn[i].level.meta.id, knobs[i], knobsData[i], i);
createComponent(editor, *this, mn[i].level, knobs[i], knobsData[i], i);
knobs[i]->setDrawLabel(false);
addAndMakeVisible(*knobs[i]);

createComponent(editor, *this, mn[i].active.meta.id, power[i], powerData[i], i);
createComponent(editor, *this, mn[i].active, power[i], powerData[i], i);
power[i]->setDrawMode(sst::jucegui::components::ToggleButton::DrawMode::GLYPH);
power[i]->setGlyph(sst::jucegui::components::GlyphPainter::POWER);
addAndMakeVisible(*power[i]);
Expand Down
13 changes: 12 additions & 1 deletion src/ui/patch-data-bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ struct PatchContinuous : jdat::Continuous
float getValue() const override { return p->value; }
std::string getValueAsStringFor(float f) const override
{
if (tsPowerPartner && tsPowerPartner->getValue())
{
auto r = p->meta.valueToString(
f, sst::basic_blocks::params::ParamMetaData::FeatureState().withTemposync(true));
if (r.has_value())
return *r;
}
auto r = p->meta.valueToString(f);
if (r.has_value())
return *r;
Expand All @@ -78,6 +85,9 @@ struct PatchContinuous : jdat::Continuous
bool isBipolar() const override { return p->meta.isBipolar(); }
float getMin() const override { return p->meta.minVal; }
float getMax() const override { return p->meta.maxVal; }

jdat::Discrete *tsPowerPartner{nullptr};
void setTemposyncPowerPartner(jdat::Discrete *d) { tsPowerPartner = d; }
};

struct PatchDiscrete : jdat::Discrete
Expand Down Expand Up @@ -127,9 +137,10 @@ struct PatchDiscrete : jdat::Discrete
};

template <typename P, typename T, typename Q, typename... Args>
void createComponent(SixSinesEditor &e, P &panel, uint32_t id, std::unique_ptr<T> &cm,
void createComponent(SixSinesEditor &e, P &panel, const Param &parm, std::unique_ptr<T> &cm,
std::unique_ptr<Q> &pc, Args... args)
{
auto id = parm.meta.id;
pc = std::make_unique<Q>(e, id);
cm = std::make_unique<T>();

Expand Down
4 changes: 2 additions & 2 deletions src/ui/self-sub-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ void SelfSubPanel::setSelectedIndex(int idx)
setupDAHDSR(editor, editor.patchCopy.selfNodes[idx]);
setupLFO(editor, editor.patchCopy.selfNodes[idx]);

createComponent(editor, *this, n.lfoToFB.meta.id, lfoToFb, lfoToFbD);
createComponent(editor, *this, n.lfoToFB, lfoToFb, lfoToFbD);
addAndMakeVisible(*lfoToFb);
lfoToFbL = std::make_unique<jcmp::Label>();
lfoToFbL->setText("Depth");
addAndMakeVisible(*lfoToFbL);

createComponent(editor, *this, n.envLfoSum.meta.id, lfoMul, lfoMulD);
createComponent(editor, *this, n.envLfoSum, lfoMul, lfoMulD);
addAndMakeVisible(*lfoMul);
lfoMul->direction = jcmp::MultiSwitch::VERTICAL;

Expand Down
4 changes: 2 additions & 2 deletions src/ui/source-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ SourcePanel::SourcePanel(SixSinesEditor &e) : jcmp::NamedPanel("Source"), HasEdi
auto &mn = editor.patchCopy.sourceNodes;
for (auto i = 0U; i < numOps; ++i)
{
createComponent(editor, *this, mn[i].ratio.meta.id, knobs[i], knobsData[i], i);
createComponent(editor, *this, mn[i].ratio, knobs[i], knobsData[i], i);
knobs[i]->setDrawLabel(false);
addAndMakeVisible(*knobs[i]);

createComponent(editor, *this, mn[i].active.meta.id, power[i], powerData[i], i);
createComponent(editor, *this, mn[i].active, power[i], powerData[i], i);
power[i]->setDrawMode(sst::jucegui::components::ToggleButton::DrawMode::GLYPH);
power[i]->setGlyph(sst::jucegui::components::GlyphPainter::POWER);
addAndMakeVisible(*power[i]);
Expand Down
6 changes: 3 additions & 3 deletions src/ui/source-sub-panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ void SourceSubPanel::setSelectedIndex(size_t idx)
setupDAHDSR(editor, sn);
setupLFO(editor, sn);

createComponent(editor, *this, sn.envToRatio.meta.id, envToRatio, envToRatioD);
createComponent(editor, *this, sn.envToRatio, envToRatio, envToRatioD);
envToRatioL = std::make_unique<jcmp::Label>();
envToRatioL->setText("Env");
addAndMakeVisible(*envToRatioL);
addAndMakeVisible(*envToRatio);

createComponent(editor, *this, sn.lfoToRatio.meta.id, lfoToRatio, lfoToRatioD);
createComponent(editor, *this, sn.lfoToRatio, lfoToRatio, lfoToRatioD);
addAndMakeVisible(*lfoToRatio);
lfoToRatioL = std::make_unique<jcmp::Label>();
lfoToRatioL->setText("LFO");
addAndMakeVisible(*lfoToRatioL);

createComponent(editor, *this, sn.envLfoSum.meta.id, lfoMul, lfoMulD);
createComponent(editor, *this, sn.envLfoSum, lfoMul, lfoMulD);
addAndMakeVisible(*lfoMul);
lfoMul->direction = jcmp::MultiSwitch::VERTICAL;

Expand Down

0 comments on commit 345c1a1

Please sign in to comment.