Backlog190rcTests.inc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Round 190rc (0.1.32 quality release): #285, #286, the ghost notes of Track-only / Simple (Discord 11-24).
  2. #include "core/EditorPolish.h"
  3. #include "core/KeyMap.h"
  4. #include "core/PlaylistOps.h"
  5. // #285: "Cut clips at the song position" — the selected clips that cross it, else every clip that crosses it
  6. TEST (backlog190rc_285_split_at_playhead)
  7. {
  8. using namespace lynx;
  9. const auto bar = (std::int64_t) 4 * ppq;
  10. std::vector<Clip> clips;
  11. for (int t = 0; t < 3; ++t)
  12. {
  13. Clip c;
  14. c.kind = ClipKind::pattern;
  15. c.pattern = t;
  16. c.track = t;
  17. c.start = t == 2 ? 2 * bar : 0; // (track 3's clip starts at the position: not cut)
  18. c.length = 4 * bar;
  19. clips.push_back (c);
  20. }
  21. // the selection: clip 1 alone
  22. CHECK ((splitat::clipsAt (clips, { 1 }, 2 * bar) == std::vector<int> { 1 }));
  23. // a selection that doesn't cross the position (clip 2 starts there): every clip that crosses it
  24. CHECK ((splitat::clipsAt (clips, { 2 }, 2 * bar) == std::vector<int> { 0, 1 }));
  25. CHECK ((splitat::clipsAt (clips, {}, 2 * bar) == std::vector<int> { 0, 1 }));
  26. CHECK (splitat::clipsAt (clips, {}, 0).empty()); // (at a clip's start nothing is cut)
  27. CHECK (splitat::clipsAt (clips, {}, 9 * bar).empty());
  28. auto cut = clips;
  29. const auto pieces = splitat::split (cut, { 0, 1 }, 2 * bar);
  30. CHECK ((pieces == std::vector<int> { 0, 3, 1, 4 }));
  31. CHECK (cut.size() == 5u);
  32. CHECK (cut[0].start == 0 && cut[0].length == 2 * bar && cut[3].start == 2 * bar && cut[3].length == 2 * bar && cut[3].offset == 2 * bar);
  33. CHECK (cut[3].track == 0 && cut[4].track == 1 && cut[2].length == 4 * bar);
  34. // the key map: an action with no default key (FL has none; Live's Ctrl+E stays the Clip-launch layout's)
  35. const auto* a = keys::findAction ("playlist.splitAtPlayhead");
  36. CHECK (a != nullptr && a->defaults.empty() && a->context == keys::Context::playlist);
  37. }
  38. // #286: "Open the project's folder" — an action with no default key
  39. TEST (backlog190rc_286_open_project_folder_action)
  40. {
  41. using namespace lynx;
  42. const auto* a = keys::findAction ("file.openProjectFolder");
  43. CHECK (a != nullptr && a->defaults.empty() && a->context == keys::Context::global);
  44. }
  45. // Discord 11-24 (sidthenugget): in Track-only mode / Simple a clip holds one instrument, so the ghost notes are the other
  46. // tracks' notes that play while the edited clip does
  47. TEST (backlog190rc_ghosts_from_other_tracks)
  48. {
  49. using namespace lynx;
  50. const auto bar = (std::int64_t) 4 * ppq;
  51. Song s;
  52. s.channels.resize (3);
  53. s.patterns.resize (3);
  54. for (int p = 0; p < 3; ++p)
  55. {
  56. Note n;
  57. n.channel = p;
  58. n.key = 60 + p;
  59. n.start = p * ppq;
  60. n.length = ppq;
  61. s.patterns[(std::size_t) p].notes.push_back (n);
  62. Note late = n;
  63. late.start = 3 * bar; // (beyond the edited clip's end: not a ghost)
  64. s.patterns[(std::size_t) p].notes.push_back (late);
  65. s.patterns[(std::size_t) p].lengthTicks = 4 * bar;
  66. }
  67. // pattern 0 (channel 0) at bar 2, two bars long; pattern 1 (channel 1) from bar 1; pattern 2 (channel 2) muted
  68. const auto addClip = [&s] (int pattern, int track, std::int64_t start, std::int64_t length, bool muted) {
  69. Clip c;
  70. c.kind = ClipKind::pattern;
  71. c.pattern = pattern;
  72. c.track = track;
  73. c.start = start;
  74. c.length = length;
  75. c.muted = muted;
  76. s.playlist.push_back (c);
  77. };
  78. addClip (0, 0, bar, 2 * bar, false);
  79. addClip (1, 1, 0, 4 * bar, false);
  80. addClip (2, 2, 0, 4 * bar, true);
  81. const auto others = polish::clipGhostNotes (s, 0, 0, 2000, true);
  82. // channel 1's note at beat 2 of pattern 1 plays at song tick ppq (before the clip): not there; its bar-4 note neither
  83. // (outside); the pattern plays from tick 0, so within bar 2-3 nothing... add one that does
  84. CHECK (others.empty());
  85. Note mid;
  86. mid.channel = 1;
  87. mid.key = 70;
  88. mid.start = bar + ppq; // song tick bar + ppq = the edited pattern's tick ppq
  89. mid.length = ppq;
  90. s.patterns[1].notes.push_back (mid);
  91. const auto again = polish::clipGhostNotes (s, 0, 0, 2000, true);
  92. CHECK (again.size() == 1u && again[0].channel == 1 && again[0].key == 70 && again[0].start == ppq);
  93. // FL's own (the same channel in other clips) leaves the other channels out
  94. for (const auto& n : polish::clipGhostNotes (s, 0, 0))
  95. CHECK (n.channel == 0);
  96. }