Auto177bTests.inc 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Round 177b: FL's "Create automation clip" placement (REA FUN_01191a50 / FUN_00e50b50, checked live in FL 2026):
  2. // the time selection, else the playback position (Options › General "Create automation clips at the playback
  3. // position", on) or the song start; it reaches the song end (at least one bar); the first track with no clips at all,
  4. // skipping instrument tracks.
  5. TEST (auto177b_new_automation_clip_place)
  6. {
  7. namespace ap = lynx::autoclipplace;
  8. const auto bar = (std::int64_t) lynx::ppq * 4;
  9. auto song = lynx::Song::makeDefault();
  10. song.beatsPerBar = 4;
  11. song.playlist.clear();
  12. song.loopStart = song.loopEnd = 0;
  13. // empty Playlist: one bar at the playhead, track 0 (FL: 1:01 → Track 1, one bar)
  14. auto p = ap::forNewClip (song, true, 0);
  15. CHECK (p.track == 0 && p.start == 0 && p.length == bar);
  16. // FL's live sequence: a clip on track 0 over bar 1; the playhead at 5:02 → track 1, one bar, at the playhead
  17. lynx::Clip c;
  18. c.track = 0;
  19. c.start = 0;
  20. c.length = bar;
  21. song.playlist.push_back (c);
  22. const auto at52 = bar * 4 + lynx::ppq / 4;
  23. p = ap::forNewClip (song, true, at52);
  24. CHECK (p.track == 1 && p.start == at52 && p.length == bar);
  25. lynx::Clip c2 = c;
  26. c2.track = 1;
  27. c2.start = at52;
  28. song.playlist.push_back (c2);
  29. // the playhead past the song (9:02) → track 2, at the playhead
  30. const auto at92 = bar * 8 + lynx::ppq / 4;
  31. p = ap::forNewClip (song, true, at92);
  32. CHECK (p.track == 2 && p.start == at92 && p.length == bar);
  33. lynx::Clip c3 = c;
  34. c3.track = 2;
  35. c3.start = at92;
  36. song.playlist.push_back (c3);
  37. // the playhead inside the song (3:02) → track 3 (track 0 is free there but not used), up to the song end (10:02)
  38. const auto at32 = bar * 2 + lynx::ppq / 4;
  39. p = ap::forNewClip (song, true, at32);
  40. CHECK (p.track == 3 && p.start == at32 && p.start + p.length == at92 + bar);
  41. // the option off: the song start
  42. p = ap::forNewClip (song, false, at32);
  43. CHECK (p.start == 0 && p.length == at92 + bar && p.track == 3);
  44. // an instrument track is skipped
  45. song.playlistTracks.resize (6);
  46. song.playlistTracks[3].mode = lynx::PlaylistTrackMode::instrument;
  47. p = ap::forNewClip (song, true, at32);
  48. CHECK (p.track == 4);
  49. // a track left empty above the used ones is taken
  50. song.playlist.erase (song.playlist.begin() + 1); // track 1 is empty again
  51. p = ap::forNewClip (song, true, at32);
  52. CHECK (p.track == 1);
  53. song.playlist.insert (song.playlist.begin() + 1, c2);
  54. // the time selection wins
  55. song.loopStart = bar;
  56. song.loopEnd = bar * 3;
  57. p = ap::forNewClip (song, true, bar * 5);
  58. CHECK (p.start == bar && p.length == bar * 2 && p.track == 4);
  59. }