stereo ping pong for delay

master
zetaPRIME 2022-03-19 03:21:04 -04:00
parent 3af05f2cc3
commit 3af34095d2
4 changed files with 15 additions and 2 deletions

7
notes
View File

@ -33,9 +33,14 @@ parameters {
TODO {
settings dialog {
about-license info
probably some audio engine settings {
working sample rate
buffer sizes and such
}
}
ping-pong for delay
- ping-pong for delay
revert-to-saved menu action

View File

@ -47,6 +47,7 @@ namespace Xybrid::Data {
r *= m;
}
inline AudioFrame flip() { return {r, l}; }
inline AudioFrame clamp(double m = 1.0) { return { std::clamp(l, -m, m), std::clamp(r, -m, m) }; }
static AudioFrame gainBalanceMult(double gain, double balance = 0.0);

View File

@ -84,6 +84,7 @@ void Delay::process() {
if (!buf.areIndexesValid()) buf.normalizeIndexes(); // make sure we can actually reach the point we need
int i = frames + buf.firstIndex();
buf[i] += (fCurrent * delayMult) + (fOut * fbMult);
if (pingPong) buf[i] = buf[i].flip();
if (oc) (*out)[f] = fCurrent + fOut;
if (wc) (*wout)[f] = fOut;
@ -93,6 +94,7 @@ void Delay::process() {
void Delay::saveData(QCborMap& m) const {
m[qs("time")] = delayTime;
m[qs("inBeats")] = timeInBeats;
m[qs("pingPong")] = pingPong;
m[qs("amount")] = amount;
m[qs("feedback")] = feedback;
}
@ -100,6 +102,7 @@ void Delay::saveData(QCborMap& m) const {
void Delay::loadData(const QCborMap& m) {
delayTime = m.value("time").toDouble(delayTime);
timeInBeats = m.value("inBeats").toBool(timeInBeats);
pingPong = m.value("pingPong").toBool(pingPong);
amount = m.value("amount").toDouble(amount);
feedback = m.value("feedback").toDouble(feedback);
}
@ -109,7 +112,9 @@ void Delay::onGadgetCreated() {
auto l = new LayoutGadget(obj);
(new KnobGadget(l))->bind(delayTime)->setLabel(qs("Time"))->setRange(0.0, 5.0, 0.001)->setDefault(0.5);
(new ToggleGadget(l))->bind(timeInBeats)->setColor({191, 127, 255})->setToolTip(qs("BPM-relative"));
auto l2 = (new LayoutGadget(l, true))->setMetrics(0, 4);
(new ToggleGadget(l2))->bind(timeInBeats)->setColor({191, 127, 255})->setToolTip(qs("BPM-relative"));
(new ToggleGadget(l2))->bind(pingPong)->setColor({127, 191, 255})->setToolTip(qs("Stereo ping-pong"));
//l->addSpacer();
(new KnobGadget(l))->bind(amount)->setLabel(qs("Level"))->setTextFunc(KnobGadget::textPercent)->setDefault(0.5);
//l->addSpacer();

View File

@ -12,6 +12,8 @@ namespace Xybrid::Effects {
double delayTime = 0.5;
bool timeInBeats = false;
bool pingPong = false;
double amount = 0.5;
double feedback = 0.0;