@@ -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+
640692void EffectsTest::test_compressorEffect_shouldReduceGainAndHandleLookahead ()
641693{
642694 Compressor effect;
0 commit comments