From a6032be6a99e2743ba73e0561ec1ebf68dfc3637 Mon Sep 17 00:00:00 2001 From: zetaPRIME Date: Fri, 25 Mar 2022 04:34:05 -0400 Subject: [PATCH] knobGadget.setSize, autopan phase --- xybrid/nodes/effect/autopan.cpp | 8 ++++++-- xybrid/nodes/effect/autopan.h | 1 + xybrid/ui/gadgets/knobgadget.h | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/xybrid/nodes/effect/autopan.cpp b/xybrid/nodes/effect/autopan.cpp index b0c0f16..7a3232d 100644 --- a/xybrid/nodes/effect/autopan.cpp +++ b/xybrid/nodes/effect/autopan.cpp @@ -59,7 +59,7 @@ void AutoPan::process() { auto tl = static_cast(ts) / static_cast(sr); // tick length for (size_t f = 0; f < ts; f++) { AudioFrame fCurrent = (*in)[f]; - auto cc = cyc + (static_cast(f) / static_cast(sr)) * eRate; + auto cc = cyc+phase + (static_cast(f) / static_cast(sr)) * eRate; (*out)[f] = fCurrent.gainBalance(0.0, level * std::sin(cc * 2*PI)); } @@ -70,21 +70,25 @@ void AutoPan::process() { void AutoPan::saveData(QCborMap& m) const { m[qs("level")] = level; m[qs("rate")] = rate; + m[qs("phase")] = phase; m[qs("bpmRelative")] = bpmRelative; } void AutoPan::loadData(const QCborMap& m) { level = m.value("level").toDouble(level); rate = m.value("rate").toDouble(rate); + phase = m.value("phase").toDouble(phase); bpmRelative = m.value("bpmRelative").toBool(bpmRelative); } void AutoPan::onGadgetCreated() { if (!obj) return; auto l = new LayoutGadget(obj); + l->setMetrics(-1, 2); (new KnobGadget(l))->bind(rate)->setLabel(qs("Rate"))->setRange(0.0, 8.0, 0.01, -1, 0.001)->setDefault(1.0); - auto l2 = (new LayoutGadget(l, true))->setMetrics(0, 4); + auto l2 = (new LayoutGadget(l, true))->setMetrics(0, 2); (new ToggleGadget(l2))->bind(bpmRelative)->setColor({191, 127, 255})->setToolTip(qs("BPM-relative")); + KnobGadget::autoPercent(l2, phase)->setLabel(qs("Phase"))->setSize(22); KnobGadget::autoBalance(l, level)->setLabel(qs("Level")); } diff --git a/xybrid/nodes/effect/autopan.h b/xybrid/nodes/effect/autopan.h index 2a4d965..548d29d 100644 --- a/xybrid/nodes/effect/autopan.h +++ b/xybrid/nodes/effect/autopan.h @@ -6,6 +6,7 @@ namespace Xybrid::Effects { class AutoPan : public Data::Node { double level; double rate = 1.0; + double phase = 0.0; bool bpmRelative = false; double cyc; // current cycle tracking diff --git a/xybrid/ui/gadgets/knobgadget.h b/xybrid/ui/gadgets/knobgadget.h index 534d6e1..8cd7f19 100644 --- a/xybrid/ui/gadgets/knobgadget.h +++ b/xybrid/ui/gadgets/knobgadget.h @@ -61,6 +61,7 @@ namespace Xybrid::UI { inline KnobGadget* setLabel(const QString& s) { label->setText(s); dirty = true; update(); return this; } inline KnobGadget* setTextFunc(const std::function& f) { fText = f; dirty = true; update(); return this; } + inline KnobGadget* setSize(decltype(size) s) { this->size = s; return this; } inline KnobGadget* setRange(double min, double max, double step = -1, int px = -1, double sub = -1) { this->min = min; this->max = max;