Issue15Tests.inc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Round 166a, issue #15 (esiowry): "Audio clips routed to a mixer insert become reassigned to a different insert when
  2. // moved to other tracks in the playlist". FL 2026 [DECOMP FLEngine FUN_00e66ba0 / FUN_00e66580, REA_rodada166a §1]:
  3. // only the clips an edit placed follow an audio track; a channel also used on another audio track asks first.
  4. namespace issue15
  5. {
  6. // tracks: 0 = audio track → insert 14, 1 = audio track → insert 10, 2 = unassigned; channel "take" on insert 14
  7. struct Setup
  8. {
  9. lynx::Song song = lynx::Song::makeDefault();
  10. int take = -1;
  11. Setup()
  12. {
  13. using namespace lynx;
  14. while (song.mixer.size() < 16)
  15. song.mixer.emplace_back();
  16. song.playlistTracks.resize (3);
  17. song.playlistTracks[0].mode = PlaylistTrackMode::audio;
  18. song.playlistTracks[0].mixerTrack = 14;
  19. song.playlistTracks[1].mode = PlaylistTrackMode::audio;
  20. song.playlistTracks[1].mixerTrack = 10;
  21. ChannelDef c;
  22. c.name = "Take";
  23. c.instrument = InstrumentKind::audioClip;
  24. c.mixerTrack = 14;
  25. song.channels.push_back (c);
  26. take = (int) song.channels.size() - 1;
  27. }
  28. int clip (int track, std::int64_t start, int channel = -1)
  29. {
  30. lynx::Clip c;
  31. c.kind = lynx::ClipKind::audio;
  32. c.channel = channel < 0 ? take : channel;
  33. c.track = track;
  34. c.start = start;
  35. c.length = 384;
  36. song.playlist.push_back (c);
  37. return (int) song.playlist.size() - 1;
  38. }
  39. };
  40. } // namespace issue15
  41. TEST (issue15_only_placed_audio_clips_follow_an_audio_track)
  42. {
  43. using namespace lynx;
  44. issue15::Setup s;
  45. const auto a = s.clip (0, 0);
  46. const auto b = s.clip (0, 384);
  47. // an edit that placed nothing (or other clips) never reroutes
  48. CHECK (trackmodes::followAudioTracks (s.song, {}) == 0);
  49. // b moved onto the audio track of insert 10: FL routes its channel there (every clip of the channel follows)
  50. s.song.playlist[(std::size_t) b].track = 1;
  51. CHECK (trackmodes::audioTrackConflicts (s.song, { b }).size() == 1); // (a is on the audio track of insert 14)
  52. s.song.playlist[(std::size_t) a].track = 2; // a on an unassigned track: no question
  53. CHECK (trackmodes::audioTrackConflicts (s.song, { b }).empty());
  54. CHECK (trackmodes::followAudioTracks (s.song, { b }) == 1 && s.song.channels[(std::size_t) s.take].mixerTrack == 10);
  55. // routed back to 14 by hand: it stays there while other clips are moved, until b itself is placed again
  56. s.song.channels[(std::size_t) s.take].mixerTrack = 14;
  57. const auto other = s.clip (1, 2000, 0); // (a generator channel's clip: ignored)
  58. s.song.playlist[(std::size_t) other].kind = ClipKind::pattern;
  59. CHECK (trackmodes::followAudioTracks (s.song, { a, other }) == 0 && s.song.channels[(std::size_t) s.take].mixerTrack == 14);
  60. CHECK (trackmodes::followAudioTracks (s.song, { b }) == 1 && s.song.channels[(std::size_t) s.take].mixerTrack == 10);
  61. // onto an unassigned track: the route stays
  62. s.song.channels[(std::size_t) s.take].mixerTrack = 14;
  63. s.song.playlist[(std::size_t) b].track = 2;
  64. CHECK (trackmodes::followAudioTracks (s.song, { b }) == 0 && s.song.channels[(std::size_t) s.take].mixerTrack == 14);
  65. }
  66. TEST (issue15_shared_channel_asks_to_make_the_clip_unique)
  67. {
  68. using namespace lynx;
  69. issue15::Setup s;
  70. const auto a = s.clip (0, 0); // on the audio track of insert 14
  71. const auto b = s.clip (1, 384); // moved onto the audio track of insert 10
  72. const auto c = s.clip (1, 768); // moved with it
  73. const auto channels = s.song.channels.size();
  74. CHECK (trackmodes::audioTrackConflicts (s.song, { b, c }) == std::vector<int> { s.take });
  75. // No: nothing changes
  76. CHECK (trackmodes::followAudioTracks (s.song, { b, c }, false) == 0);
  77. CHECK (s.song.channels.size() == channels && s.song.channels[(std::size_t) s.take].mixerTrack == 14);
  78. // Yes: one copy for the placed clips, routed to 10; a keeps the channel on 14
  79. CHECK (trackmodes::followAudioTracks (s.song, { b, c }, true) == 2);
  80. CHECK (s.song.channels.size() == channels + 1 && s.song.channels.back().mixerTrack == 10);
  81. CHECK (s.song.playlist[(std::size_t) b].channel == (int) channels && s.song.playlist[(std::size_t) c].channel == (int) channels);
  82. CHECK (s.song.playlist[(std::size_t) a].channel == s.take && s.song.channels[(std::size_t) s.take].mixerTrack == 14);
  83. CHECK (trackmodes::audioTrackConflicts (s.song, { b, c }).empty());
  84. // a clip of the channel in another arrangement counts too (FL looks at every playlist)
  85. issue15::Setup t;
  86. t.clip (0, 0);
  87. Arrangement other;
  88. other.clips = t.song.playlist;
  89. t.song.arrangements = { Arrangement {}, other };
  90. t.song.currentArrangement = 0;
  91. t.song.playlist.clear();
  92. const auto d = t.clip (1, 0);
  93. CHECK (trackmodes::audioTrackConflicts (t.song, { d }).size() == 1);
  94. }