switch cutoff to a Param
parent
a7c26b9722
commit
369a7d979d
|
@ -70,27 +70,19 @@ namespace Xybrid::NodeLib {
|
|||
return Reader(this, r);
|
||||
}
|
||||
|
||||
inline QString saveName() {
|
||||
inline QString saveName() const {
|
||||
return name.toLower().remove(' ');
|
||||
}
|
||||
|
||||
inline void save(QCborMap& m, QString id = { }) {
|
||||
inline void save(QCborMap& m, QString id = { }) const {
|
||||
if (id.isEmpty()) id = saveName();
|
||||
m[id] = value;
|
||||
}
|
||||
|
||||
inline void load(QCborMap& m, QString id = { }) {
|
||||
inline void load(const QCborMap& m, QString id = { }) {
|
||||
if (id.isEmpty()) id = saveName();
|
||||
value = m.value(id).toDouble(value);
|
||||
vt = std::numeric_limits<double>::quiet_NaN();
|
||||
}
|
||||
|
||||
// - give it a Reader abstraction (grab from a "startTick" thing, call its next() function for tracking and values)
|
||||
// - functions to automatically save/load from QCborMap
|
||||
// binding a knobgadget automatically populates range+defaults(+label)
|
||||
// - figure out how to do range stuff
|
||||
// - "signed" extents only if min == -max
|
||||
|
||||
// meta info for parameter ports?
|
||||
};
|
||||
}
|
||||
|
|
|
@ -52,6 +52,10 @@ SVF::SVF() { }
|
|||
void SVF::init() {
|
||||
addPort(Port::Input, Port::Audio, 0);
|
||||
addPort(Port::Output, Port::Audio, 0);
|
||||
|
||||
//addPort(Port::Input, Port::Parameter, 0);
|
||||
//auto p = Param("Cutoff", 0.0, 16000.0, 0.0);
|
||||
cutoff.makePort(this);
|
||||
}
|
||||
|
||||
void SVF::reset() {
|
||||
|
@ -69,12 +73,13 @@ void SVF::process() {
|
|||
out->pull();
|
||||
|
||||
auto r = filter.scaledResonance(resonance);
|
||||
auto c = cutoff.start();
|
||||
|
||||
size_t ts = audioEngine->curTickSize();
|
||||
for (size_t f = 0; f < ts; f++) {
|
||||
AudioFrame inp = (*in)[f];
|
||||
|
||||
filter.process(inp, cutoff, r);
|
||||
filter.process(inp, c.next(), r);
|
||||
|
||||
switch (mode) {
|
||||
case Low:
|
||||
|
@ -96,13 +101,16 @@ void SVF::process() {
|
|||
}
|
||||
|
||||
void SVF::saveData(QCborMap& m) const {
|
||||
m[qs("cutoff")] = cutoff;
|
||||
//m[qs("cutoff")] = cutoff;
|
||||
cutoff.save(m);
|
||||
m[qs("resonance")] = resonance;
|
||||
m[qs("mode")] = mode;
|
||||
}
|
||||
|
||||
void SVF::loadData(const QCborMap& m) {
|
||||
cutoff = m.value("cutoff").toDouble(m.value("frequency").toDouble(cutoff));
|
||||
cutoff.load(m, "frequency");
|
||||
cutoff.load(m);
|
||||
//cutoff = m.value("cutoff").toDouble(m.value("frequency").toDouble(cutoff));
|
||||
resonance = m.value("resonance").toDouble(resonance);
|
||||
mode = static_cast<FilterMode>(m.value("mode").toInteger(mode));
|
||||
}
|
||||
|
|
|
@ -18,12 +18,15 @@
|
|||
#include "data/audioframe.h"
|
||||
|
||||
#include "nodelib/svfilter.h"
|
||||
#include "nodelib/param.h"
|
||||
|
||||
namespace Xybrid::Effects {
|
||||
class SVF : public Data::Node {
|
||||
NodeLib::SVFilter filter;
|
||||
|
||||
double cutoff = 6440.0;
|
||||
//double cutoff = 6440.0;
|
||||
NodeLib::Param cutoff = {"Cutoff", 0, 16000, 0};
|
||||
|
||||
double resonance = 0.0;
|
||||
|
||||
public:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "ui/gadgets/gadget.h"
|
||||
#include "nodelib/param.h"
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
@ -86,6 +87,24 @@ namespace Xybrid::UI {
|
|||
update();
|
||||
return this;
|
||||
}
|
||||
KnobGadget* bind(NodeLib::Param& par) {
|
||||
auto p = ∥
|
||||
fGet = [p] { return p->value; };
|
||||
fSet = [p](double d) {
|
||||
p->value = d;
|
||||
p->vt = std::numeric_limits<double>::quiet_NaN();
|
||||
};
|
||||
|
||||
// binding to one of these populates metadata
|
||||
min = p->min;
|
||||
max = p->max;
|
||||
defaultVal = p->def;
|
||||
label->setText(p->name);
|
||||
|
||||
dirty = true;
|
||||
update();
|
||||
return this;
|
||||
}
|
||||
|
||||
static QString textPercent(double);
|
||||
static QString textOffset(double);
|
||||
|
|
Loading…
Reference in New Issue