Iss152Tests.inc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // Issue #152 (0.1.25, Windows 11): (1) "the count-in doesn't keep its change"; (3) "I pick a physical input of my
  2. // interface on insert X and LYNX records the signal of another insert". (2), the VST3 controls that follow a MIDI
  3. // controller in the sound but not in the plugin's window, is a JUCE host fix (cmake/LynxPatchJuce.cmake fix 25).
  4. #include "core/CountIn.h"
  5. TEST (iss152_count_in_toggle_keeps_its_length)
  6. {
  7. using namespace lynx::countin;
  8. // Ctrl+P / the button: a 2-bar count-in goes off and comes back at 2 bars (it came back at 1 bar)
  9. CHECK (toggled (2, 2) == 0);
  10. CHECK (toggled (0, 2) == 2);
  11. CHECK (toggled (0, 4) == 4);
  12. CHECK (toggled (1, 1) == 0);
  13. // a length out of range: FL's 1 bar .. LYNX's 4
  14. CHECK (toggled (0, 0) == 1 && toggled (0, 9) == 4);
  15. // a count-in that is on sets the length; off keeps it
  16. CHECK (lengthFor (2, 1) == 2 && lengthFor (0, 4) == 4 && lengthFor (0, -3) == 1);
  17. }
  18. TEST (iss152_count_in_settings_round_trip_in_any_order)
  19. {
  20. using namespace lynx::countin;
  21. // what MainComponent writes: the switch and the length; read back in either order
  22. for (const bool lengthFirst : { false, true })
  23. for (const int saved : { 0, 1, 2, 4 })
  24. {
  25. const int savedLength = saved > 0 ? saved : 2; // off with 2 bars kept
  26. int bars = 0, length = 1; // the defaults at start-up
  27. const std::pair<std::string_view, int> lines[] { { onKey, saved > 0 ? 1 : 0 }, { lengthKey, savedLength } };
  28. for (int k = 0; k < 2; ++k)
  29. {
  30. const auto& [key, value] = lines[lengthFirst ? 1 - k : k];
  31. CHECK (readSetting (key, value, bars, length));
  32. }
  33. CHECK (bars == saved);
  34. CHECK (length == savedLength);
  35. }
  36. // a new install starts as FL's factory form (on, 1 bar); an older settings file without the keys keeps LYNX's off
  37. CHECK (startingBars (false) == 1 && startingBars (true) == 0);
  38. int bars = 3, length = 3;
  39. CHECK (! readSetting ("recordPreRoll", 2, bars, length) && bars == 3 && length == 3); // another key: untouched
  40. CHECK (std::string (onKey) != std::string (lengthKey));
  41. }
  42. namespace
  43. {
  44. // insert 1 plays physical input 3 and sends to insert 2; insert 2 has physical input 1 - 2 armed: the reporter's
  45. // "records the signal of another insert"
  46. struct Iss152Inputs
  47. {
  48. lynx::Song song = lynx::Song::makeDefault();
  49. lynx::RackRenderer renderer;
  50. lynx::LiveInput input;
  51. std::vector<float> in1 = std::vector<float> (256, 0.25f), in2 = std::vector<float> (256, 0.25f), in3 = std::vector<float> (256, 0.5f),
  52. l = std::vector<float> (256), r = std::vector<float> (256);
  53. Iss152Inputs()
  54. {
  55. song.channels.clear();
  56. song.playlist.clear();
  57. song.mixer = lynx::Song::defaultMixer (4);
  58. auto& other = song.mixer[1];
  59. other.inputChannel = 2;
  60. other.inputStereo = false;
  61. other.monitor = lynx::InputMonitor::on;
  62. other.sends.push_back ({ 2, 1.0f });
  63. auto& x = song.mixer[2];
  64. x.inputChannel = 0; // "In 1 - In 2"
  65. x.monitor = lynx::InputMonitor::automatic;
  66. renderer.prepare (48000.0, 512);
  67. renderer.setLiveInput (&input);
  68. input.channels[0] = in1.data();
  69. input.channels[1] = in2.data();
  70. input.channels[2] = in3.data();
  71. input.numChannels = 3;
  72. input.armed[2].store (true);
  73. input.recording.store (true);
  74. input.taps[0].point.store ((int) lynx::RecordSource::postEq);
  75. input.taps[0].track.store (2);
  76. input.tapCount.store (1);
  77. }
  78. float postEqTake()
  79. {
  80. auto state = lynx::RackState::build (song, nullptr, 48000.0);
  81. for (int block = 0; block < 12; ++block)
  82. {
  83. for (auto& d : input.taps[0].data)
  84. std::fill (d.begin(), d.begin() + 256, 0.0f);
  85. renderer.process (state.get(), true, 0.0, 256, l.data(), r.data());
  86. }
  87. return input.taps[0].data[0][200];
  88. }
  89. };
  90. } // namespace
  91. TEST (iss152_post_eq_take_holds_other_inserts_audio)
  92. {
  93. // the cause: FL's default "Record" position is Post EQ, which takes everything reaching insert X — here insert 1's
  94. // input 3 too (0.25 + 0.5), not only X's own input
  95. Iss152Inputs t;
  96. CHECK (t.song.mixer[2].recordSource == lynx::RecordSource::postEq);
  97. const auto take = t.postEqTake();
  98. CHECK (std::abs (take - 0.75f) < 0.05f);
  99. }
  100. TEST (iss152_choosing_an_input_asks_for_external_input_only)
  101. {
  102. using lynx::RecordSource;
  103. // FL asks when an input is chosen on an insert that records more than it; "External input only" records the
  104. // device input alone (the engine pushes the input's channels, no tap), through the same insert on playback
  105. CHECK (lynx::asksExternalInputOnly (2, 0, RecordSource::postEq));
  106. CHECK (lynx::asksExternalInputOnly (2, 3, RecordSource::externalAndMixer));
  107. CHECK (lynx::asksExternalInputOnly (2, 0, RecordSource::postTrack));
  108. CHECK (! lynx::asksExternalInputOnly (2, 0, RecordSource::externalInput)); // already
  109. CHECK (! lynx::asksExternalInputOnly (2, -1, RecordSource::postEq)); // "(none)"
  110. CHECK (! lynx::asksExternalInputOnly (0, 0, RecordSource::postEq)); // the Master: no record arm
  111. }
  112. TEST (iss152_simple_recording_tracks_record_their_input_alone)
  113. {
  114. // the Simple workflow's voice / guitar / bass tracks: their input alone, on their own insert
  115. using namespace simple184a;
  116. for (const auto kind : { simpletracks::Kind::voice, simpletracks::Kind::guitar, simpletracks::Kind::bass })
  117. {
  118. auto s = freshSong();
  119. simpletracks::Request q;
  120. q.kind = kind;
  121. q.input = 0;
  122. const auto r = simpletracks::addTrack (s, q);
  123. CHECK (r.ok());
  124. CHECK (s.mixer[(std::size_t) r.insert].inputChannel == 0);
  125. CHECK (s.mixer[(std::size_t) r.insert].recordSource == lynx::RecordSource::externalInput);
  126. }
  127. // no input chosen: FL's default stays
  128. auto s = freshSong();
  129. simpletracks::Request q;
  130. q.kind = simpletracks::Kind::voice;
  131. q.input = -1;
  132. const auto r = simpletracks::addTrack (s, q);
  133. CHECK (r.ok() && s.mixer[(std::size_t) r.insert].recordSource == lynx::RecordSource::postEq);
  134. }