Skip to content

Commit 0802aa6

Browse files
committed
Fix rack Delay effect mode selector
1 parent 472026a commit 0802aa6

4 files changed

Lines changed: 58 additions & 2 deletions

File tree

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ New features:
1818

1919
Bug fixes:
2020

21+
* Fix rack Delay effect mode selector (Mono/Ping Pong/Tape had no effect)
22+
2123
Other:
2224

2325
* Double the maximum number of devices and effects per rack to 16

src/unit_tests/effects_test/effects_test.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,58 @@ void EffectsTest::test_delayEffect_shouldSyncParameters()
637637
}
638638
}
639639

640+
void EffectsTest::test_delayEffect_typeParameter_shouldSelectPingPong()
641+
{
642+
// Regression: selecting a mode via the parameter system (as the UI does) must actually change the mode.
643+
// delayType is a discrete parameter whose value is the raw enum index; PingPong is index 2.
644+
Delay effect;
645+
effect.setSampleRate(44100.0);
646+
647+
const auto setParam = [&](const QString & key, float value) {
648+
if (const auto p = effect.parameter(key.toStdString()); p) {
649+
p->get().setValue(value);
650+
}
651+
};
652+
653+
setParam(Constants::NahdXml::xmlKeyDelayType(), 2.0f); // PingPong
654+
setParam(Constants::NahdXml::xmlKeyDelayMix(), 1.0f); // Fully wet
655+
setParam(Constants::NahdXml::xmlKeyDelayFeedback(), 1.0f);
656+
setParam(Constants::NahdXml::xmlKeyDelayDepth(), 1.0f); // Max width
657+
setParam(Constants::NahdXml::xmlKeyDelayTime(), 0.01f); // 0.01 * 10s = 0.1s
658+
effect.sync();
659+
660+
const int delaySamples = static_cast<int>(0.1 * 44100.0);
661+
662+
// Feed a pulse to the LEFT channel only.
663+
double left = 1.0;
664+
double right = 0.0;
665+
effect.process(left, right);
666+
667+
// First echo appears on the LEFT (same side as input).
668+
for (int i = 0; i + 1 < delaySamples; i++) {
669+
double l = 0.0;
670+
double r = 0.0;
671+
effect.process(l, r);
672+
}
673+
left = 0.0;
674+
right = 0.0;
675+
effect.process(left, right);
676+
QVERIFY(std::abs(left - 1.0) < 1.0e-3);
677+
QVERIFY(std::abs(right) < 1.0e-3);
678+
679+
// Second echo bounces to the RIGHT: this only happens in PingPong mode.
680+
for (int i = 0; i + 1 < delaySamples; i++) {
681+
double l = 0.0;
682+
double r = 0.0;
683+
effect.process(l, r);
684+
}
685+
left = 0.0;
686+
right = 0.0;
687+
effect.process(left, right);
688+
QVERIFY(std::abs(left) < 1.0e-3);
689+
QVERIFY(std::abs(right - 1.0) < 1.0e-3);
690+
}
691+
640692
void EffectsTest::test_compressorEffect_shouldReduceGainAndHandleLookahead()
641693
{
642694
Compressor effect;

src/unit_tests/effects_test/effects_test.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ private slots:
4040
void test_delayEffect_shouldProcessPingPongMode();
4141
void test_delayEffect_shouldProcessTapeMode();
4242
void test_delayEffect_shouldSyncParameters();
43+
void test_delayEffect_typeParameter_shouldSelectPingPong();
4344
void test_compressorEffect_shouldReduceGainAndHandleLookahead();
4445
void test_limiterEffect_shouldLimitPeaksToCeiling();
4546
void test_limiterEffect_shouldBoostToCeiling();

src/view/qml/Dialogs/DelayDialog.qml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ Dialog {
6868
model: ["Stereo", "Mono", "PingPong", "Tape"]
6969
currentIndex: {
7070
effectRackController.revision;
71-
return Math.round(effectRackController.parameterValue(root.effectIndex, "delayType") * 3);
71+
// delayType is a discrete parameter whose value is the raw enum index (0..3).
72+
return Math.round(effectRackController.parameterValue(root.effectIndex, "delayType"));
7273
}
73-
onActivated: index => effectRackController.setParameterValue(root.effectIndex, "delayType", index / 3.0)
74+
onActivated: index => effectRackController.setParameterValue(root.effectIndex, "delayType", index)
7475
Layout.fillWidth: true
7576
}
7677
}

0 commit comments

Comments
 (0)