DetailsShot190mk.inc 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. // --details190mkshot <prefix> <project.flp> (round 190mk, details pass 6): Live's insert marker (Clip-launch, Live's
  2. // look), the Channel rack's zipped channels, Fruity Multiband's peak display with its SPEED slider, the rack's
  3. // Options menu items. <prefix>-checks.txt lists the checks. Included in the app class of Main.cpp.
  4. bool runDetailsShot190mk (const juce::String& prefix, const juce::String& project)
  5. {
  6. juce::LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
  7. const juce::ScopedValueSetter<bool> shown (lynx::ui::showingForShots(), true);
  8. juce::String checks;
  9. bool allOk = true;
  10. const auto check = [&checks, &allOk] (const juce::String& what, bool ok) {
  11. checks << (ok ? "ok " : "FAIL ") << what << "\n";
  12. allOk = allOk && ok;
  13. };
  14. const auto line = [&checks] (const juce::String& what) { checks << " " << what << "\n"; };
  15. const auto write = [&prefix] (juce::Component& c, const juce::String& name) { savePng (lynx::shot::snapshot (c), prefix + "-" + name + ".png"); };
  16. const auto zoomShot = [&prefix] (juce::Component& c, juce::Rectangle<int> r, float k, const juce::String& name) {
  17. savePng (c.createComponentSnapshot (r.getIntersection (c.getLocalBounds()), true, k), prefix + "-" + name + ".png");
  18. };
  19. using namespace lynx;
  20. if (project.isNotEmpty())
  21. {
  22. AudioEngine offline (false);
  23. MainComponent ui (offline, false);
  24. ui.setSize (1920, 1080);
  25. ui.openFile (juce::File (project));
  26. offline.dispatchPendingMessages();
  27. // ---- the Channel rack's zipped channels (DE-38): FL's capture zipped two neighbouring channels
  28. {
  29. auto& rack = ui.getRackForSnapshot();
  30. ui.showPanelsForSnapshot ({ workspace::Panel::channelRack });
  31. rack.updateSize();
  32. offline.dispatchPendingMessages();
  33. const auto menu = ui.rackMenuForSnapshot();
  34. juce::StringArray items;
  35. for (juce::PopupMenu::MenuItemIterator it (menu, true); it.next();)
  36. if (! it.getItem().text.isEmpty())
  37. items.add (it.getItem().text);
  38. check ("rack menu: Zip selected / Unzip all", items.joinIntoString ("|").contains (tr ("Zip selected")) && items.joinIntoString ("|").contains (tr ("Unzip all")));
  39. const auto before = rack.getHeight();
  40. write (rack, "rack-before-zip");
  41. offline.setChannelSelection ({ 1, 2 }, 1);
  42. rack.zipSelected();
  43. offline.dispatchPendingMessages();
  44. rack.updateSize();
  45. juce::Rectangle<int> strip;
  46. const auto zipped = rack.zipStripForSnapshot (1, strip) && offline.getSong().channels[1].zipped && offline.getSong().channels[2].zipped;
  47. line ("rack height " + juce::String (before) + " -> " + juce::String (rack.getHeight()) + ", strip " + strip.toString());
  48. check ("Zip selected: the two channels in one half-row strip", zipped && strip.getHeight() == ChannelRackComponent::rowHeight / 2
  49. && rack.getHeight() == before - (2 * ChannelRackComponent::rowHeight - ChannelRackComponent::rowHeight / 2));
  50. write (rack, "rack-zipped");
  51. zoomShot (rack, juce::Rectangle<int> (0, 0, 560, strip.getBottom() + 3 * ChannelRackComponent::rowHeight), 2.0f, "rack-zipped@2x");
  52. zoomShot (rack, juce::Rectangle<int> (0, 0, rack.getWidth(), strip.getBottom() + 3 * ChannelRackComponent::rowHeight), 1.5f, "rack-zipped@150");
  53. rack.unzip (2);
  54. offline.dispatchPendingMessages();
  55. check ("a right-click on a bar unzips that channel", ! offline.getSong().channels[2].zipped && offline.getSong().channels[1].zipped);
  56. rack.unzipAll();
  57. offline.dispatchPendingMessages();
  58. rack.updateSize();
  59. check ("Unzip all: the rack as before", rack.getHeight() == before && ! offline.getSong().channels[1].zipped);
  60. // Channel button width (DE-39): FL's 400 % (80 -> 332 px there; 150 -> 622 px here), then back
  61. rack.setButtonWidth (400);
  62. offline.dispatchPendingMessages();
  63. line ("button width at 400 %: " + juce::String (ChannelRackComponent::nameWidth) + " px");
  64. check ("Channel button width 400 %: FL's proportion (x 4.15)", ChannelRackComponent::nameWidth == ChannelRackComponent::widthForPercent (400)
  65. && std::abs (ChannelRackComponent::nameWidth / 150.0 - 332.0 / 80.0) < 0.01);
  66. zoomShot (rack, juce::Rectangle<int> (0, 0, rack.getWidth(), juce::jmin (rack.getHeight(), 8 * ChannelRackComponent::rowHeight)), 1.0f, "rack-button-width-400");
  67. rack.setButtonWidth (0);
  68. line ("button width, size to fit: " + juce::String (ChannelRackComponent::nameWidth) + " px");
  69. rack.setButtonWidth (100);
  70. check ("Channel button width 100 %: LYNX's 150 px", ChannelRackComponent::nameWidth == 150);
  71. // the piano roll preview's mute button (DE-33): a muted channel with a preview keeps the crossed icon
  72. int previewRow = -1;
  73. for (int p = 0; p < (int) offline.getSong().patterns.size() && previewRow < 0; ++p)
  74. {
  75. for (int c = 0; c < (int) offline.getSong().channels.size() && previewRow < 0; ++c)
  76. if (showsNotePreview (offline.getSong().patterns[(std::size_t) p], c))
  77. previewRow = c;
  78. if (previewRow >= 0)
  79. offline.editSong ([p] (Song& s) { s.currentPattern = p; }, false);
  80. }
  81. offline.dispatchPendingMessages();
  82. rack.updateSize();
  83. line ("preview row " + juce::String (previewRow));
  84. if (previewRow >= 0)
  85. {
  86. offline.editSong ([previewRow] (Song& s) { s.channels[(std::size_t) previewRow].muted = true; });
  87. offline.dispatchPendingMessages();
  88. rack.updateSize();
  89. const auto rowTop = rack.rowTopForSnapshot (previewRow);
  90. zoomShot (rack, juce::Rectangle<int> (0, rowTop - 2, rack.getWidth(), ChannelRackComponent::rowHeight + 4), 2.0f, "rack-preview-muted@2x");
  91. offline.editSong ([previewRow] (Song& s) { s.channels[(std::size_t) previewRow].muted = false; });
  92. }
  93. check ("Options menu: Show a mute button on the piano roll preview, Channel button width",
  94. items.joinIntoString ("|").contains (tr ("Show a mute button on the piano roll preview")) && items.joinIntoString ("|").contains (tr ("Channel button width")));
  95. }
  96. // ---- an automation clip's Articulator tools (DE-115)
  97. {
  98. const auto& song = offline.getSong();
  99. int clipIndex = -1;
  100. for (int i = 0; i < (int) song.playlist.size() && clipIndex < 0; ++i)
  101. if (song.playlist[(std::size_t) i].kind == ClipKind::automation && song.playlist[(std::size_t) i].automation >= 0)
  102. clipIndex = i;
  103. if (clipIndex >= 0)
  104. {
  105. const auto clip = song.playlist[(std::size_t) clipIndex];
  106. const auto menu = articulator::menu (offline, clip.automation, clip.length, ui);
  107. juce::StringArray items;
  108. for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
  109. if (! it.getItem().text.isEmpty())
  110. items.add (it.getItem().text);
  111. line ("Articulator tools: " + items.joinIntoString (" | "));
  112. check ("automation clip: FL's Articulator tools", items.size() == 12 && items.contains (tr ("Smooth up abrupt changes")) && items.contains (tr ("Analyze audio file...")));
  113. saveMenus (juce::StringArray { tr ("Articulator tools") }, { menu }, prefix + "-menu-articulator.png");
  114. const auto before = offline.getSong().automations[(std::size_t) clip.automation].points;
  115. for (juce::PopupMenu::MenuItemIterator it (menu); it.next();)
  116. if (it.getItem().text == tr ("Flip vertically") && it.getItem().action)
  117. it.getItem().action();
  118. const auto& after = offline.getSong().automations[(std::size_t) clip.automation].points;
  119. check ("Articulator › Flip vertically flips the clip's points", ! before.empty() && after.size() == before.size()
  120. && std::abs (after[0].value - (1.0f - before[0].value)) < 1.0e-6f);
  121. offline.undo();
  122. }
  123. else
  124. line ("no automation clip in the project");
  125. }
  126. // ---- Live's insert marker (DL-70): Clip-launch layout, Live's look
  127. {
  128. ui.setLayoutStyle (layoutstyle::Style::clipLaunch);
  129. offline.dispatchPendingMessages();
  130. auto& pl = ui.getPlaylistForSnapshot();
  131. ui.showPanelsForSnapshot ({ workspace::Panel::playlist });
  132. offline.dispatchPendingMessages();
  133. juce::Rectangle<int> lineBox;
  134. juce::String hint;
  135. const auto tick = (std::int64_t) offline.getSong().barTicks() * 2 + (std::int64_t) ppq; // bar 3, beat 2
  136. const auto ok = pl.insertMarkForSnapshot (1, tick, lineBox, hint);
  137. line ("insert mark line " + lineBox.toString() + ", hint \"" + hint + "\"");
  138. check ("Live look: the insert marker, 1 px over the lane (17 px in Live's 19 px lane)", ok && lineBox.getWidth() == 1 && lineBox.getHeight() >= 15);
  139. check ("status bar text: Insert Mark 3.2.1 (Time: m:ss:ms)", hint.startsWith (tr ("Insert Mark {0} (Time: {1})", { "3.2.1", "" }).upToFirstOccurrenceOf ("(", false, false)));
  140. write (pl, "live-insert-marker");
  141. zoomShot (pl, lineBox.expanded (60, 24), 4.0f, "live-insert-marker@4x");
  142. zoomShot (pl, lineBox.expanded (200, 60), 1.5f, "live-insert-marker@150");
  143. ui.setLayoutStyle (layoutstyle::Style::pattern);
  144. offline.dispatchPendingMessages();
  145. }
  146. }
  147. {
  148. // ---- Gross Beat's mapping menu, the rest (DP-7): State / Points selection / Tools / Options / View
  149. AudioEngine offline (false);
  150. Song gb;
  151. gb.mixer.resize (2);
  152. gb.mixer[0].name = "Master";
  153. gb.mixer[1].name = "Insert 1";
  154. gb.mixer[1].effects.push_back (makeEffectSlot (EffectKind::grossBeat));
  155. offline.setSong (std::move (gb));
  156. offline.dispatchPendingMessages();
  157. auto editor = makeNativeEffectEditor (offline, 1, 0, 1.0f, 0);
  158. showGrossBeatEnvelopeForSnapshot (*editor, 0);
  159. grossBeatEditForSnapshot (*editor, 4); // (FL's Basic 4, as in the capture)
  160. juce::PopupMenu menu;
  161. grossBeatToolsForSnapshot (*editor, false, false, false, &menu);
  162. juce::StringArray items;
  163. for (juce::PopupMenu::MenuItemIterator it (menu, true); it.next();)
  164. if (! it.getItem().text.isEmpty())
  165. items.add (it.getItem().text);
  166. line ("mapping menu: " + items.joinIntoString (" | "));
  167. check ("mapping menu: FL's Presets, state files, Prepare, point clipboard, Analyze, Options, View",
  168. items.contains (tr ("Presets")) && items.contains (tr ("Open state file...")) && items.contains (tr ("Save state file..."))
  169. && items.contains (tr ("Prepare for smooth editing")) && items.contains (tr ("Paste (insert)")) && items.contains (tr ("Paste (replace)"))
  170. && items.contains (tr ("Duplicate")) && items.contains (tr ("Analyze audio file...")) && items.contains (tr ("Focus on click"))
  171. && items.contains (tr ("Background gradient")) && items.contains (tr ("Invert grid")));
  172. saveMenus (juce::StringArray { "Gross Beat: mapping options" }, { menu }, prefix + "-menu-grossbeat-mapping.png");
  173. write (*editor, "plug-grossbeat-before");
  174. grossBeatEditForSnapshot (*editor, 2);
  175. write (*editor, "plug-grossbeat-paste-insert");
  176. grossBeatEditForSnapshot (*editor, 4);
  177. grossBeatEditForSnapshot (*editor, 1);
  178. write (*editor, "plug-grossbeat-prepare-smooth");
  179. grossBeatEditForSnapshot (*editor, 3);
  180. write (*editor, "plug-grossbeat-gradient-grid");
  181. grossBeatEditForSnapshot (*editor, 0);
  182. auto big = makeNativeEffectEditor (offline, 1, 0, 1.5f, 0);
  183. showGrossBeatEnvelopeForSnapshot (*big, 0);
  184. write (*big, "plug-grossbeat-prepare-smooth@150");
  185. }
  186. {
  187. // ---- Fruity Multiband Compressor's peak display and SPEED (DP-30)
  188. AudioEngine offline (false);
  189. Song song;
  190. song.mixer.resize (2);
  191. song.mixer[0].name = "Master";
  192. song.mixer[1].name = "Insert 1";
  193. song.mixer[1].effects.push_back (makeEffectSlot (EffectKind::fruityMultiband));
  194. offline.setSong (std::move (song));
  195. offline.dispatchPendingMessages();
  196. auto editor = makeNativeEffectEditor (offline, 1, 0, 1.0f, 0);
  197. multibandMetersForSnapshot (*editor);
  198. check ("Multiband: the scrolling peak display at FL's default SPEED", multibandHistoryForSnapshot (*editor, 0.5f));
  199. write (*editor, "plug-multiband-peaks");
  200. check ("Multiband: SPEED 0 shows the crossover graph only", ! multibandHistoryForSnapshot (*editor, 0.0f));
  201. write (*editor, "plug-multiband-speed0");
  202. auto big = makeNativeEffectEditor (offline, 1, 0, 1.5f, 0);
  203. multibandMetersForSnapshot (*big);
  204. multibandHistoryForSnapshot (*big, 0.5f);
  205. write (*big, "plug-multiband-peaks@150");
  206. }
  207. juce::File (prefix + "-checks.txt").replaceWithText (checks + (allOk ? "result=OK\n" : "result=FAIL\n"));
  208. return allOk;
  209. }