bpm relativity for auto pan (and consistency in delay)
parent
5d9b39f84b
commit
cf81f91a0b
1
notes
1
notes
|
@ -43,7 +43,6 @@ TODO {
|
|||
revert-to-saved menu action
|
||||
|
||||
distortion effect
|
||||
> auto pan
|
||||
|
||||
uh... maybe save/load samples as s16 instead of f32
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ void AutoPan::process() {
|
|||
auto ts = audioEngine->curTickSize();
|
||||
|
||||
auto eRate = rate;
|
||||
if (bpmRelative) eRate *= audioEngine->curTempo() / 60.0;
|
||||
|
||||
auto tl = static_cast<double>(ts) / static_cast<double>(sr); // tick length
|
||||
for (size_t f = 0; f < ts; f++) {
|
||||
|
@ -69,11 +70,13 @@ void AutoPan::process() {
|
|||
void AutoPan::saveData(QCborMap& m) const {
|
||||
m[qs("level")] = level;
|
||||
m[qs("rate")] = rate;
|
||||
m[qs("bpmRelative")] = bpmRelative;
|
||||
}
|
||||
|
||||
void AutoPan::loadData(const QCborMap& m) {
|
||||
level = m.value("level").toDouble(level);
|
||||
rate = m.value("rate").toDouble(rate);
|
||||
bpmRelative = m.value("bpmRelative").toBool(bpmRelative);
|
||||
}
|
||||
|
||||
void AutoPan::onGadgetCreated() {
|
||||
|
@ -81,5 +84,7 @@ void AutoPan::onGadgetCreated() {
|
|||
auto l = new LayoutGadget(obj);
|
||||
|
||||
(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);
|
||||
(new ToggleGadget(l2))->bind(bpmRelative)->setColor({191, 127, 255})->setToolTip(qs("BPM-relative"));
|
||||
KnobGadget::autoBalance(l, level)->setLabel(qs("Level"));
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Xybrid::Effects {
|
|||
class AutoPan : public Data::Node {
|
||||
double level;
|
||||
double rate = 1.0;
|
||||
bool bpmRelative = false;
|
||||
|
||||
double cyc; // current cycle tracking
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void Delay::process() {
|
|||
auto fbMult = std::pow(feedback, 2);
|
||||
|
||||
// calculate number of frames ahead to write to the buffer
|
||||
int frames = static_cast<int>(delayTime * static_cast<double>(audioEngine->curSampleRate()) * (timeInBeats ? (60.0 / audioEngine->curTempo()) : 1.0));
|
||||
int frames = static_cast<int>(delayTime * static_cast<double>(audioEngine->curSampleRate()) * (bpmRelative ? (60.0 / audioEngine->curTempo()) : 1.0));
|
||||
|
||||
// enlarge buffer if too small
|
||||
if (auto mc = frames+1; buf.capacity() < mc) buf.setCapacity(mc);
|
||||
|
@ -89,7 +89,7 @@ void Delay::process() {
|
|||
|
||||
void Delay::saveData(QCborMap& m) const {
|
||||
m[qs("time")] = delayTime;
|
||||
m[qs("inBeats")] = timeInBeats;
|
||||
m[qs("bpmRelative")] = bpmRelative;
|
||||
m[qs("pingPong")] = pingPong;
|
||||
m[qs("amount")] = amount;
|
||||
m[qs("feedback")] = feedback;
|
||||
|
@ -97,7 +97,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);
|
||||
bpmRelative = m.value("bpmRelative").toBool(m.value("inBeats").toBool(bpmRelative));
|
||||
pingPong = m.value("pingPong").toBool(pingPong);
|
||||
amount = m.value("amount").toDouble(amount);
|
||||
feedback = m.value("feedback").toDouble(feedback);
|
||||
|
@ -109,7 +109,7 @@ void Delay::onGadgetCreated() {
|
|||
|
||||
(new KnobGadget(l))->bind(delayTime)->setLabel(qs("Time"))->setRange(0.0, 5.0, 0.001, -1, 0.01)->setDefault(0.5);
|
||||
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(bpmRelative)->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);
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Xybrid::Effects {
|
|||
QContiguousCache<Data::AudioFrame> buf;
|
||||
|
||||
double delayTime = 0.5;
|
||||
bool timeInBeats = false;
|
||||
bool bpmRelative = false;
|
||||
|
||||
bool pingPong = false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue