ProjectDowngrade.cpp 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981
  1. #include "engine/ProjectDowngrade.h"
  2. #include "engine/ProjectFile.h"
  3. #include "core/DirectWaveState.h"
  4. #include "core/DynamicsSuite.h"
  5. #include "core/EchoSuite.h"
  6. #include "core/FacetEq.h"
  7. #include "core/GeneratorPresets.h"
  8. #include "core/Harmor.h"
  9. #include "core/LuxeVerb.h"
  10. #include "core/LynxVerbs.h"
  11. #include "core/MixSuite.h"
  12. #include "core/NewtoneFx.h"
  13. #include "core/PeakShapes.h"
  14. #include "core/RackRenderer.h"
  15. #include "core/VoiceShift.h"
  16. #include <cmath>
  17. #include <functional>
  18. // TR_NOOP marks the loss texts for translation (tools/i18n_keys.py); the UI translates them
  19. #ifndef TR_NOOP
  20. #define TR_NOOP(text) text
  21. #endif
  22. namespace lynx::olderlynx
  23. {
  24. namespace
  25. {
  26. using Losses = std::vector<Loss>;
  27. juce::DynamicObject* objectOf (const juce::var& v) { return v.getDynamicObject(); }
  28. juce::Array<juce::var>* arrayOf (const juce::var& v) { return v.getArray(); }
  29. bool drop (juce::DynamicObject& o, const char* key)
  30. {
  31. if (! o.hasProperty (key))
  32. return false;
  33. o.removeProperty (key);
  34. return true;
  35. }
  36. juce::String channelName (const juce::var& c, int index)
  37. {
  38. const auto name = c["name"].toString();
  39. return name.isNotEmpty() ? "\"" + name + "\"" : "#" + juce::String (index + 1);
  40. }
  41. juce::String insertName (const juce::var& mixer, int track)
  42. {
  43. // (language-neutral: "#3 \"Kick\"", the Master as "#0")
  44. const auto name = mixer[track]["name"].toString();
  45. return "#" + juce::String (track) + (name.isNotEmpty() ? " \"" + name + "\"" : juce::String());
  46. }
  47. // "a, b, c" (at most four, then "…")
  48. juce::String listOf (const juce::StringArray& names)
  49. {
  50. juce::StringArray shown;
  51. for (int i = 0; i < names.size() && i < 4; ++i)
  52. shown.add (names[i]);
  53. return shown.joinIntoString (", ") + (names.size() > 4 ? juce::String::fromUTF8 (", \u2026") : juce::String());
  54. }
  55. void forEachChannel (const juce::var& root, const std::function<void (juce::DynamicObject&, int)>& fn)
  56. {
  57. if (auto* channels = arrayOf (root["channels"]))
  58. for (int i = 0; i < channels->size(); ++i)
  59. if (auto* c = objectOf ((*channels)[i]))
  60. fn (*c, i);
  61. }
  62. // every clip array of the project: the Playlist, the stored arrangements, the clip grid's slots
  63. void forEachClip (const juce::var& root, const std::function<void (juce::Array<juce::var>&)>& fn)
  64. {
  65. auto list = [&] (const juce::var& clips) {
  66. if (auto* a = arrayOf (clips))
  67. for (auto& c : *a)
  68. if (auto* fields = arrayOf (c))
  69. fn (*fields);
  70. };
  71. list (root["playlist"]);
  72. if (auto* arrangements = arrayOf (root["arrangements"]))
  73. for (const auto& a : *arrangements)
  74. list (a["clips"]);
  75. if (auto* slots = arrayOf (root["clipGrid"]["clips"]))
  76. for (const auto& s : *slots)
  77. list (s["clip"]);
  78. }
  79. // Every effect object below `v` (the mixer's slots, a Patcher's nodes, a rack's branches): `fn (effect, where)`, `where`
  80. // the insert ("#3 \"Vox\"") of a mixer slot, else "Patcher"
  81. void forEachEffect (const juce::var& root, const std::function<void (juce::DynamicObject&, const juce::String&)>& fn)
  82. {
  83. std::function<void (const juce::var&, const juce::String&)> walk = [&] (const juce::var& v, const juce::String& where) {
  84. if (auto* a = arrayOf (v))
  85. {
  86. for (auto& item : *a)
  87. walk (item, where);
  88. return;
  89. }
  90. auto* o = objectOf (v);
  91. if (o == nullptr)
  92. return;
  93. if (o->getProperty ("kind").isString() && o->getProperty ("params").isArray())
  94. fn (*o, where);
  95. for (auto& p : o->getProperties())
  96. walk (p.value, "Patcher");
  97. };
  98. if (auto* mixer = arrayOf (root["mixer"]))
  99. for (int t = 0; t < mixer->size(); ++t)
  100. if (auto* fx = arrayOf ((*mixer)[t]["effects"]))
  101. for (auto& e : *fx)
  102. {
  103. if (auto* o = objectOf (e); o != nullptr && o->getProperty ("kind").isString() && o->getProperty ("params").isArray())
  104. fn (*o, insertName (root["mixer"], t));
  105. if (auto* o = objectOf (e))
  106. for (auto& p : o->getProperties())
  107. walk (p.value, "Patcher");
  108. }
  109. if (auto* channels = arrayOf (root["channels"]))
  110. for (auto& c : *channels)
  111. if (auto* o = objectOf (c))
  112. for (auto& p : o->getProperties())
  113. walk (p.value, "Patcher");
  114. }
  115. void addOnce (juce::StringArray& list, const juce::String& item)
  116. {
  117. if (! list.contains (item))
  118. list.add (item);
  119. }
  120. void flattenEffects (juce::var& root, const juce::StringArray& kinds, const char* loss, Losses& lost);
  121. // Rollup 0.1.30 (round 190il): what the other 0.1.30 rounds save that 0.1.28 cannot hold (round 190hq's step above
  122. // knew only its own). Each loss is reported only when the project has it.
  123. void toRelease0128FromRollup030 (juce::var& root, Losses& lost)
  124. {
  125. auto& o = *objectOf (root);
  126. // round 190kk: the engines Live's Erosion (and the next lot) open on are not in 0.1.28
  127. flattenEffects (root, { "corrode" },
  128. TR_NOOP ("Corrode (an imported Live Erosion) is not in this release: it becomes a switched-off Utility in its slot, and its automation does nothing ({0})"),
  129. lost);
  130. flattenEffects (root, { "platter" },
  131. TR_NOOP ("Platter (an imported Live Vinyl Distortion) is not in this release: it becomes a switched-off Utility in its slot, and its automation does nothing ({0})"),
  132. lost);
  133. flattenEffects (root, { "soundboard" },
  134. TR_NOOP ("Soundboard (an imported Live Corpus) is not in this release: it becomes a switched-off Utility in its slot, and its automation does nothing ({0})"),
  135. lost);
  136. // round 190ko: Live's Spectral Time / Spectral Resonator engines
  137. flattenEffects (root, { "timeprism" },
  138. TR_NOOP ("Timeprism (an imported Live Spectral Time) is not in this release: it becomes a switched-off Utility in its slot, and its automation does nothing ({0})"),
  139. lost);
  140. flattenEffects (root, { "harmonia" },
  141. TR_NOOP ("Harmonia (an imported Live Spectral Resonator) is not in this release: it becomes a switched-off Utility in its slot, and its automation does nothing ({0})"),
  142. lost);
  143. // channels: Tetra (round 190hs) is not in 0.1.28, which would play its channels as its basic synth: an empty Sampler
  144. // (silent) keeps the channel, its notes and its routing; DirectWave states (rounds 190hz / 190ii) get their short zone
  145. // records completed as DirectWave reads them, since 0.1.28 skipped them (FL's version-36 programs lost their loops)
  146. {
  147. juce::StringArray tetra, helix, braid;
  148. forEachChannel (root, [&] (juce::DynamicObject& c, int i) {
  149. const auto instrument = c.getProperty ("instrument").toString();
  150. if (instrument == "tetra" || instrument == "helix" || instrument == "braid") // (rollup step 3: Helix, round 190ja, as Tetra; Braid, 190ko)
  151. {
  152. (instrument == "tetra" ? tetra : instrument == "helix" ? helix : braid).add (channelName (juce::var (&c), i));
  153. c.setProperty ("instrument", "sampler");
  154. drop (c, "modelParams");
  155. drop (c, "pluginState");
  156. drop (c, "samplePath");
  157. }
  158. else if (instrument == "directwave")
  159. {
  160. juce::MemoryOutputStream decoded;
  161. if (! juce::Base64::convertFromBase64 (decoded, c.getProperty ("pluginState").toString()))
  162. return;
  163. const auto* bytes = static_cast<const std::uint8_t*> (decoded.getData());
  164. auto doc = dw::readDoc (std::vector<std::uint8_t> (bytes, bytes + decoded.getDataSize()));
  165. if (doc && dw::completeShortZoneRecords (*doc) > 0)
  166. {
  167. const auto state = dw::writeDoc (*doc);
  168. c.setProperty ("pluginState", juce::Base64::toBase64 (state.data(), state.size()));
  169. }
  170. }
  171. });
  172. if (! tetra.isEmpty())
  173. lost.push_back ({ TR_NOOP ("Tetra is not in this release: its channels become empty Samplers and play nothing: {0}"), listOf (tetra), true });
  174. if (! helix.isEmpty())
  175. lost.push_back ({ TR_NOOP ("Helix is not in this release: its channels become empty Samplers and play nothing: {0}"), listOf (helix), true });
  176. if (! braid.isEmpty())
  177. lost.push_back ({ TR_NOOP ("Braid is not in this release: its channels become empty Samplers and play nothing: {0}"), listOf (braid), true });
  178. }
  179. // notes: index 19 holds a note's MPE curves (round 190hy)
  180. {
  181. int curved = 0;
  182. if (auto* patterns = arrayOf (root["patterns"]))
  183. for (auto& p : *patterns)
  184. if (auto* notes = arrayOf (p["notes"]))
  185. for (auto& n : *notes)
  186. if (auto* fields = arrayOf (n); fields != nullptr && fields->size() > 19)
  187. {
  188. ++curved;
  189. fields->removeRange (19, fields->size() - 19);
  190. }
  191. if (curved > 0)
  192. lost.push_back ({ TR_NOOP ("{0} note(s) lose their MPE curves (pitch bend, slide, pressure)"), juce::String (curved), true });
  193. }
  194. // Pattern Blocks: a third element marks a muted block (round 190ht); 0.1.28 reads only [pattern, start] and drops
  195. // any other block. A muted block plays nothing, so it is left out (the sound stays); the rest keep their two.
  196. {
  197. int muted = 0;
  198. auto blocks = [&muted] (const juce::var& list) {
  199. if (auto* a = arrayOf (list))
  200. for (int i = a->size(); --i >= 0;)
  201. if (auto* b = arrayOf ((*a)[i]); b != nullptr && b->size() > 2)
  202. {
  203. if ((int) (*b)[2] != 0)
  204. {
  205. a->remove (i);
  206. ++muted;
  207. }
  208. else
  209. b->removeRange (2, b->size() - 2);
  210. }
  211. };
  212. blocks (root["blocks"]);
  213. if (auto* arrangements = arrayOf (root["arrangements"]))
  214. for (const auto& a : *arrangements)
  215. blocks (a["blocks"]);
  216. if (muted > 0)
  217. lost.push_back ({ TR_NOOP ("{0} muted Pattern Block(s) are left out (they play nothing)"), juce::String (muted), false });
  218. }
  219. // clips: index 13 is the clip's pitch, ±48 semitones since round 190hr (0.1.28 holds ±12)
  220. {
  221. int transposed = 0;
  222. forEachClip (root, [&] (juce::Array<juce::var>& clip) {
  223. if (clip.size() > 13)
  224. if (const auto pitch = (double) clip[13]; std::abs (pitch) > 12.0)
  225. {
  226. clip.set (13, juce::jlimit (-12.0, 12.0, pitch));
  227. ++transposed;
  228. }
  229. });
  230. if (transposed > 0)
  231. lost.push_back ({ TR_NOOP ("{0} clip(s) transposed by more than 12 semitones play at ±12"), juce::String (transposed), true });
  232. }
  233. // clip slots (round 190hr): the Start marker inside the loop, the clip's own scale
  234. {
  235. int markers = 0, scales = 0;
  236. if (auto* slots = arrayOf (root["clipGrid"]["clips"]))
  237. for (auto& slot : *slots)
  238. if (auto* so = objectOf (slot))
  239. {
  240. markers += drop (*so, "startMarker") ? 1 : 0;
  241. scales += drop (*so, "clipScale") ? 1 : 0;
  242. }
  243. if (markers > 0)
  244. lost.push_back ({ TR_NOOP ("{0} clip slot(s) launch from their loop start (the Start marker inside the loop)"), juce::String (markers), true });
  245. if (scales > 0)
  246. lost.push_back ({ TR_NOOP ("Clip scales (Scale Mode) of {0} clip slot(s)"), juce::String (scales), false });
  247. }
  248. // effects (round 190ho): Voice Shift's Measured law revision 1, Ridge Strip's 4K Pink EQ; (round 190iq) Hush De-esser's
  249. // measured Allround timing (hidden parameters 0.1.28 ignores: it plays revision 0, Black, and the earlier timing)
  250. {
  251. juce::StringArray thump, pink, hushTiming, hushVocal, echoVoicings, latticeTaps, luxeDucking, verbRevisions;
  252. forEachEffect (root, [&] (juce::DynamicObject& e, const juce::String& where) {
  253. auto* params = arrayOf (e.getProperty ("params"));
  254. if (params == nullptr) // (a slot written without parameters)
  255. return;
  256. const auto kind = e.getProperty ("kind").toString();
  257. if (kind == "voiceShift" && params->size() > voiceshift::revision)
  258. {
  259. if ((float) (double) (*params)[voiceshift::law] >= 0.5f && (float) (double) (*params)[voiceshift::revision] >= 0.5f)
  260. addOnce (thump, where);
  261. params->removeRange (voiceshift::revision, params->size() - voiceshift::revision);
  262. }
  263. else if (kind == "ridgeStrip" && params->size() > mixsuite::ridge::k4Pink)
  264. {
  265. if ((float) (double) (*params)[mixsuite::ridge::k4Pink] >= 0.5f)
  266. addOnce (pink, where);
  267. params->removeRange (mixsuite::ridge::k4Pink, params->size() - mixsuite::ridge::k4Pink);
  268. }
  269. else if (kind == "hushDeEsser" && params->size() > mixsuite::hush::timing)
  270. {
  271. // (the timing is the Allround law's: Single Vocal plays the same either way)
  272. if ((float) (double) (*params)[mixsuite::hush::timing] >= 0.5f && (float) (double) (*params)[mixsuite::hush::allround] >= 0.5f)
  273. addOnce (hushTiming, where);
  274. // rollup step 5, round 190js: Single Vocal's "stands out" revision (hidden, after the timing; Allround ignores it)
  275. if (params->size() > mixsuite::hush::vocalRevision && (float) (double) (*params)[mixsuite::hush::vocalRevision] >= 0.5f
  276. && (float) (double) (*params)[mixsuite::hush::allround] < 0.5f)
  277. addOnce (hushVocal, where);
  278. params->removeRange (mixsuite::hush::timing, params->size() - mixsuite::hush::timing);
  279. }
  280. // rollup step 3: round 190is's Echoform voicings revision (heard only with an echo voicing), round 190it's
  281. // reverb revisions (the Measured law's: Law 1), Lattice Mod's tap network and LuxeVerb's Space ducking
  282. else if (kind == "echoform" && params->size() > echosuite::echoform::revision)
  283. {
  284. if ((float) (double) (*params)[echosuite::echoform::revision] >= 0.5f && (float) (double) (*params)[echosuite::echoform::voicing] >= 0.5f)
  285. addOnce (echoVoicings, where);
  286. params->removeRange (echosuite::echoform::revision, params->size() - echosuite::echoform::revision);
  287. }
  288. else if (kind == "latticeMod" && params->size() > echosuite::lattice::revision)
  289. {
  290. if ((float) (double) (*params)[echosuite::lattice::revision] >= 0.5f)
  291. addOnce (latticeTaps, where);
  292. params->removeRange (echosuite::lattice::revision, params->size() - echosuite::lattice::revision);
  293. }
  294. else if (kind == "luxeVerb" && params->size() > luxeVerbSpaceDucking)
  295. {
  296. if ((float) (double) (*params)[luxeVerbSpaceDucking] > 0.0f)
  297. addOnce (luxeDucking, where);
  298. params->removeRange (luxeVerbSpaceDucking, params->size() - luxeVerbSpaceDucking);
  299. }
  300. else
  301. {
  302. const auto verb = [&] (const char* id, int law, int revision) {
  303. if (kind != id || params->size() <= revision)
  304. return;
  305. if ((float) (double) (*params)[revision] >= 0.5f && (float) (double) (*params)[law] >= 0.5f)
  306. addOnce (verbRevisions, where);
  307. params->removeRange (revision, params->size() - revision);
  308. };
  309. verb ("epochVerb", verbs::epoch::engineLaw, verbs::epoch::revision);
  310. verb ("atrium", verbs::atrium::engineLaw, verbs::atrium::revision);
  311. verb ("foilPlate", verbs::foil::engineLaw, verbs::foil::revision);
  312. verb ("halo", verbs::halo::engineLaw, verbs::halo::revision);
  313. }
  314. });
  315. if (! thump.isEmpty())
  316. lost.push_back ({ TR_NOOP ("Voice Shift's Measured law plays its earlier version (a low thump at sung onsets): {0}"), listOf (thump), true });
  317. if (! pink.isEmpty())
  318. lost.push_back ({ TR_NOOP ("Ridge Strip's 4K Pink EQ plays as the Black EQ: {0}"), listOf (pink), true });
  319. if (! hushTiming.isEmpty())
  320. lost.push_back ({ TR_NOOP ("Hush De-esser's Allround mode plays its earlier timing: {0}"), listOf (hushTiming), true });
  321. if (! hushVocal.isEmpty())
  322. lost.push_back ({ TR_NOOP ("Hush De-esser's Single Vocal mode plays its earlier version: {0}"), listOf (hushVocal), true });
  323. if (! echoVoicings.isEmpty())
  324. lost.push_back ({ TR_NOOP ("Echoform's echo voicings play their earlier loop: {0}"), listOf (echoVoicings), true });
  325. if (! verbRevisions.isEmpty())
  326. lost.push_back ({ TR_NOOP ("Epoch Verb, Atrium, Foil Plate and Halo play the 0.1.27 version of their Measured law: {0}"), listOf (verbRevisions), true });
  327. if (! latticeTaps.isEmpty())
  328. lost.push_back ({ TR_NOOP ("Lattice Mod plays its earlier tap network: {0}"), listOf (latticeTaps), true });
  329. if (! luxeDucking.isEmpty())
  330. lost.push_back ({ TR_NOOP ("LuxeVerb's Space ducking is not in this release: {0}"), listOf (luxeDucking), true });
  331. }
  332. // rollup step 3, round 190ik (warp engines): an 11-number warpModes list (the Texture / Complex Pro law), Beats'
  333. // pitch-aware law (0.1.28 reads it as Measured), Complex Pro / Texture transpositions rendered offline (0.1.28
  334. // renders a baked pitch only for Beats: it goes to the Pitch knob, as 0.1.28 itself moves it)
  335. {
  336. juce::StringArray pitchAware, newEngines, knobPitch;
  337. bool warped = false;
  338. // (a project saved by this build has the mark; a channel without its own list then plays the pitch-aware Beats
  339. // and the Measured Texture / Complex Pro laws, which 0.1.28 reads as Measured Beats and its Classic engines)
  340. const auto marked = (bool) root.getProperty ("warpLaw190ik", false);
  341. forEachChannel (root, [&] (juce::DynamicObject& c, int i) {
  342. auto* sampler = objectOf (c.getProperty ("samplerSettings"));
  343. if (sampler == nullptr)
  344. return;
  345. const juce::var sv (sampler);
  346. const auto method = (int) sv.getProperty ("stretchMethod", 0); // (StretchMethod: 3 Beats, 5 Texture, 6 Complex)
  347. const auto stretched = (double) sv.getProperty ("stretchBeats", 0.0) > 0.0;
  348. const auto keepsPitch = (bool) sv.getProperty ("keepPitch", false);
  349. warped = warped || stretched;
  350. auto* list = arrayOf (sampler->getProperty ("warpModes"));
  351. const auto listed = list != nullptr && list->size() >= 9;
  352. const auto beatsLaw = listed && list->size() > 9 ? (double) (*list)[9] : 2.0;
  353. const auto warpLaw = listed && list->size() > 10 ? (double) (*list)[10] : 1.0;
  354. const auto complexPro = listed && (double) (*list)[8] != 0.0;
  355. if (marked && stretched && keepsPitch && method == 3 && beatsLaw >= 1.5)
  356. pitchAware.add (channelName (juce::var (&c), i));
  357. if (marked && stretched && keepsPitch && warpLaw >= 0.5 && (method == 5 || (method == 6 && complexPro)))
  358. newEngines.add (channelName (juce::var (&c), i));
  359. if (list != nullptr && list->size() > 10)
  360. {
  361. if (beatsLaw >= 1.5)
  362. list->set (9, 1.0);
  363. list->removeRange (10, list->size() - 10);
  364. }
  365. if (const auto baked = (double) sv.getProperty ("stretchPitch", 0.0); baked != 0.0 && method != 3)
  366. {
  367. sampler->setProperty ("pitch", juce::jlimit (-24.0, 24.0, (double) sv.getProperty ("pitch", 0.0) + baked));
  368. sampler->removeProperty ("stretchPitch");
  369. knobPitch.add (channelName (juce::var (&c), i));
  370. }
  371. });
  372. if (! pitchAware.isEmpty())
  373. lost.push_back ({ TR_NOOP ("Beats' pitch-aware cuts play as the Measured law: {0}"), listOf (pitchAware), true });
  374. if (! newEngines.isEmpty())
  375. lost.push_back ({ TR_NOOP ("Texture and Complex Pro play their earlier engine (no grains or formants): {0}"), listOf (newEngines), true });
  376. if (! knobPitch.isEmpty())
  377. lost.push_back ({ TR_NOOP ("Complex Pro and Texture transpositions play through the Pitch knob: {0}"), listOf (knobPitch), true });
  378. // issue #187 (round 190ik): engine behaviour, nothing to drop; reported when warped samples meet tempo automation
  379. bool tempoAutomation = false;
  380. if (auto* automations = arrayOf (root["automations"]))
  381. for (const auto& a : *automations)
  382. tempoAutomation = tempoAutomation || a["target"][0].toString() == "tempo";
  383. if (warped && tempoAutomation)
  384. lost.push_back ({ TR_NOOP ("Warped samples do not follow tempo changes in this release: they keep the project tempo"), {}, true });
  385. }
  386. // rollup step 3, round 190im (R12): Live's deactivated clip slots ("inactive"); 0.1.28 plays them
  387. {
  388. int inactive = 0;
  389. if (auto* slots = arrayOf (root["clipGrid"]["clips"]))
  390. for (auto& slot : *slots)
  391. if (auto* so = objectOf (slot))
  392. inactive += drop (*so, "inactive") ? 1 : 0;
  393. if (inactive > 0)
  394. lost.push_back ({ TR_NOOP ("{0} deactivated clip slot(s) play again"), juce::String (inactive), true });
  395. }
  396. // rollup step 4, round 190jh: Facet EQ's automatic dynamic thresholds (hidden parameters past its count; 0.1.28 plays
  397. // those bands with their manual threshold)
  398. {
  399. juce::StringArray autoBands;
  400. forEachEffect (root, [&] (juce::DynamicObject& e, const juce::String& where) {
  401. auto* params = arrayOf (e.getProperty ("params"));
  402. if (params == nullptr || e.getProperty ("kind").toString() != "facetEq" || params->size() <= facet::autoThresholdParam0)
  403. return;
  404. for (int b = 0; b < 8 && facet::autoThresholdParam0 + b < params->size(); ++b)
  405. if ((float) (double) (*params)[facet::autoThresholdParam0 + b] >= 0.5f)
  406. addOnce (autoBands, where);
  407. params->removeRange (facet::autoThresholdParam0, params->size() - facet::autoThresholdParam0);
  408. });
  409. if (! autoBands.isEmpty())
  410. lost.push_back ({ TR_NOOP ("Facet EQ's automatic dynamic thresholds play with the bands' manual threshold: {0}"), listOf (autoBands), true });
  411. }
  412. // rollup step 4, round 190jl: MIDI Out channels and the plugin wrappers' Output port reach hardware MIDI outputs from
  413. // 0.1.30 on (0.1.28 sends them to plugins on that port only); engine behaviour, nothing to drop
  414. {
  415. juce::StringArray hardware;
  416. forEachChannel (root, [&] (juce::DynamicObject& c, int i) {
  417. // (the wrapper's "midiOutPort" is written only when it has a port)
  418. if (c.getProperty ("instrument").toString() == "midiOut" || c.getProperty ("plugin").hasProperty ("midiOutPort"))
  419. addOnce (hardware, channelName (juce::var (&c), i));
  420. });
  421. if (! hardware.isEmpty())
  422. lost.push_back ({ TR_NOOP ("MIDI Out channels and plugins' MIDI output reach only plugins in this release, not hardware MIDI outputs: {0}"), listOf (hardware), true });
  423. }
  424. // rollup step 4, round 190jg: sample-accurate automation of hosted CLAP / VST3 plugins (0.1.28 applies a change once
  425. // per piece of up to 128 samples); engine behaviour, reported when automation drives such a plugin's parameter
  426. {
  427. const auto hosted = [] (const juce::var& plugin) {
  428. const auto id = plugin["id"].toString();
  429. return id.startsWith ("VST3-") || id.startsWith ("CLAP-");
  430. };
  431. bool timed = false;
  432. std::function<void (const juce::var&)> walk = [&] (const juce::var& v) {
  433. if (timed)
  434. return;
  435. if (auto* a = arrayOf (v))
  436. {
  437. for (const auto& item : *a)
  438. walk (item);
  439. return;
  440. }
  441. auto* o = objectOf (v);
  442. if (o == nullptr)
  443. return;
  444. if (const auto& target = o->getProperty ("target"); target.isArray() && target.size() >= 4)
  445. {
  446. const auto kind = target[0].toString();
  447. const auto index = (int) target[1], slot = (int) target[2];
  448. if (kind == "channelParam")
  449. timed = root["channels"][index]["instrument"].toString() == "plugin" && hosted (root["channels"][index]["plugin"]);
  450. else if (kind == "effectParam")
  451. timed = root["mixer"][index]["effects"][slot]["kind"].toString() == "plugin" && hosted (root["mixer"][index]["effects"][slot]["plugin"]);
  452. }
  453. for (const auto& p : o->getProperties())
  454. walk (p.value);
  455. };
  456. walk (root["automations"]);
  457. walk (root["patterns"]);
  458. walk (root["playlistTracks"]);
  459. if (timed)
  460. lost.push_back ({ TR_NOOP ("Automation of hosted CLAP and VST3 plugins changes once per 128 samples in this release (0.1.30 places each change at its own sample)"), {}, true });
  461. }
  462. // rollup step 5, round 190jv: on FL's native generators a slide note moves in steps, once per tick of the project, as
  463. // in FL (0.1.28 glides straight, except Slicex, which stepped already); engine behaviour, nothing to drop
  464. {
  465. juce::StringArray stepped;
  466. const auto* channels = arrayOf (root["channels"]);
  467. if (auto* patterns = arrayOf (root["patterns"]))
  468. for (const auto& p : *patterns)
  469. if (auto* notes = arrayOf (p["notes"]))
  470. for (const auto& n : *notes)
  471. if (n.isArray() && n.size() >= 9 && (bool) n[8]) // [start, length, channel, key, velocity, pan, fine, muted, slide, ..]
  472. {
  473. const auto ch = (int) n[2];
  474. if (channels == nullptr || ch < 0 || ch >= channels->size())
  475. continue;
  476. const auto& c = channels->getReference (ch);
  477. const auto kind = genpresets::kindFromId (c["instrument"].toString().toStdString());
  478. if (kind && *kind != InstrumentKind::slicex && RackRenderer::stepsSlides (*kind))
  479. addOnce (stepped, channelName (c, ch));
  480. }
  481. if (! stepped.isEmpty())
  482. lost.push_back ({ TR_NOOP ("Slide notes on FL's native generators glide instead of stepping once per tick: {0}"), listOf (stepped), true });
  483. }
  484. // rollup step 6, round 190kc: Live's crossfader (Crossfade Assign per insert, the Main's position and curve, its
  485. // automation target "crossfader", which 0.1.28 reads as no target) and the return tracks' flags (a return is an
  486. // insert like any other: 0.1.28 routes it the same, its sends are ordinary sends)
  487. {
  488. juce::StringArray assigned, returns;
  489. if (auto* mixer = arrayOf (root["mixer"]))
  490. for (int t = 0; t < mixer->size(); ++t)
  491. if (auto* m = objectOf ((*mixer)[t]))
  492. {
  493. if (drop (*m, "crossfade"))
  494. addOnce (assigned, insertName (root["mixer"], t));
  495. if (m->getProperty ("liveReturn").isBool() && (bool) m->getProperty ("liveReturn"))
  496. addOnce (returns, insertName (root["mixer"], t));
  497. drop (*m, "liveReturn");
  498. drop (*m, "returnPre");
  499. drop (*m, "returnSendsOn");
  500. }
  501. drop (o, "crossfader");
  502. drop (o, "crossfadeCurve");
  503. if (! assigned.isEmpty())
  504. lost.push_back ({ TR_NOOP ("The crossfader (Live's Crossfade Assign) is not in this release: these inserts play at their full level, and its automation does nothing: {0}"),
  505. listOf (assigned), true });
  506. if (! returns.isEmpty())
  507. lost.push_back ({ TR_NOOP ("Live return tracks show as ordinary mixer inserts: {0}"), listOf (returns), false });
  508. }
  509. // rollup step 6, round 190ke: the Simple dock's Controls tab and its own knob mapping (0.1.28 has no Controls tab)
  510. {
  511. juce::StringArray mapped;
  512. if (auto* mixer = arrayOf (root["mixer"]))
  513. for (int t = 0; t < mixer->size(); ++t)
  514. if (auto* m = objectOf ((*mixer)[t]); m != nullptr && drop (*m, "smartControls"))
  515. addOnce (mapped, insertName (root["mixer"], t));
  516. if (! mapped.isEmpty())
  517. lost.push_back ({ TR_NOOP ("The Simple Controls tab's own knob mappings: {0}"), listOf (mapped), false });
  518. }
  519. // rollup step 6, round natives190kj: ChannelDef::engineRev (Harmor 1 = a part with a sample in its IMG section plays
  520. // FL's resynthesis; 0.1.28 plays such a part's timbres) and Newtone's state version 3 (+ the key, each note's voiced
  521. // end and velocity): 0.1.28 reads up to version 2 and would load no notes at all, so the state is written as version
  522. // 2 (the notes and every edit kept; the voiced end only shaped the analysed smooth times, which are saved)
  523. {
  524. juce::StringArray resynth, newtone;
  525. forEachChannel (root, [&] (juce::DynamicObject& c, int i) {
  526. const auto rev = (int) c.getProperty ("engineRev");
  527. if (drop (c, "engineRev") && rev >= 1 && c.getProperty ("instrument").toString() == "harmor")
  528. {
  529. juce::MemoryOutputStream decoded;
  530. if (juce::Base64::convertFromBase64 (decoded, c.getProperty ("pluginState").toString()))
  531. {
  532. const auto* bytes = static_cast<const std::uint8_t*> (decoded.getData());
  533. if (harmorUsesResynthesis (std::vector<std::uint8_t> (bytes, bytes + decoded.getDataSize())))
  534. addOnce (resynth, channelName (juce::var (&c), i));
  535. }
  536. }
  537. });
  538. forEachEffect (root, [&] (juce::DynamicObject& e, const juce::String& where) {
  539. if (e.getProperty ("kind").toString() != "newtone")
  540. return;
  541. juce::MemoryOutputStream decoded;
  542. if (! juce::Base64::convertFromBase64 (decoded, e.getProperty ("state").toString()))
  543. return;
  544. const auto* bytes = static_cast<const std::uint8_t*> (decoded.getData());
  545. const std::vector<std::uint8_t> state (bytes, bytes + decoded.getDataSize());
  546. if (newtonefx::nativeVersionOf (state) < 3)
  547. return;
  548. if (const auto track = newtonefx::parseNative (state))
  549. {
  550. const auto older = newtonefx::writeNative (*track, 2);
  551. e.setProperty ("state", juce::Base64::toBase64 (older.data(), older.size()));
  552. addOnce (newtone, where);
  553. }
  554. });
  555. if (! resynth.isEmpty())
  556. lost.push_back ({ TR_NOOP ("Harmor parts with a sample in the IMG section play their timbres instead of the resynthesis: {0}"), listOf (resynth), true });
  557. if (! newtone.isEmpty())
  558. lost.push_back ({ TR_NOOP ("Newtone's detected key and note velocities are left out: {0}"), listOf (newtone), false });
  559. }
  560. // rollup step 7: round 190kl's extra Peak Controller LFO shapes and round 190kt's console law of Crest's Bus style
  561. // (hidden parameters past the slot's count, written only when set; 0.1.28 plays FL's Shape and the Bus style as it
  562. // was), round 190kn's mixer lock state (0.1.28: a solo elsewhere silences the insert and Unmute All unmutes it),
  563. // round qafix190kq's imported take lanes (0.1.28 gives them columns in the clip grid and the Session mixer) and round
  564. // 190ks's "record the notes played in the plugin's window" switch (written only when off: 0.1.28 never records them)
  565. {
  566. juce::StringArray shapes, console, locked;
  567. forEachEffect (root, [&] (juce::DynamicObject& e, const juce::String& where) {
  568. auto* params = arrayOf (e.getProperty ("params"));
  569. if (params == nullptr)
  570. return;
  571. const auto kind = e.getProperty ("kind").toString();
  572. if (kind == "peakController" && params->size() > peakshapes::extraShapeParam)
  573. {
  574. if (peakshapes::idOf ((float) (double) (*params)[peakshapes::extraShapeParam]) != 0)
  575. addOnce (shapes, where);
  576. params->removeRange (peakshapes::extraShapeParam, params->size() - peakshapes::extraShapeParam);
  577. }
  578. else if (kind == "crestCompressor" && params->size() > crest::busLaw)
  579. {
  580. if ((float) (double) (*params)[crest::busLaw] >= 0.5f)
  581. addOnce (console, where);
  582. params->removeRange (crest::busLaw, params->size() - crest::busLaw);
  583. }
  584. });
  585. bool soloed = false;
  586. if (auto* mixer = arrayOf (root["mixer"]))
  587. for (int t = 0; t < mixer->size(); ++t)
  588. if (auto* m = objectOf ((*mixer)[t]))
  589. {
  590. soloed = soloed || (bool) m->getProperty ("solo");
  591. if (drop (*m, "lockState"))
  592. addOnce (locked, insertName (root["mixer"], t));
  593. }
  594. forEachChannel (root, [&] (juce::DynamicObject& c, int) {
  595. if (auto* plugin = objectOf (c.getProperty ("plugin")))
  596. drop (*plugin, "recordOwnNotes");
  597. });
  598. if (auto* mixer = arrayOf (root["mixer"]))
  599. for (auto& m : *mixer)
  600. if (auto* fx = arrayOf (m["effects"]))
  601. for (auto& e : *fx)
  602. if (auto* plugin = objectOf (e["plugin"]))
  603. drop (*plugin, "recordOwnNotes");
  604. if (! shapes.isEmpty())
  605. lost.push_back ({ TR_NOOP ("The Peak Controller's LYNX LFO shapes play its FL Shape: {0}"), listOf (shapes), true });
  606. if (! console.isEmpty())
  607. lost.push_back ({ TR_NOOP ("Crest Compressor's console law (the Waves SSLComp stand-in) plays as its Bus style: {0}"), listOf (console), true });
  608. if (! locked.isEmpty())
  609. lost.push_back ({ TR_NOOP ("Mixer lock states (a solo silences these inserts, and Unmute all unmutes them): {0}"), listOf (locked), soloed });
  610. if (auto* lanes = arrayOf (root["playlistTakeLanes"]))
  611. {
  612. const auto count = lanes->size();
  613. drop (o, "playlistTakeLanes");
  614. if (count > 0)
  615. lost.push_back ({ TR_NOOP ("{0} imported take lane(s) get their own columns in the clip grid and the Session mixer"), juce::String (count), false });
  616. }
  617. }
  618. // the view
  619. {
  620. // rollup step 4: round 190jf's nested Playlist folders (0.1.28 opens the groups one level deep), round 190jd's
  621. // second display view of an effect (Fruity Limiter's CURVE; 0.1.28 shows its one view)
  622. if (auto* nests = arrayOf (root["playlistTrackNest"]))
  623. {
  624. const auto count = nests->size();
  625. drop (o, "playlistTrackNest");
  626. if (count > 0)
  627. lost.push_back ({ TR_NOOP ("{0} track(s) in nested Playlist folders open one level deep"), juce::String (count), false });
  628. }
  629. juce::StringArray views;
  630. forEachEffect (root, [&] (juce::DynamicObject& e, const juce::String& where) {
  631. if (drop (e, "displayView"))
  632. addOnce (views, where);
  633. });
  634. if (! views.isEmpty())
  635. lost.push_back ({ TR_NOOP ("Fruity Limiter's CURVE view (its display shows the scrolling graph): {0}"), listOf (views), false });
  636. bool colours = false;
  637. if (auto* automations = arrayOf (root["automations"]))
  638. for (auto& a : *automations)
  639. if (auto* ao = objectOf (a))
  640. colours = drop (*ao, "colour") || colours;
  641. if (colours)
  642. lost.push_back ({ TR_NOOP ("Automation clip colours"), {}, false });
  643. if (drop (o, "mixSnapshots"))
  644. lost.push_back ({ TR_NOOP ("Mix snapshots (the Mixer menu)"), {}, false });
  645. }
  646. }
  647. // --- 0.1.29 / 0.1.30 → 0.1.28 ------------------------------------------------------------------------------------------
  648. void toRelease0128 (juce::var& root, Losses& lost)
  649. {
  650. auto& o = *objectOf (root);
  651. // (reported only when the project has such automation: the mark is on in every new project)
  652. bool levelAutomation = false;
  653. if (auto* automations = arrayOf (root["automations"]))
  654. for (const auto& a : *automations)
  655. if (const auto kind = a["target"][0].toString(); kind == "mixerVolume" || kind == "mixerPan" || kind == "mixerSend" || kind == "vcaLevel")
  656. levelAutomation = true;
  657. if (drop (o, "mixerLevelPdc190hq") && levelAutomation)
  658. lost.push_back ({ TR_NOOP ("Mixer › Plugin delay compensation › \"Compensate fader and route automations too\" is not in this release: that automation plays a little early behind plugins with latency"), {}, true });
  659. int markers = 0;
  660. if (auto* automations = arrayOf (root["automations"]))
  661. for (auto& a : *automations)
  662. if (auto* ao = objectOf (a); ao != nullptr && drop (*ao, "tempoMarkers"))
  663. if (auto* points = arrayOf (a["points"]))
  664. markers += juce::jmax (0, points->size() - 1);
  665. if (markers > 0)
  666. lost.push_back ({ TR_NOOP ("{0} tempo marker(s) on the ruler become a plain tempo automation clip (the tempo plays the same)"), juce::String (markers), false });
  667. // round 190hq's side-chain compensation is engine behaviour: nothing to drop, but an older release lines up less
  668. bool sidechain = false;
  669. if (auto* mixer = arrayOf (root["mixer"]))
  670. for (const auto& t : *mixer)
  671. if (auto* fx = arrayOf (t["effects"]))
  672. for (const auto& e : *fx)
  673. sidechain = sidechain || (int) e.getProperty ("sidechain", -1) > 0 || (int) e.getProperty ("sidechain2", -1) > 0;
  674. if (sidechain)
  675. lost.push_back ({ TR_NOOP ("Side-chains are not lined up with plugin delay compensation in this release: behind plugins with latency, ducking may be a few milliseconds off"), {}, true });
  676. toRelease0128FromRollup030 (root, lost);
  677. }
  678. // --- 0.1.28 → 0.1.27 -----------------------------------------------------------------------------------------------------
  679. // A slot 0.1.27 does not know (it would drop it, moving every later slot): a switched-off Utility in its place.
  680. bool flattenUnknownEffect (juce::var& e, const juce::StringArray& kinds)
  681. {
  682. auto* o = objectOf (e);
  683. if (o == nullptr || ! kinds.contains (e["kind"].toString()))
  684. return false;
  685. auto replacement = std::make_unique<juce::DynamicObject>();
  686. replacement->setProperty ("kind", "utility");
  687. replacement->setProperty ("on", false);
  688. for (const auto* keep : { "row", "sidechain", "sidechain2" })
  689. if (o->hasProperty (keep))
  690. replacement->setProperty (keep, o->getProperty (keep));
  691. e = juce::var (replacement.release());
  692. return true;
  693. }
  694. // nested chains (a Patcher's nodes, a rack's branches): every effect object below `v`
  695. void flattenNested (juce::var& v, int& count, const juce::StringArray& kinds)
  696. {
  697. if (auto* a = arrayOf (v))
  698. {
  699. for (auto& item : *a)
  700. flattenNested (item, count, kinds);
  701. return;
  702. }
  703. auto* o = objectOf (v);
  704. if (o == nullptr)
  705. return;
  706. for (auto& p : o->getProperties())
  707. {
  708. auto value = p.value;
  709. if (value.isObject() && kinds.contains (value["kind"].toString()) && (p.name.toString() == "effect" || p.name.toString() == "head"))
  710. {
  711. if (flattenUnknownEffect (value, kinds))
  712. {
  713. o->setProperty (p.name, value);
  714. ++count;
  715. }
  716. continue;
  717. }
  718. if (auto* list = arrayOf (value); list != nullptr && (p.name.toString() == "chain" || p.name.toString() == "effects"))
  719. for (auto& item : *list)
  720. if (flattenUnknownEffect (item, kinds))
  721. ++count;
  722. flattenNested (value, count, kinds);
  723. }
  724. }
  725. // automation that drove slot (track, slot)'s parameters or mix now drives nothing ("none")
  726. void detachTargets (juce::var& v, int track, int slot)
  727. {
  728. auto isSlotTarget = [&] (const juce::var& t) {
  729. if (! t.isArray() || t.size() < 4)
  730. return false;
  731. const auto kind = t[0].toString();
  732. return (kind == "effectParam" || kind == "effectMix") && (int) t[1] == track && (int) t[2] == slot;
  733. };
  734. if (auto* a = arrayOf (v))
  735. {
  736. for (auto& item : *a)
  737. detachTargets (item, track, slot);
  738. return;
  739. }
  740. auto* o = objectOf (v);
  741. if (o == nullptr)
  742. return;
  743. for (auto& p : o->getProperties())
  744. {
  745. auto value = p.value;
  746. if (p.name.toString() == "target" && isSlotTarget (value))
  747. if (auto* t = arrayOf (value))
  748. t->set (0, "none");
  749. if (p.name.toString() == "links")
  750. if (auto* links = arrayOf (value))
  751. for (auto& l : *links)
  752. if (isSlotTarget (l))
  753. if (auto* t = arrayOf (l))
  754. t->set (0, "none");
  755. detachTargets (value, track, slot);
  756. }
  757. }
  758. // Every slot of `kinds` (mixer inserts, Patchers, racks) becomes a switched-off Utility; their automation is detached and one
  759. // loss line names where they were
  760. void flattenEffects (juce::var& root, const juce::StringArray& kinds, const char* loss, Losses& lost)
  761. {
  762. auto& o = *objectOf (root);
  763. juce::StringArray where;
  764. if (auto* mixer = arrayOf (root["mixer"]))
  765. for (int t = 0; t < mixer->size(); ++t)
  766. if (auto* fx = arrayOf ((*mixer)[t]["effects"]))
  767. for (int s = 0; s < fx->size(); ++s)
  768. if (flattenUnknownEffect (fx->getReference (s), kinds))
  769. {
  770. where.add (insertName (o.getProperty ("mixer"), t) + juce::String::fromUTF8 (" \u203a ") + juce::String (s + 1));
  771. detachTargets (root, t, s);
  772. }
  773. int nested = 0;
  774. if (auto* mixer = arrayOf (root["mixer"]))
  775. for (auto& t : *mixer)
  776. if (auto* fx = arrayOf (t["effects"]))
  777. for (auto& e : *fx)
  778. flattenNested (e, nested, kinds);
  779. if (auto* channels = arrayOf (root["channels"]))
  780. for (auto& c : *channels)
  781. flattenNested (c, nested, kinds);
  782. if (nested > 0)
  783. where.add (juce::String (nested) + juce::String::fromUTF8 (" \u00d7 Patcher"));
  784. if (! where.isEmpty())
  785. lost.push_back ({ loss, listOf (where), true });
  786. }
  787. void toRelease0127 (juce::var& root, Losses& lost)
  788. {
  789. auto& o = *objectOf (root);
  790. // the effect 0.1.28 added (Anvil Bus, round 190fk)
  791. flattenEffects (root, { "anvilBus" }, TR_NOOP ("Anvil Bus is not in this release: it becomes a switched-off Utility in its slot, and its automation does nothing ({0})"), lost);
  792. // channels
  793. {
  794. juce::StringArray cut, pads, warp, frozen, beats, soundfonts;
  795. bool scales = false;
  796. forEachChannel (root, [&] (juce::DynamicObject& c, int i) {
  797. const auto name = channelName (juce::var (&c), i);
  798. if (drop (c, "cutOthersOnly") | drop (c, "cutAtNoteEnd"))
  799. cut.add (name);
  800. scales = drop (c, "editorScale") || scales;
  801. if (drop (c, "simplePad"))
  802. pads.add (name);
  803. if (drop (c, "trackFreeze"))
  804. frozen.add (name);
  805. if (auto* sampler = objectOf (c.getProperty ("samplerSettings")))
  806. {
  807. if (drop (*sampler, "warpModes"))
  808. warp.add (name);
  809. if ((int) sampler->getProperty ("stretchMethod") == (int) StretchMethod::beats)
  810. beats.add (name);
  811. }
  812. if (c.getProperty ("instrument").toString() == "soundfont")
  813. soundfonts.add (name);
  814. });
  815. if (! cut.isEmpty())
  816. lost.push_back ({ TR_NOOP ("Cut group modes (\"Cut others only\", \"Cut at the note's end\"): {0}"), listOf (cut), true });
  817. if (! pads.isEmpty())
  818. lost.push_back ({ TR_NOOP ("Simple workflow pad settings (mode, tone, release, group): {0}"), listOf (pads), true });
  819. if (! warp.isEmpty())
  820. lost.push_back ({ TR_NOOP ("Warp mode settings (Preserve, loop mode, grain sizes) go back to their defaults: {0}"), listOf (warp), true });
  821. if (! frozen.isEmpty())
  822. lost.push_back ({ TR_NOOP ("Freeze Track: these channels play live again (the same sound, more CPU): {0}"), listOf (frozen), false });
  823. if (scales)
  824. lost.push_back ({ TR_NOOP ("Plugin window sizes (Scale)"), {}, false });
  825. if (drop (o, "beatsLaw190gx") && ! beats.isEmpty())
  826. lost.push_back ({ TR_NOOP ("Beats warping uses this release's older (Classic) law: {0}"), listOf (beats), true });
  827. if (drop (o, "sfModBase190he") && ! soundfonts.isEmpty())
  828. lost.push_back ({ TR_NOOP ("Soundfont modulation knobs centre at this release's older value: {0}"), listOf (soundfonts), true });
  829. }
  830. // clips: index 24 (a Playlist clip's groove, round 190fm) and 25 (its envelopes, round 190gi) are new
  831. {
  832. int grooves = 0, envelopes = 0;
  833. forEachClip (root, [&] (juce::Array<juce::var>& clip) {
  834. if (clip.size() > 24 && (juce::int64) clip[24] != 0)
  835. ++grooves;
  836. if (clip.size() > 25 && (int) clip[25] >= 0)
  837. ++envelopes;
  838. if (clip.size() > 24)
  839. clip.removeRange (24, clip.size() - 24);
  840. });
  841. if (drop (o, "clipEnvelopes") && envelopes > 0)
  842. lost.push_back ({ TR_NOOP ("{0} audio clip envelope(s): those clips play at their own level and pan"), juce::String (envelopes), true });
  843. if (grooves > 0)
  844. lost.push_back ({ TR_NOOP ("{0} Playlist clip groove(s): those clips play straight"), juce::String (grooves), true });
  845. }
  846. // automation clips with several target links (round 190gw): 0.1.27 drives the first one, 1:1
  847. {
  848. juce::StringArray linked;
  849. if (auto* automations = arrayOf (root["automations"]))
  850. for (int i = 0; i < automations->size(); ++i)
  851. if (auto* a = objectOf ((*automations)[i]))
  852. {
  853. const auto links = a->getProperty ("links");
  854. const auto formula = links.isArray() && links.size() > 0 && links[0].isArray() && links[0].size() >= 5 ? links[0][4].toString() : juce::String();
  855. if (drop (*a, "links") && (links.size() > 1 || formula.isNotEmpty()))
  856. linked.add ("\"" + a->getProperty ("name").toString() + "\"");
  857. }
  858. if (! linked.isEmpty())
  859. lost.push_back ({ TR_NOOP ("Automation clips with several targets or a formula drive only their first target, 1:1: {0}"), listOf (linked), true });
  860. }
  861. // the song
  862. if (o.hasProperty ("beatUnit"))
  863. {
  864. const auto unit = (int) o.getProperty ("beatUnit");
  865. drop (o, "beatUnit");
  866. lost.push_back ({ TR_NOOP ("The time signature's beat unit: n/{0} becomes n/4"), juce::String (unit), true });
  867. }
  868. if (drop (o, "linkTracksToMixer"))
  869. lost.push_back ({ TR_NOOP ("\"Link Playlist tracks to mixer tracks\" (a setting)"), {}, false });
  870. if (drop (o, "midiGenerate"))
  871. lost.push_back ({ TR_NOOP ("MIDI generator settings"), {}, false });
  872. if (drop (o, "playlistRowHeight"))
  873. lost.push_back ({ TR_NOOP ("The Playlist's row height"), {}, false });
  874. }
  875. struct Step
  876. {
  877. const char* release; // the release this step's output is for
  878. void (*apply) (juce::var&, Losses&);
  879. };
  880. // newest first: a copy for release R runs every step down to R's
  881. constexpr Step steps[] = { { "0.1.28", toRelease0128 }, { "0.1.27", toRelease0127 } };
  882. } // namespace
  883. juce::StringArray releases()
  884. {
  885. juce::StringArray r;
  886. for (const auto& s : steps)
  887. r.add (s.release);
  888. return r;
  889. }
  890. Copy forRelease (const juce::String& projectJson, const juce::String& release)
  891. {
  892. Copy copy;
  893. if (! releases().contains (release))
  894. {
  895. copy.error = "no such release: " + release;
  896. return copy;
  897. }
  898. auto root = juce::JSON::parse (projectJson);
  899. if (objectOf (root) == nullptr)
  900. {
  901. copy.error = "not a project";
  902. return copy;
  903. }
  904. const auto from = root["savedBy"].toString();
  905. for (const auto& s : steps)
  906. {
  907. s.apply (root, copy.lost);
  908. if (release == s.release)
  909. break;
  910. }
  911. // stamped as that release's own file (no "saved by a newer version" notice there); where it came from, for us
  912. objectOf (root)->setProperty ("savedBy", release);
  913. if (from.isNotEmpty())
  914. objectOf (root)->setProperty ("copiedFrom", from);
  915. copy.json = juce::JSON::toString (root, true);
  916. copy.ok = true;
  917. return copy;
  918. }
  919. Copy forRelease (const Song& song, const juce::String& release)
  920. {
  921. return forRelease (ProjectFile::toJson (song), release);
  922. }
  923. juce::String copyName (const juce::String& projectName, const juce::String& release)
  924. {
  925. return (projectName.isNotEmpty() ? projectName : juce::String ("Untitled")) + " (for LYNX " + release + ")";
  926. }
  927. } // namespace lynx::olderlynx