Просмотр исходного кода

Project file keeps a draft length as it is (an exact round trip); the copy for 0.1.32 gives a written draft the automatic length (round 190uf)

Saving a written draft as the automatic length broke the selftest's track-clip round trip (trackclips190ne: the patterns
reopened different from the saved ones). Now "length" + "draftLength" are saved as they are, so a project reopens exactly;
the copy for 0.1.32 drops "draftLength" and, for a pattern with notes or automation clip steps, its "length" too, so 0.1.32
plays the automatic length (the same sound). --round190uftest checks both files.

(cherry picked from commit 00babe539e87c38a167561db27cfdc08ea6547de)
Ka1-S 2 дней назад
Родитель
Сommit
2fa2234e71

+ 6 - 5
docs/analise/REA_rodada190uf.md

@@ -72,9 +72,9 @@ user picks a length (Channel rack length box / menu, the pattern menu, Remote `l
 length goes through `setLength()` (rack length box display, `growSetLengthToNotes`, channel-loop burn, clip loop ops,
 pattern split, `sameContent`, Remote, ALS export, .flp 0xA4, History's label). `followPatternLengths` never shrinks a
 draft's clips (2 bars written into an 8-bar clip leave it 8 bars, repeating; a 1-bar clip still grows with its notes).
-Project file: `"draftLength": true` only while it holds; a written draft is saved as the automatic length it plays as,
-so 0.1.32 reads the same pattern (the copy for 0.1.32 drops the key). Old projects keep their set lengths (unchanged
-sound; the reply tells the user how to switch one to Automatic).
+Project file: `"draftLength": true` beside the drawn `"length"`, so a project reopens exactly as it was saved; the copy
+for 0.1.32 drops the key and, for a written draft, the length too (0.1.32 then plays the automatic length, the same
+sound). Old projects keep their set lengths (unchanged sound; the reply tells the user how to switch one to Automatic).
 
 `.flp` export: a pattern clip off its pattern's automatic length (stretched, shortened, a set length, or an offset) now
 carries its section (start / end), as FL saves a resized clip; a clip at its pattern's own length keeps FL's "no
@@ -84,12 +84,13 @@ uses there was not measured, so the import keeps the item's length).
 
 ## 5. Tests
 
-- `--round190uftest` (src/Round190ufCheck.inc, also in `--selftest` as `round190uf`): 55 checks — per case the pattern's
+- `--round190uftest` (src/Round190ufCheck.inc, also in `--selftest` as `round190uf`): 56 checks — per case the pattern's
   length, the render's sounding beats against FL's rule written out apart from LYNX's code, and with the option off FL's
   once (as FL 2026's /R); the Playlist's drawn notes per beat (snapshot); the reporter's gestures through the real
   Playlist (pencil clip A, its edge to 8 bars, pencil clip B = 8 bars, 8 notes with the Piano roll's pencil, B's edge to
   16 bars: B is 2 bars long, its clip stays 8 then 16 bars, the render repeats from bar 3); the project file (B reopens 2
-  bars; an empty draft reopens as one), the copy for 0.1.32 (B without "length"), the .flp sections and the trip back.
+  bars; a draft, empty or written, reopens exactly), the copy for 0.1.32 (a written draft without "length", an empty one
+  with its drawn length), the .flp sections and the trip back.
 - Unit tests `cliploop190uf_*` (6 tests, 31 checks); round 190ra's tests follow the draft rule (an old file's set length is
   still mended by the next edit).
 - The reporter's clip exported by this build (`rt.flp`: section 0..16 bars, the pattern automatic) and rendered by FL 2026

+ 8 - 3
src/Round190ufCheck.inc

@@ -471,7 +471,7 @@
             closeModals();
         }
         {
-            // the file keeps an empty draft as a draft; a filled draft is saved as the automatic length it now is
+            // the file keeps a draft as it is (empty or written); the copy for 0.1.32 plays the same
             auto s = baseSong();
             PlaylistTrack t;
             t.mode = PlaylistTrackMode::instrument;
@@ -485,8 +485,13 @@
             const auto back = ProjectFile::fromJson (ProjectFile::toJson (s), error);
             check ("file: an empty drawn clip reopens as a draft of 8 bars", back && back->patterns[(std::size_t) empty].draftLength
                                                                                 && back->patterns[(std::size_t) empty].effectiveLength (back->meter()) == 8 * barOf (s));
-            check ("file: a filled drawn clip reopens with the automatic length (2 bars)", back && back->patterns[(std::size_t) filled].lengthTicks == 0
-                                                                                              && back->patterns[(std::size_t) filled].effectiveLength (back->meter()) == 2 * barOf (s));
+            check ("file: a filled drawn clip reopens as it was (a draft, 2 bars: its notes)", back && back->patterns[(std::size_t) filled].draftLength
+                                                                                                   && back->patterns == s.patterns
+                                                                                                   && back->patterns[(std::size_t) filled].effectiveLength (back->meter()) == 2 * barOf (s));
+            const auto old = juce::JSON::parse (olderlynx::forRelease (s, "0.1.32").json);
+            check ("file: the copy for 0.1.32 keeps the empty clip's drawn length, gives the filled one the automatic length",
+                   (juce::int64) old["patterns"][empty].getProperty ("length", 0) == 8 * barOf (s) && ! old["patterns"][filled].hasProperty ("length")
+                       && ! old["patterns"][empty].hasProperty ("draftLength") && ! old["patterns"][filled].hasProperty ("draftLength"));
         }
 
         // ---- (4) .flp: FL reads a pattern clip without a section (start/end −1) as its pattern's length (FL 2026 /R, 12-02:

+ 12 - 5
src/engine/ProjectDowngrade.cpp

@@ -2630,9 +2630,9 @@ void toRelease0131 (juce::var& root, Losses& lost)
 // - round 190to (item 96): a mixer insert's "effectsOn": false (FL's per-insert effects switch): written as every slot of
 //   the insert switched off (0.1.32's way to say it: the same sound), the key dropped, a view line (the slots' own
 //   switches are lost there);
-// - round 190uf: a pattern's "draftLength" (an empty clip drawn to write into, core/Song.h Pattern::draftLength): dropped,
-//   no line. Only an empty pattern carries it (a draft with notes is saved as the automatic length it plays as, which
-//   0.1.32 reads the same); 0.1.32 ignores the key and keeps the drawn length as a set one, as it made it;
+// - round 190uf: a pattern's "draftLength" (a clip drawn to write into, core/Song.h Pattern::draftLength): dropped, no
+//   line. A draft with notes (or automation clip steps) plays as the automatic length, so its "length" goes too and
+//   0.1.32 plays the same; an empty one keeps its drawn length as a set one, as 0.1.32 made it;
 // - round 190tk: root "flAutomationPpq" (an imported FL project's PPQ: FL's automation timing): kept, no line. 0.1.32 reads
 //   root keys by name and ignores it, so a copy plays LYNX's own automation timing there (timing only, nothing is lost).
 // Not in projects, so nothing to change here: every other 0.1.33 step's settings (ui-options, toolbar presets, the
@@ -2665,11 +2665,18 @@ void toRelease0132 (juce::var& root, Losses& lost)
     auto& top = *objectOf (root);
     ownDataSets (root, lost);
 
-    // round 190uf: the draft lengths of empty drawn clips (no line: 0.1.32 made the same set length itself)
+    // round 190uf: draft lengths (no line: the same sound). Written: the automatic length it plays as; empty: the drawn
+    // length, as 0.1.32 made it
     if (auto* patterns = arrayOf (root["patterns"]))
         for (auto& p : *patterns)
             if (auto* po = objectOf (p))
-                drop (*po, "draftLength");
+                if (drop (*po, "draftLength"))
+                {
+                    const auto* notes = arrayOf (po->getProperty ("notes"));
+                    const auto* steps = arrayOf (po->getProperty ("autoNotes"));
+                    if ((notes != nullptr && ! notes->isEmpty()) || (steps != nullptr && ! steps->isEmpty()))
+                        po->removeProperty ("length");
+                }
 
     // round 190so: pinned Playlist tracks
     if (drop (top, "playlistTracksPinned"))

+ 4 - 4
src/engine/ProjectFile.cpp

@@ -3216,11 +3216,11 @@ juce::String toJson (const Song& song, bool stampVersion)
         if (p.uid != 0)
             o->setProperty ("uid", uidVar (p.uid));
 
-        // round 190uf: a draft length (a clip drawn to write into) is saved while it holds, with "draftLength"; once the
-        // pattern has notes it is the automatic length it plays as, so an older LYNX reads the same pattern
-        if (p.setLength() > 0)
+        if (p.lengthTicks > 0)
             o->setProperty ("length", (juce::int64) p.lengthTicks);
-        if (p.draftLength && p.setLength() > 0)
+        // round 190uf: a draft length (a clip drawn to write into, core/Song.h): kept as it is, so the project reopens the
+        // same; the copy for 0.1.32 gives a written draft the automatic length it plays as (engine/ProjectDowngrade.cpp)
+        if (p.draftLength && p.lengthTicks > 0)
             o->setProperty ("draftLength", true);
 
         if (p.colour != 0)