Maps190caTests.inc 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. // --- Round 190ca: state maps of the stand-in rows (docs/PARITY.md, the tail lab) -------------------------------------
  2. // The ValhallaDelay translator's Tape level, the per-device default presets of the Complete Access reverb role, and the
  3. // guarantee the maps rest on: a slot that already is a substitute is never translated again (saved projects keep theirs).
  4. namespace p190ca
  5. {
  6. inline lynx::ForeignPlugin vst3Named (const char* name, const std::string& xml = {}, const char* classHex = nullptr)
  7. {
  8. lynx::ForeignPlugin f;
  9. f.format = lynx::ForeignPlugin::Format::vst3;
  10. if (classHex != nullptr)
  11. {
  12. f.classId = substtest::classIdOf (classHex);
  13. f.hasClassId = true;
  14. }
  15. f.name = name;
  16. f.path = std::string ("C:\\Program Files\\Common Files\\VST3\\") + name + ".vst3";
  17. if (! xml.empty())
  18. f.state = substtest::flVst3State (substtest::juceXmlComponent (xml));
  19. return f;
  20. }
  21. inline int paramNamed (lynx::EffectKind kind, const char* name)
  22. {
  23. const auto& params = lynx::effectInfo (kind).params;
  24. for (std::size_t i = 0; i < params.size(); ++i)
  25. if (std::string (params[i].name) == name)
  26. return (int) i;
  27. return 0;
  28. }
  29. inline lynx::EffectSlot substituted (const lynx::ForeignPlugin& f)
  30. {
  31. lynx::EffectSlot slot;
  32. slot.kind = lynx::EffectKind::plugin;
  33. slot.plugin.name = f.name;
  34. slot.plugin.foreign = f;
  35. lynx::substituteEffectSlot (slot, lynx::pluginIdentity (f));
  36. return slot;
  37. }
  38. } // namespace p190ca
  39. TEST (p190ca_valhalladelay_tape_echoes_at_the_measured_level)
  40. {
  41. namespace ef = lynx::echosuite::echoform;
  42. const char* cls = "64545356614c7679616c68616c6c6164";
  43. // Tape (the default mode, 1/24): round 190ca's Output -1.67 dB is gone since round 190dl — the measured tape stage
  44. // (Law = Measured, which a translated slot gets) has the level law itself
  45. const auto tape = p190ca::substituted (p190ca::vst3Named ("ValhallaDelay", "<ValhallaDelay Mode=\"0.0416666679084301\" Mix=\"0.5\"/>", cls));
  46. CHECK (tape.kind == lynx::EffectKind::echoform && ef::modeOf (tape.params[ef::mode]) == ef::Mode::tape);
  47. CHECK (std::abs (tape.params[ef::output] - 0.5f) < 1e-6f && tape.params[ef::engineLaw] >= 0.5f);
  48. CHECK (std::abs (tape.params[ef::mix] - 0.5f) < 1e-6f); // the dry/wet setting is the reference's own
  49. // every other mode stays at 0 dB, the tape variants (DuckTape 10/24, ChromeTape 16/24) included: not measured
  50. for (const char* value : { "0.10", "0.1875", "0.4375", "0.5625", "0.6875", "0.7291667" })
  51. {
  52. const auto s = p190ca::substituted (p190ca::vst3Named ("ValhallaDelay", std::string ("<ValhallaDelay Mode=\"") + value + "\"/>", cls));
  53. CHECK (s.kind == lynx::EffectKind::echoform && std::abs (s.params[ef::output] - 0.5f) < 1e-6f);
  54. }
  55. }
  56. TEST (p190ca_reverb_role_devices_start_at_their_own_default)
  57. {
  58. using namespace lynx;
  59. const auto paramOf = [] (const EffectSlot& s, const char* name) { return s.params[(std::size_t) p190ca::paramNamed (s.kind, name)]; };
  60. // (round 190cm: FlexVerb and VerbSuite, all wet at their own default, keep the role's 25 % slot mix — a stand-in must
  61. // not open wetter than it did before round 190ca; the two plates' even mix is Foil's own Mix at a slot mix of 100 %)
  62. struct Want { const char* name; float mix, decay, voicing, type, width, slotMix; };
  63. for (const auto& w : { Want { "SSL PlateVerb", 0.2687f, 0.3028f, 1.0f, 0.29f, 0.5f, 1.0f }, Want { "SSL SpringVerb", 0.1933f, 0.4877f, 0.0f, 0.375f, 0.5f, 1.0f },
  64. Want { "SSL Native FlexVerb", 1.0f, 0.0541f, 0.0f, 0.875f, 0.4694f, 0.25f }, Want { "VerbSuite Classics", 1.0f, 0.278f, 1.0f, 0.29f, 0.5f, 0.25f } })
  65. {
  66. const auto s = p190ca::substituted (p190ca::vst3Named (w.name));
  67. CHECK (s.kind == EffectKind::foilPlate && s.isSubstitute());
  68. CHECK (s.mix == w.slotMix); // Foil's own Mix carries the device's dry/wet, or the role's slot mix when unknown
  69. CHECK (std::abs (paramOf (s, "Mix") - w.mix) < 1e-6f && std::abs (paramOf (s, "Decay") - w.decay) < 1e-6f);
  70. CHECK (std::abs (paramOf (s, "Voicing") - w.voicing) < 1e-6f && std::abs (paramOf (s, "Type") - w.type) < 1e-6f);
  71. CHECK (std::abs (paramOf (s, "Width") - w.width) < 1e-6f);
  72. // both shelves at 700 Hz (equal gains = a flat wet gain), the modulation at its slowest rate
  73. CHECK (std::abs (paramOf (s, "Low EQ freq") - 0.742f) < 1e-6f && std::abs (paramOf (s, "High EQ freq") - 0.0606f) < 1e-6f);
  74. CHECK (paramOf (s, "Mod rate") == 0.0f);
  75. }
  76. // the role's other devices keep the role preset (no measured default of their own), and so does the entry itself
  77. for (const char* name : { "Lustrous Plates", "SSL GateVerb", "Seventh Heaven", "smartreverb" })
  78. {
  79. const auto s = p190ca::substituted (p190ca::vst3Named (name));
  80. CHECK (s.kind == EffectKind::foilPlate && std::abs (s.mix - 0.25f) < 1e-6f);
  81. CHECK (std::abs (paramOf (s, "Decay") - 0.3f) < 1e-6f && paramOf (s, "Mix") == 1.0f && paramOf (s, "Voicing") == 0.0f);
  82. }
  83. const auto id = pluginIdentity (p190ca::vst3Named ("SSL PlateVerb"));
  84. const auto* entry = findPluginSubstitute (id, false);
  85. CHECK (entry != nullptr && entry->key == "complete-access-reverbs");
  86. if (entry != nullptr)
  87. {
  88. const auto plain = makeSubstituteSlot (*entry); // the quick-add palette: no original plugin
  89. CHECK (std::abs (plain.mix - 0.25f) < 1e-6f && std::abs (paramOf (plain, "Decay") - 0.3f) < 1e-6f && paramOf (plain, "Voicing") == 0.0f);
  90. }
  91. }
  92. TEST (p190ca_device_defaults_parse_and_report_errors)
  93. {
  94. using namespace lynx;
  95. int errors = 0;
  96. auto t = parseSubstituteTable ("[p190ca-test]\nlynx = Foil Plate\nnames = Some Verb; Other Verb\npreset = Decay=0.4\nmix = 0.5\n"
  97. "default = Other Verb | Decay=0.7; Voicing=1\n", &errors);
  98. CHECK (errors == 0 && t.size() == 1);
  99. if (t.size() == 1)
  100. {
  101. PluginIdentity a, b;
  102. a.format = b.format = ForeignPlugin::Format::vst3;
  103. a.name = "Some Verb";
  104. b.name = "Other Verb";
  105. const auto sa = makeSubstituteSlot (t[0], &a), sb = makeSubstituteSlot (t[0], &b);
  106. const auto decay = (std::size_t) p190ca::paramNamed (EffectKind::foilPlate, "Decay"), voicing = (std::size_t) p190ca::paramNamed (EffectKind::foilPlate, "Voicing");
  107. CHECK (std::abs (sa.params[decay] - 0.4f) < 1e-6f && sa.params[voicing] == 0.0f && std::abs (sa.mix - 0.5f) < 1e-6f);
  108. CHECK (std::abs (sb.params[decay] - 0.7f) < 1e-6f && sb.params[voicing] == 1.0f && sb.mix == 1.0f);
  109. }
  110. // a default without a name, or with an unknown parameter, counts as an error
  111. parseSubstituteTable ("[p190ca-test]\nlynx = Foil Plate\nnames = Some Verb\ndefault = Decay=0.7\n", &errors);
  112. CHECK (errors == 1);
  113. parseSubstituteTable ("[p190ca-test]\nlynx = Foil Plate\nnames = Some Verb\ndefault = Some Verb | Nope=0.7\n", &errors);
  114. CHECK (errors == 1);
  115. // (round 190cm) a lower-case mix= item is the slot's dry/wet, "Mix" stays the effect's parameter
  116. t = parseSubstituteTable ("[p190ca-test]\nlynx = Foil Plate\nnames = Send Verb\npreset = Mix=1\nmix = 0.25\ndefault = Send Verb | Decay=0.7; Mix=0.9; mix=0.3\n", &errors);
  117. CHECK (errors == 0 && t.size() == 1);
  118. if (t.size() == 1)
  119. {
  120. PluginIdentity a;
  121. a.format = ForeignPlugin::Format::vst3;
  122. a.name = "Send Verb";
  123. const auto s = makeSubstituteSlot (t[0], &a);
  124. CHECK (std::abs (s.mix - 0.3f) < 1e-6f && std::abs (s.params[(std::size_t) p190ca::paramNamed (EffectKind::foilPlate, "Mix")] - 0.9f) < 1e-6f);
  125. }
  126. parseSubstituteTable ("[p190ca-test]\nlynx = Foil Plate\nnames = Some Verb\n", &errors); // leaves no default behind
  127. CHECK (errors == 0);
  128. }
  129. TEST (p190ca_a_substitute_is_not_translated_again)
  130. {
  131. using namespace lynx;
  132. // what a saved project holds: the substitute slot with its own parameters. Changing the maps does not reach it.
  133. auto slot = p190ca::substituted (p190ca::vst3Named ("SSL PlateVerb"));
  134. CHECK (slot.kind == EffectKind::foilPlate && slot.isSubstitute());
  135. const auto decay = (std::size_t) p190ca::paramNamed (EffectKind::foilPlate, "Decay");
  136. slot.params[decay] = 0.123f;
  137. slot.mix = 0.6f;
  138. const auto before = slot.params;
  139. CHECK (! substituteEffectSlot (slot, pluginIdentity (slot.substituteFor.foreign)));
  140. CHECK (slot.params == before && slot.mix == 0.6f && slot.kind == EffectKind::foilPlate);
  141. namespace ef = lynx::echosuite::echoform;
  142. auto echo = p190ca::substituted (p190ca::vst3Named ("ValhallaDelay", "<ValhallaDelay Mode=\"0.0416666679084301\"/>", "64545356614c7679616c68616c6c6164"));
  143. echo.params[ef::output] = 0.5f; // a project saved before this round
  144. CHECK (! substituteEffectSlot (echo, pluginIdentity (echo.substituteFor.foreign)));
  145. CHECK (echo.params[ef::output] == 0.5f);
  146. }