Просмотр исходного кода

Limiter: the L2 law's latency known before the first block; Pro-Q 4 test knows Facet's dispersion parameters (rollup step 9)

Round 190lf's Limiter reported the classic look-ahead (66 samples at 44.1 kHz) until its first block on the L2 law, then
the law's window (59): Pdc188e's rule (issue #113: what an effect reports after prepare() is what it reports once it
runs) failed 4 times on random settings. makeEffect (slot) now builds the Limiter knowing its law, as Multiband Delay and
the Frequency Splitter do; reset() still clears the law's state, so the samples are the same. Parity190lgQ4: Facet's
storedParamCount is past round 190ln's dispersion [126 ... 128] now. Test rollup030_step9_limiter_l2_latency_is_known_before_the_first_block.
Ka1-S 2 недель назад
Родитель
Сommit
4905f1dbd0
3 измененных файлов с 32 добавлено и 3 удалено
  1. 5 1
      src/core/Effects.cpp
  2. 1 1
      tests/Parity190lgQ4Tests.inc
  3. 26 1
      tests/Rollup190luTests.inc

+ 5 - 1
src/core/Effects.cpp

@@ -945,7 +945,9 @@ class Limiter final : public Effect
 public:
     static constexpr double lookaheadSeconds = 0.0015;
 
-    Limiter()
+    // (rollup step 9: `l2` = the slot's settings run round 190lf's L2 law, so the latency PDC reads before the first block
+    // is the law's window, as after it: issue #113's rule, tests/Pdc188eTests.inc)
+    explicit Limiter (bool l2 = false) : l2Active (l2)
     {
         const auto size = (std::size_t) (lookaheadSeconds * maxSampleRate) + 4;
         delay[0].assign (size, 0.0f);
@@ -5112,6 +5114,8 @@ std::unique_ptr<Effect> makeEffect (const EffectSlot& slot)
         return std::make_unique<ParametricEq> (slot.params);
     if (slot.kind == EffectKind::frequencySplitter)
         return fsplit::make (slot.params);
+    if (slot.kind == EffectKind::limiter) // (rollup step 9: the L2 law's latency known at once)
+        return std::make_unique<Limiter> (limiterlaw::isL2 (slot.params[(std::size_t) limiterlaw::lawParam]));
     if (slot.kind == EffectKind::hardwareInsert) // its round trip (latency) known before the first block (round 164d)
         return std::make_unique<hwinsert::HardwareInsertFx> (&slot.params);
     if (slot.kind == EffectKind::flEmphasis) // its look-ahead / oversampling latency known before the first block (round 167f)

+ 1 - 1
tests/Parity190lgQ4Tests.inc

@@ -32,7 +32,7 @@ inline double gainAt (double rangeDb, float rev, double loud, double a, double b
 TEST (parity190lg_facet_auto_revision_is_hidden_set_by_the_translator_only)
 {
     using namespace lynx;
-    CHECK (facet::autoRevisionParam == facet::autoThresholdParam0 + facet::bands && facet::storedParamCount == facet::autoRevisionParam + 1);
+    CHECK (facet::autoRevisionParam == facet::autoThresholdParam0 + facet::bands && facet::dispersionCountParam == facet::autoRevisionParam + 1); // (rollup step 9: round 190ln's dispersion [126 … 128] follows)
     auto s = makeEffectSlot (EffectKind::facetEq);
     CHECK (s.params[(std::size_t) facet::autoRevisionParam] == 0.0f && savedEffectParamCount (s) <= (std::size_t) facet::paramCount);
     // a translated Pro-Q 4 band with Auto gets the revision

+ 26 - 1
tests/Rollup190luTests.inc

@@ -3,8 +3,10 @@
 //    notes (GitHub #198): the capture runs in process()'s per-piece loop only, so a block is refused while a channel is
 //    marked (BatchRefusal::midiBetweenUnits) and batched again once nothing is marked;
 //  - LYNX Tune reads its MIDI target channel's held notes in process(): it follows them (followsHeldNotesWith) only with
-//    a MIDI channel set, so a block with it stays piece by piece then.
+//    a MIDI channel set, so a block with it stays piece by piece then;
+//  - round 190lf's L2 law on the Limiter reports its latency before the first block.
 
+#include "core/LimiterLaw.h"
 #include "core/LynxTune.h"
 
 TEST (rollup030_step9_no_batched_block_while_plugins_own_notes_are_recorded)
@@ -61,3 +63,26 @@ TEST (rollup030_step9_lynx_tune_follows_held_notes_only_with_a_midi_channel)
     slot.params[(std::size_t) lynxtune::midiChannel] = 3.0f / 128.0f; // (Channel Rack channel 3)
     CHECK (fx->followsHeldNotesWith (slot.params));
 }
+
+// round 190lf's L2 law on the Limiter: the latency PDC reads after prepare(), before any block, is already the law's
+// window (issue #113's rule; tests/Pdc188eTests.inc found 66 before / 59 after at 44.1 kHz)
+TEST (rollup030_step9_limiter_l2_latency_is_known_before_the_first_block)
+{
+    using namespace lynx;
+    auto s = makeEffectSlot (EffectKind::limiter);
+    s.params[(std::size_t) limiterlaw::lawParam] = limiterlaw::l2LawValue;
+    for (const auto rate : { 44100.0, 48000.0, 96000.0 })
+    {
+        auto fx = makeEffect (s);
+        fx->prepare (rate);
+        const auto before = fx->latencySamples();
+        std::vector<float> l (512, 0.0f), r (512, 0.0f);
+        fx->process (l.data(), r.data(), 512, s.params, 120.0);
+        CHECK ((before) == (fx->latencySamples()));
+        if (rate == 48000.0)
+            CHECK ((before) == (64));
+    }
+    auto classic = makeEffect (makeEffectSlot (EffectKind::limiter));
+    classic->prepare (48000.0);
+    CHECK ((classic->latencySamples()) == (72));
+}