فهرست منبع

Chord lane UI: a LYNX extra in every layout, off by default (Playlist menu > View, Settings > LYNX extras, the Simple ruler menu), under the Sections lane; FL marker-tag look in Pattern, Live greys in Clip-launch, rounded blocks in Simple; double-click picks a chord (the key's degree chords first, any root and shape, a bass), drag moves on the snap, the right edge resizes, Del deletes; lane menu: detect from the notes or the selected audio clip (Basic Pitch), chords from key regions, Export chords as MIDI, Use these chords on the Chord pad, Channels that follow the chords; Piano roll View > Highlight the Chord lane's chord; the Chord pad's menu offers the song's chords; Smart Tempo preview (bars and tempo graph, bar 1's beat, half / double, Smooth) from the audio clip menu's LYNX extras

Ka1-S 2 هفته پیش
والد
کامیت
232b7c436f

+ 7 - 0
src/core/LynxExtras.h

@@ -134,6 +134,13 @@ inline constexpr Item items[] = {
     { "playlist.sectionsLane", TR_NOOP ("Playlist"), TR_NOOP ("Sections lane"),
       TR_NOOP ("A lane under the Playlist's ruler with named song sections (Intro, Verse, Chorus...): drag one to move it with every clip, automation and marker under it, Ctrl+drag to copy it, drop it onto another to swap them. FL Studio has only time markers; an .flp export writes a marker at each section's start. Also in the Playlist menu › View."),
       "ui-options.txt:sectionsLane" },
+    // round 190pf (research190oe P13): Cubase's / Logic's / Studio Pro's chord track (FL and Live have none)
+    { "playlist.chordLane", TR_NOOP ("Playlist"), TR_NOOP ("Chord lane"),
+      TR_NOOP ("A lane under the Playlist's ruler with the song's chords: draw them, pick them from the key's degree chords or detect them from the notes or an audio clip; channels can follow them while the song plays, and the Chord pad can play them. FL Studio has no chord track; an .flp export writes a marker at each chord's start. Also in the Playlist menu › View."),
+      "ui-options.txt:chordLane" },
+    { "pianoRoll.chordHighlight", TR_NOOP ("Piano Roll"), TR_NOOP ("Highlight the Chord lane's chord (LYNX)"),
+      TR_NOOP ("The Piano roll's rows light the notes of the Chord lane's chord at the song position instead of the scale, and switch as the song plays. Also in the Piano roll's View menu."),
+      "ui-options.txt:prChordHighlight" },
     // round 190oo (design review O-1, issue #230): FL 2026 draws only the fade curve; Live (and #230's picture) shade
     { "playlist.shadeFadedAudio", TR_NOOP ("Playlist"), TR_NOOP ("Shade faded audio (LYNX)"),
       TR_NOOP ("The Pattern layout also darkens the part of an audio clip that a fade takes away, as the Clip-launch layout and Live do; FL Studio draws only the fade curve. Also in Playlist › View."),

+ 45 - 0
src/ui/AudioToMidi.cpp

@@ -468,6 +468,46 @@ void convertClip (AudioEngine& engine, int clipIndex, const Request& request, st
     });
 }
 
+// round 190pf: the clip's notes in song ticks (a2m::addClipPattern's mapping), for the Chord lane
+void detectClip (AudioEngine& engine, int clipIndex, std::function<void (std::vector<chordlane::TimedNote>, std::int64_t, std::int64_t)> done)
+{
+    Request request;
+    request.mode = a2m::Mode::harmony;
+    auto work = prepareClip (engine, clipIndex, request);
+    if (! work)
+        return;
+    auto mono = std::move (work->mono);
+    const auto rate = work->rate;
+    startJob (std::move (mono), rate, request, [&engine, clipIndex, w = std::move (*work), done] (std::vector<a2m::Note> notes) {
+        const auto& song = engine.getSong();
+        if (clipIndex < 0 || clipIndex >= (int) song.playlist.size() || ! done)
+            return;
+        const auto& clip = song.playlist[(std::size_t) clipIndex];
+        const auto tickOf = [&] (double seconds) {
+            const auto frame = (double) w.range.first + seconds * w.timing.sampleRate;
+            const auto fromZero = w.timing.backwards ? w.timing.spanFrames - (frame - w.timing.zeroFrame) : frame - w.timing.zeroFrame;
+            return (double) clip.start + fromZero / w.timing.framesPerTick - (double) clip.offset;
+        };
+        std::vector<chordlane::TimedNote> out;
+        for (const auto& n : notes)
+        {
+            auto a = tickOf (n.start), b = tickOf (n.end);
+            if (a > b)
+                std::swap (a, b);
+            chordlane::TimedNote t;
+            t.start = std::max (clip.start, (std::int64_t) std::llround (a));
+            t.end = std::min (clip.end(), (std::int64_t) std::llround (b));
+            t.key = std::clamp (n.key + w.transpose, 0, 127);
+            if (t.end > t.start)
+                out.push_back (t);
+        }
+        if (out.empty())
+            noNotes();
+        else
+            done (std::move (out), clip.start, clip.end());
+    });
+}
+
 void convertAudio (AudioEngine& engine, std::vector<float> mono, double sampleRate, const Request& request, const juce::String& name,
                    std::function<void (int)> done)
 {
@@ -639,6 +679,11 @@ private:
 };
 } // namespace
 
+void detectClipNotes (AudioEngine& engine, int clipIndex, std::function<void (std::vector<chordlane::TimedNote>, std::int64_t, std::int64_t)> done)
+{
+    detectClip (engine, clipIndex, std::move (done));
+}
+
 a2m::ConvertOptions& lastConvertOptions()
 {
     static a2m::ConvertOptions options; // (message thread)

+ 6 - 0
src/ui/AudioToMidi.h

@@ -4,6 +4,7 @@
 #include <vector>
 
 #include "core/AudioToMidi.h"
+#include "core/ChordLaneOps.h"
 #include "engine/AudioEngine.h"
 
 namespace lynx
@@ -41,6 +42,11 @@ std::unique_ptr<juce::Component> makeConvertOptionsForSnapshot (AudioEngine& eng
 // The settings the dialog showed last (this run of LYNX; the channel is not kept between conversions).
 a2m::ConvertOptions& lastConvertOptions();
 
+// Round 190pf (research190oe P13, the Chord lane): the notes an audio clip plays (Basic Pitch, polyphonic; the same worker,
+// progress window and Cancel as Convert to MIDI) in song ticks where the clip plays them, for the lane's chord detection.
+// `done` gets them with the clip's span [from, to) on the message thread; nothing when cancelled or nothing was found.
+void detectClipNotes (AudioEngine& engine, int clipIndex, std::function<void (std::vector<chordlane::TimedNote>, std::int64_t, std::int64_t)> done);
+
 // App shutdown: a conversion still running stops at its next check and is waited for (before the engine goes).
 void shutdownAudioToMidi();
 

+ 656 - 0
src/ui/ChordLane190pf.h

@@ -0,0 +1,656 @@
+#pragma once
+
+// Round 190pf (research190oe P13): the Chord lane ---------------------------------------------------------------------
+// A child of the Playlist under the ruler (and under the Sections lane when it shows; PlaylistComponent::chordLaneHeight):
+// the song's chords (core/ChordLane.h) as named blocks over the time line, Cubase's / Logic's / Studio Pro's chord track
+// done LYNX's way. A LYNX extra in every layout, off by default (Playlist menu › View › "Chord lane", Settings › LYNX
+// extras; the Simple ruler's menu has it too). Looks:
+//  - Pattern (18 px): FL's marker-tag style as the Sections lane's Pattern look, in a steel blue (sections are orange);
+//  - Clip-launch (18 px): flat Live-grey blocks with the name;
+//  - Simple (30 px): rounded blocks, the name centred.
+// Mouse: double-click an empty place (or right-click › Add a chord here) picks a chord for the bar there; drag a block to
+// move it (on the snap), its right edge to resize it; double-click or right-click a block to change it (the key's degree
+// chords first — round 190nu's Scale degree chord — then any root and shape, and a bass); Delete removes it. The lane's
+// menu detects chords from the clips under the time selection (or the selected clips; a selected audio clip through the
+// polyphonic converter), makes them from the key regions, exports them as MIDI, gives them to the Chord pad and sets which
+// channels follow them. Header only: included by PlaylistComponent.cpp (its side in ChordLane190pf.inc) and the shot route.
+
+#include <algorithm>
+#include <cstdint>
+#include <string>
+#include <vector>
+
+#include <juce_gui_basics/juce_gui_basics.h>
+
+#include "core/ChordLane.h"
+#include "core/ChordLaneOps.h"
+#include "core/NoteNames.h"
+#include "core/ScaleKeys.h"
+#include "engine/AudioEngine.h"
+#include "ui/AudioToMidi.h"
+#include "ui/FlMods.h"
+#include "ui/I18n.h"
+#include "ui/PlaylistComponent.h"
+#include "ui/SimpleLook.h"
+#include "ui/TextCache.h"
+#include "ui/Theme.h"
+#include "ui/WorkflowExtras.h"
+
+namespace lynx
+{
+// The lane's name of a chord in the spelling the app shows (flats when the note names use flats)
+inline juce::String chordLaneName (const SongChord& c)
+{
+    return juce::String::fromUTF8 (chordlane::name (c, notenames::currentFlats.load()).c_str());
+}
+
+// The chord picker (a block's menu and a new block's): the degree chords of the key in force there (triads, then a
+// submenu of sevenths), any root with any shape, and the bass. `pick` gets the harmony (start / length unused).
+inline void addChordPicker (juce::PopupMenu& menu, const Song& song, std::int64_t tick, const SongChord* current, std::function<void (SongChord)> pick)
+{
+    const auto flats = notenames::currentFlats.load();
+    const auto same = [current] (const SongChord& c) {
+        return current != nullptr && current->root == c.root && current->quality == c.quality && current->extensions == c.extensions;
+    };
+    const auto key = chordlane::keyAt (song, tick).value_or (projectkey::Key { 0, keyregions::majorScale() });
+    menu.addSectionHeader (tr ("Chords of {0}", { juce::String (projectkey::rootName (key.root)) + " " + tr (notetools::flReferenceScales()[(std::size_t) std::max (0, key.flScale)].name) }));
+    for (const auto& d : chordlane::degreeChords (key))
+        menu.addItem (juce::String::fromUTF8 (d.numeral.c_str()) + "\t" + chordLaneName (d.chord), true, same (d.chord), [pick, c = d.chord] { pick (c); });
+    juce::PopupMenu sevenths;
+    for (const auto& d : chordlane::degreeChords (key, keyregions::DegreeSize::seventh))
+        sevenths.addItem (juce::String::fromUTF8 (d.numeral.c_str()) + "\t" + chordLaneName (d.chord), true, same (d.chord), [pick, c = d.chord] { pick (c); });
+    menu.addSubMenu (tr ("Sevenths"), sevenths);
+    menu.addSeparator();
+    juce::PopupMenu roots;
+    for (int r = 0; r < 12; ++r)
+    {
+        juce::PopupMenu shapes;
+        for (int s = 0; s < chordlane::shapeCount; ++s)
+        {
+            const auto c = chordlane::make (r, s);
+            shapes.addItem (chordLaneName (c), true, same (c), [pick, c, current] {
+                auto x = c;
+                if (current != nullptr && current->root == x.root)
+                    x.bass = current->bass; // (a new shape on the same root keeps its bass)
+                pick (x);
+            });
+        }
+        roots.addSubMenu (chordlane::rootName (r, flats), shapes, true, nullptr, current != nullptr && current->root == r);
+    }
+    menu.addSubMenu (tr ("Other chord"), roots);
+    if (current != nullptr)
+    {
+        juce::PopupMenu bass;
+        bass.addItem (tr ("The root"), true, current->bass < 0, [pick, c = *current] {
+            auto x = c;
+            x.bass = -1;
+            pick (x);
+        });
+        for (int r = 0; r < 12; ++r)
+            if (r != current->root)
+                bass.addItem (juce::String ("/") + chordlane::rootName (r, flats), true, current->bass == r, [pick, c = *current, r] {
+                    auto x = c;
+                    x.bass = r;
+                    pick (x);
+                });
+        menu.addSubMenu (tr ("Bass note"), bass);
+    }
+}
+
+class ChordLaneView final : public juce::Component,
+                            public ui::HintSource
+{
+public:
+    ChordLaneView (AudioEngine& e, PlaylistComponent& p) : engine (e), playlist (p)
+    {
+        setWantsKeyboardFocus (true);
+        setMouseClickGrabsKeyboardFocus (true);
+        setComponentID ("playlist.chordLane");
+        setOpaque (true);
+    }
+
+    enum class Look { fl, live, simple };
+    Look look() const noexcept { return playlist.simpleHeaders ? Look::simple : playlist.liveStyle ? Look::live : Look::fl; }
+    int selected() const noexcept { return chordlane::indexOfUid (engine.getSong().chords(), selectedUid); }
+    void select (int index)
+    {
+        const auto& list = engine.getSong().chords();
+        selectedUid = index >= 0 && index < (int) list.size() ? list[(std::size_t) index].uid : 0;
+        repaint();
+    }
+
+    // --- geometry ------------------------------------------------------------------------------------------------------
+    juce::Rectangle<float> blockOf (const SongChord& c) const
+    {
+        const auto x0 = (float) playlist.tickToX ((double) c.start), x1 = (float) playlist.tickToX ((double) c.end());
+        return look() == Look::simple ? juce::Rectangle<float> (x0 + 1.0f, 3.0f, juce::jmax (2.0f, x1 - x0 - 2.0f), (float) getHeight() - 6.0f)
+                                      : juce::Rectangle<float> (x0, 1.0f, juce::jmax (1.0f, x1 - x0), (float) getHeight() - 2.0f);
+    }
+
+    struct Hit
+    {
+        int chord = -1;
+        enum Part { none, body, edge, header, lane } part = none;
+    };
+    Hit hitAt (juce::Point<int> p) const
+    {
+        Hit h;
+        if (p.x < playlist.headerWidth)
+        {
+            h.part = Hit::header;
+            return h;
+        }
+        const auto& list = engine.getSong().chords();
+        for (int i = 0; i < (int) list.size(); ++i)
+        {
+            const auto r = blockOf (list[(std::size_t) i]);
+            if (std::abs ((float) p.x - r.getRight()) <= 4.0f && r.getWidth() > 10.0f)
+                return { i, Hit::edge };
+            if ((float) p.x >= r.getX() && (float) p.x < r.getRight())
+                return { i, Hit::body };
+        }
+        h.part = Hit::lane;
+        return h;
+    }
+
+    // --- painting --------------------------------------------------------------------------------------------------------
+    // Kept as a picture while nothing it shows changes (as the Sections lane: the Playlist repaints often); a drag paints
+    // directly.
+    void paint (juce::Graphics& g) override
+    {
+        if (drag != Drag::none)
+        {
+            cacheValid = false;
+            paintLane (g);
+            return;
+        }
+        const auto scale = g.getInternalContext().getPhysicalPixelScaleFactor();
+        CacheKey key { engine.getSong().chords(), selectedUid, hover.chord, (int) hover.part, playlist.scrollTicks, playlist.pixelsPerTick, getWidth(),
+                       getHeight(), playlist.headerWidth, (int) look(), scale, theme::colour::bg1.getARGB(), notenames::currentFlats.load() };
+        if (! cacheValid || ! (key == cacheKey))
+        {
+            cache = juce::Image (juce::Image::RGB, juce::jmax (1, juce::roundToInt ((float) getWidth() * scale)),
+                                 juce::jmax (1, juce::roundToInt ((float) getHeight() * scale)), false);
+            juce::Graphics cg (cache);
+            cg.addTransform (juce::AffineTransform::scale (scale));
+            paintLane (cg);
+            cacheKey = std::move (key);
+            cacheValid = true;
+        }
+        g.drawImage (cache, getLocalBounds().toFloat());
+    }
+
+    static juce::Colour laneColour() noexcept { return juce::Colour (0xff5b8fc9); } // (steel blue: the sections are FL's orange)
+
+    void paintLane (juce::Graphics& g)
+    {
+        using namespace theme;
+        const auto& list = engine.getSong().chords();
+        const auto lk = look();
+        const auto simple = lk == Look::simple;
+        const auto gridRight = getWidth() - PlaylistComponent::scrollBarSize;
+        g.fillAll (simple ? colour::bg1 : colour::bg2);
+        g.setColour (simple ? colour::bg2 : colour::bg3);
+        g.fillRect (0, 0, playlist.headerWidth, getHeight());
+        g.setColour (colour::textSecondary);
+        g.setFont (font (simple ? type::small : type::caption, simple));
+        textcache::drawText (g, tr ("Chords"), simple ? 14 : 6, 0, playlist.headerWidth - 12, getHeight(), juce::Justification::centredLeft);
+        g.setColour (colour::border);
+        g.fillRect (playlist.headerWidth - 1, 0, 1, getHeight());
+        g.fillRect (0, getHeight() - 1, getWidth(), 1);
+        juce::Graphics::ScopedSaveState clip (g);
+        g.reduceClipRegion (playlist.headerWidth, 0, gridRight - playlist.headerWidth, getHeight());
+        const auto sel = selected();
+        for (int i = 0; i < (int) list.size(); ++i)
+        {
+            const auto& c = list[(std::size_t) i];
+            auto r = blockOf (c);
+            if (r.getRight() < (float) playlist.headerWidth || r.getX() > (float) gridRight)
+                continue;
+            if (drag == Drag::move && c.uid == dragUid && moved)
+            {
+                paintBlock (g, c, r, true, false, 0.35f);
+                r = r.withX ((float) playlist.tickToX ((double) dragStart));
+                paintBlock (g, c, r, true, false, 0.8f);
+                continue;
+            }
+            if (drag == Drag::resize && c.uid == dragUid)
+                r = r.withRight (juce::jmax (r.getX() + 2.0f, (float) playlist.tickToX ((double) resizeEnd)));
+            paintBlock (g, c, r, i == sel, hover.chord == i && hover.part != Hit::none, 1.0f);
+        }
+        if (list.empty())
+        {
+            g.setColour (colour::textDisabled);
+            g.setFont (font (simple ? type::small : type::caption, simple));
+            textcache::drawText (g, tr ("Double-click to add a chord, or right-click to detect them"), playlist.headerWidth + 8, 0, 520, getHeight(),
+                                 juce::Justification::centredLeft);
+        }
+    }
+
+    void paintBlock (juce::Graphics& g, const SongChord& c, juce::Rectangle<float> r, bool isSelected, bool hovered, float alpha) const
+    {
+        using namespace theme;
+        const auto name = chordLaneName (c);
+        switch (look())
+        {
+            case Look::simple:
+            {
+                const auto body = (isSelected ? juce::Colour (0xff7aa6d8) : juce::Colour (0xff3f5f86)).withMultipliedBrightness (hovered && ! isSelected ? 1.15f : 1.0f);
+                g.setColour (body.withMultipliedAlpha (alpha));
+                g.fillRoundedRectangle (r, 5.0f);
+                g.setColour (ui::simplelook::inkOn (body).withMultipliedAlpha (alpha));
+                g.setFont (font (type::body, true));
+                textcache::drawText (g, name, r.reduced (6.0f, 0.0f), juce::Justification::centred, true);
+                return;
+            }
+            case Look::live:
+            {
+                const auto body = isSelected ? juce::Colour (0xffb4c8dc) : juce::Colour (hovered ? 0xff6e7a86 : 0xff5d6874);
+                g.setColour (body.withMultipliedAlpha (alpha));
+                g.fillRect (r);
+                g.setColour (colour::bg0.withMultipliedAlpha (alpha));
+                g.fillRect (juce::Rectangle<float> (r.getX(), r.getY(), 1.0f, r.getHeight()));
+                g.setColour ((isSelected ? juce::Colour (0xff101214) : colour::textPrimary).withMultipliedAlpha (alpha));
+                g.setFont (font (type::caption, false));
+                textcache::drawText (g, name, r.reduced (4.0f, 0.0f), juce::Justification::centredLeft, true);
+                return;
+            }
+            case Look::fl:
+            default:
+            {
+                // the Playlist's marker tag in the lane's colour over its span, tinted (the Sections lane's Pattern look)
+                const auto fill = laneColour();
+                g.setColour (fill.withAlpha ((isSelected ? 0.34f : hovered ? 0.26f : 0.16f) * alpha));
+                g.fillRect (r);
+                g.setColour (fill.withMultipliedAlpha (alpha));
+                g.fillRect (juce::Rectangle<float> (r.getX(), 0.0f, 1.0f, (float) getHeight()));
+                g.setFont (font (type::caption, true));
+                const auto width = juce::jmin (r.getWidth(), (float) juce::GlyphArrangement::getStringWidthInt (g.getCurrentFont(), name) + 8.0f);
+                const auto tag = juce::Rectangle<float> (r.getX(), (float) getHeight() - 13.0f, width, 11.0f);
+                g.fillRoundedRectangle (tag, 2.0f);
+                g.setColour (colour::bg0.withMultipliedAlpha (alpha));
+                textcache::drawText (g, name, tag.reduced (3.0f, 0.0f), juce::Justification::centredLeft, false);
+                if (isSelected)
+                {
+                    g.setColour (colour::textPrimary.withMultipliedAlpha (alpha));
+                    g.drawRect (r, 1.0f);
+                }
+                return;
+            }
+        }
+    }
+
+    // --- mouse -----------------------------------------------------------------------------------------------------------
+    std::int64_t snapped (double tick) const { return std::max<std::int64_t> (0, playlist.snap (std::max (0.0, tick), true)); }
+
+    void mouseDown (const juce::MouseEvent& e) override
+    {
+        const auto h = hitAt (e.getPosition());
+        drag = Drag::none;
+        moved = false;
+        if (flmods::popup (e.mods))
+        {
+            if (h.chord >= 0)
+            {
+                select (h.chord);
+                chordMenu (h.chord).showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
+            }
+            else
+                laneMenu ((std::int64_t) std::max (0.0, playlist.xToTick (e.x)))
+                    .showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
+            return;
+        }
+        if (h.chord < 0)
+        {
+            select (-1);
+            return;
+        }
+        select (h.chord);
+        const auto& c = engine.getSong().chords()[(std::size_t) h.chord];
+        dragUid = c.uid;
+        if (h.part == Hit::edge)
+        {
+            drag = Drag::resize;
+            resizeEnd = c.end();
+        }
+        else
+        {
+            drag = Drag::move;
+            grabTicks = playlist.xToTick (e.x) - (double) c.start;
+            dragStart = c.start;
+        }
+    }
+
+    void mouseDrag (const juce::MouseEvent& e) override
+    {
+        const auto index = chordlane::indexOfUid (engine.getSong().chords(), dragUid);
+        if (index < 0)
+            return;
+        const auto& c = engine.getSong().chords()[(std::size_t) index];
+        if (drag == Drag::resize)
+        {
+            resizeEnd = std::max (snapped (playlist.xToTick (e.x)), c.start + 1);
+            repaint();
+        }
+        else if (drag == Drag::move)
+        {
+            moved = moved || e.getDistanceFromDragStart() > 3;
+            dragStart = snapped (playlist.xToTick (e.x) - grabTicks);
+            repaint();
+        }
+    }
+
+    void mouseUp (const juce::MouseEvent&) override
+    {
+        const auto was = drag;
+        drag = Drag::none;
+        const auto index = chordlane::indexOfUid (engine.getSong().chords(), dragUid);
+        if (was == Drag::resize && index >= 0)
+            engine.editSong ([index, end = resizeEnd] (Song& s) { chordlane::resize (s.chords(), index, end); });
+        else if (was == Drag::move && moved && index >= 0)
+        {
+            std::uint64_t uid = 0;
+            engine.editSong ([index, at = dragStart, &uid] (Song& s) {
+                const auto i = chordlane::move (s.chords(), index, at);
+                uid = i >= 0 ? s.chords()[(std::size_t) i].uid : 0;
+            });
+            selectedUid = uid;
+        }
+        moved = false;
+        repaint();
+    }
+
+    void mouseDoubleClick (const juce::MouseEvent& e) override
+    {
+        const auto h = hitAt (e.getPosition());
+        if (h.chord >= 0)
+            chordMenu (h.chord).showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
+        else if (h.part == Hit::lane)
+            addMenu ((std::int64_t) std::max (0.0, playlist.xToTick (e.x))).showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
+    }
+
+    void mouseMove (const juce::MouseEvent& e) override
+    {
+        const auto h = hitAt (e.getPosition());
+        if (h.chord != hover.chord || h.part != hover.part)
+        {
+            hover = h;
+            setMouseCursor (h.part == Hit::edge ? juce::MouseCursor::LeftRightResizeCursor : juce::MouseCursor::NormalCursor);
+            repaint();
+        }
+    }
+    void mouseExit (const juce::MouseEvent&) override
+    {
+        hover = {};
+        repaint();
+    }
+    void mouseWheelMove (const juce::MouseEvent& e, const juce::MouseWheelDetails& wheel) override
+    {
+        playlist.mouseWheelMove (e.getEventRelativeTo (&playlist), wheel);
+    }
+
+    bool keyPressed (const juce::KeyPress& key) override
+    {
+        const auto index = selected();
+        if (index < 0)
+            return false;
+        if (key == juce::KeyPress::deleteKey || key == juce::KeyPress::backspaceKey)
+        {
+            engine.editSong ([index] (Song& s) { chordlane::remove (s.chords(), index); });
+            select (-1);
+            return true;
+        }
+        return false;
+    }
+
+    // --- commands --------------------------------------------------------------------------------------------------------
+    // A new block at `tick`: from the bar line there to the next bar (or to the next chord when it starts sooner)
+    void addChordAt (std::int64_t tick, SongChord harmony)
+    {
+        const auto& song = engine.getSong();
+        const auto bar = song.barAt (tick);
+        auto c = harmony;
+        c.start = bar.tick;
+        c.length = std::max<std::int64_t> (1, bar.length);
+        const auto& list = song.chords();
+        if (const auto inside = chordlane::indexAt (list, c.start); inside >= 0 && list[(std::size_t) inside].start < c.start)
+            c.start = std::max (c.start, list[(std::size_t) inside].start); // (cuts the one it lands in)
+        for (const auto& other : list)
+            if (other.start > c.start && other.start < c.end())
+                c.length = other.start - c.start;
+        std::uint64_t uid = 0;
+        engine.editSong ([c, &uid] (Song& s) {
+            const auto i = chordlane::put (s.chords(), c);
+            uid = i >= 0 ? s.chords()[(std::size_t) i].uid : 0;
+        });
+        selectedUid = uid;
+        repaint();
+    }
+
+    juce::PopupMenu addMenu (std::int64_t tick)
+    {
+        juce::PopupMenu menu;
+        addChordPicker (menu, engine.getSong(), tick, nullptr, [this, tick] (SongChord c) { addChordAt (tick, c); });
+        return menu;
+    }
+
+    juce::PopupMenu chordMenu (int index)
+    {
+        juce::PopupMenu menu;
+        const auto& list = engine.getSong().chords();
+        if (index < 0 || index >= (int) list.size())
+            return menu;
+        const auto c = list[(std::size_t) index];
+        const auto uid = c.uid;
+        menu.addSectionHeader (chordLaneName (c));
+        addChordPicker (menu, engine.getSong(), c.start, &c, [this, uid] (SongChord pick) {
+            engine.editSong ([uid, pick] (Song& s) { chordlane::setChord (s.chords(), chordlane::indexOfUid (s.chords(), uid), pick); });
+            repaint();
+        });
+        menu.addSeparator();
+        menu.addItem (tr ("Duplicate"), [this, uid] {
+            engine.editSong ([uid] (Song& s) {
+                const auto i = chordlane::indexOfUid (s.chords(), uid);
+                if (i < 0)
+                    return;
+                auto copy = s.chords()[(std::size_t) i];
+                copy.start = copy.end();
+                chordlane::put (s.chords(), copy);
+            });
+            repaint();
+        });
+        menu.addItem (tr ("Delete") + "\tDel", [this, uid] {
+            engine.editSong ([uid] (Song& s) { chordlane::remove (s.chords(), chordlane::indexOfUid (s.chords(), uid)); });
+            select (-1);
+        });
+        menu.addSeparator();
+        menu.addItem (tr ("Loop this chord"), [this, from = c.start, to = c.end()] {
+            engine.editSong ([from, to] (Song& song) {
+                song.loopStart = from;
+                song.loopEnd = to;
+            }, false);
+            playlist.repaint();
+        });
+        return menu;
+    }
+
+    // The range the lane's commands work on: the time selection, else the song (to the end of its last clip)
+    std::pair<std::int64_t, std::int64_t> workRange() const
+    {
+        const auto& song = engine.getSong();
+        if (song.loopEnd > song.loopStart)
+            return { song.loopStart, song.loopEnd };
+        std::int64_t end = 0;
+        for (const auto& c : song.playlist)
+            if (c.gridSlot < 0 && c.kind != ClipKind::automation)
+                end = std::max (end, c.end());
+        return { 0, end };
+    }
+
+    // the selected Playlist clips of a kind
+    std::vector<int> selectedOf (ClipKind kind) const
+    {
+        std::vector<int> out;
+        const auto& song = engine.getSong();
+        for (const auto i : playlist.selection)
+            if (i >= 0 && i < (int) song.playlist.size() && song.playlist[(std::size_t) i].kind == kind)
+                out.push_back (i);
+        return out;
+    }
+
+    void detectFromNotes (chordlane::Resolution resolution)
+    {
+        auto [from, to] = workRange();
+        const auto clips = selectedOf (ClipKind::pattern);
+        const auto& song = engine.getSong();
+        if (! clips.empty() && song.loopEnd <= song.loopStart)
+        {
+            // the selected clips' span
+            from = std::numeric_limits<std::int64_t>::max();
+            to = 0;
+            for (const auto i : clips)
+            {
+                from = std::min (from, song.playlist[(std::size_t) i].start);
+                to = std::max (to, song.playlist[(std::size_t) i].end());
+            }
+        }
+        const auto found = chordlane::detect (song, chordlane::songNotes (song, from, to, clips), from, to, resolution);
+        if (found.empty())
+        {
+            juce::AlertWindow::showMessageBoxAsync (juce::MessageBoxIconType::InfoIcon, tr ("Chord lane"), tr ("No chords were found in the notes there."));
+            return;
+        }
+        engine.editSong ([from = from, to = to, found] (Song& s) { chordlane::write (s, from, to, found); });
+        repaint();
+    }
+
+    void detectFromAudio (int clipIndex)
+    {
+        juce::Component::SafePointer<ChordLaneView> self (this);
+        detectClipNotes (engine, clipIndex, [self] (std::vector<chordlane::TimedNote> notes, std::int64_t from, std::int64_t to) {
+            if (self == nullptr)
+                return;
+            const auto found = chordlane::detect (self->engine.getSong(), notes, from, to, chordlane::Resolution::halfBar);
+            if (found.empty())
+            {
+                juce::AlertWindow::showMessageBoxAsync (juce::MessageBoxIconType::InfoIcon, tr ("Chord lane"), tr ("No chords were found in this audio."));
+                return;
+            }
+            self->engine.editSong ([from, to, found] (Song& s) { chordlane::write (s, from, to, found); });
+            self->repaint();
+        });
+    }
+
+    juce::PopupMenu laneMenu (std::int64_t tick)
+    {
+        juce::PopupMenu menu;
+        const auto& song = engine.getSong();
+        juce::PopupMenu add;
+        addChordPicker (add, song, tick, nullptr, [this, tick] (SongChord c) { addChordAt (tick, c); });
+        menu.addSubMenu (tr ("Add a chord here"), add);
+        menu.addSeparator();
+        juce::PopupMenu detect;
+        detect.addItem (tr ("A chord per bar"), [this] { detectFromNotes (chordlane::Resolution::bar); });
+        detect.addItem (tr ("A chord per half bar"), [this] { detectFromNotes (chordlane::Resolution::halfBar); });
+        detect.addItem (tr ("A chord per beat"), [this] { detectFromNotes (chordlane::Resolution::beat); });
+        menu.addSubMenu (tr ("Detect chords from the notes"), detect);
+        const auto audio = selectedOf (ClipKind::audio);
+        menu.addItem (tr ("Detect chords from the selected audio clip"), audio.size() == 1, false, [this, clip = audio.empty() ? -1 : audio.front()] { detectFromAudio (clip); });
+        menu.addItem (tr ("Chords from the key regions"), [this] {
+            const auto [from, to] = workRange();
+            const auto found = chordlane::fromKeyRegions (engine.getSong(), from, std::max (to, from + engine.getSong().barAt (from).length));
+            if (! found.empty())
+                engine.editSong ([from = found.front().start, to = found.back().end(), found] (Song& s) { chordlane::write (s, from, to, found); });
+            repaint();
+        });
+        menu.addSeparator();
+        const auto any = ! song.chords().empty();
+        menu.addItem (tr ("Export chords as MIDI"), any, false, [this] {
+            const auto channel = engine.getSelectedChannel();
+            const auto& s = engine.getSong();
+            const auto usable = channel >= 0 && channel < (int) s.channels.size() && chordlane::harmonic (s.channels[(std::size_t) channel])
+                                && a2m::canPlayNotes (s.channels[(std::size_t) channel]);
+            engine.editSong ([c = usable ? channel : -1, p = tr ("Chords").toStdString()] (Song& song) { chordlane::exportAsPattern (song, c, p, p); });
+            playlist.sortClips();
+            playlist.repaint();
+        });
+        menu.addItem (tr ("Use these chords on the Chord pad"), any, false, [this] {
+            engine.editSong ([] (Song& s) { s.keyboardChords = chordlane::padSet (s.chords()); });
+            scalekeys::current().projectChords = true;
+            scalekeys::current().mode = scalekeys::Mode::chordPad;
+        });
+        // the channels that follow the chords (Cubase's Follow Chord Track): Off / Chord tones / Bass, per instrument channel
+        {
+            juce::PopupMenu follow;
+            int shown = 0;
+            for (int c = 0; c < (int) song.channels.size() && shown < 64; ++c)
+            {
+                const auto& ch = song.channels[(std::size_t) c];
+                if (! a2m::canPlayNotes (ch) || (! chordlane::harmonic (ch) && ch.followChords == 0))
+                    continue;
+                ++shown;
+                juce::PopupMenu modes;
+                const std::pair<const char*, int> items[] = { { TR_NOOP ("Off"), 0 }, { TR_NOOP ("Chord tones"), 1 }, { TR_NOOP ("Bass note"), 2 } };
+                for (const auto& [text, mode] : items)
+                    modes.addItem (tr (text), true, ch.followChords == mode, [this, c, m = mode] {
+                        engine.editSong ([c, m] (Song& s) { s.channels[(std::size_t) c].followChords = (std::uint8_t) m; });
+                    });
+                follow.addSubMenu (juce::String (c + 1) + "  " + juce::String::fromUTF8 (ch.name.c_str()), modes, true, nullptr, ch.followChords != 0);
+            }
+            menu.addSubMenu (tr ("Channels that follow the chords"), follow, shown > 0);
+        }
+        menu.addSeparator();
+        menu.addItem (tr ("Clear the chords in the time selection"), any, false, [this] {
+            const auto [from, to] = workRange();
+            engine.editSong ([from, to] (Song& s) { chordlane::clearRange (s.chords(), from, std::max (to, from + 1)); });
+            select (-1);
+        });
+        menu.addItem (tr ("Chord lane") + " (LYNX)", true, true, [] { workflowextras::setExtra ("playlist.chordLane", false); });
+        return menu;
+    }
+
+    ui::Hint hintAt (juce::Point<int> p) override
+    {
+        const auto h = hitAt (p);
+        const auto& list = engine.getSong().chords();
+        if (h.part == Hit::header)
+            return { tr ("Chords: the harmony of the song. Channels can follow them; the Piano roll can light them"), {}, false, true };
+        if (h.chord >= 0 && h.chord < (int) list.size())
+        {
+            const auto& c = list[(std::size_t) h.chord];
+            if (h.part == Hit::edge)
+                return { tr ("Drag to resize the chord"), chordLaneName (c) };
+            return { tr ("[LMB] drag to move  [2xLMB] change the chord  [Del] delete  [RMB] menu"), chordLaneName (c), false, true };
+        }
+        return { tr ("[2xLMB] add a chord  [RMB] menu: detect chords, follow, export"), {}, false, true };
+    }
+
+private:
+    struct CacheKey
+    {
+        std::vector<SongChord> chords;
+        std::uint64_t selected = 0;
+        int hoverChord = -1, hoverPart = 0;
+        double scrollTicks = 0.0, pixelsPerTick = 0.0;
+        int width = 0, height = 0, headerWidth = 0, look = 0;
+        float scale = 1.0f;
+        juce::uint32 ground = 0;
+        bool flats = false;
+        bool operator== (const CacheKey&) const = default;
+    };
+    AudioEngine& engine;
+    PlaylistComponent& playlist;
+    CacheKey cacheKey;
+    juce::Image cache;
+    bool cacheValid = false;
+    enum class Drag { none, move, resize };
+    Drag drag = Drag::none;
+    std::uint64_t dragUid = 0, selectedUid = 0;
+    double grabTicks = 0.0;
+    std::int64_t dragStart = 0, resizeEnd = 0;
+    bool moved = false;
+    Hit hover;
+
+    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ChordLaneView)
+};
+} // namespace lynx

+ 48 - 0
src/ui/ChordLane190pf.inc

@@ -0,0 +1,48 @@
+// Round 190pf (research190oe P13): the Playlist's side of the Chord lane (ui/ChordLane190pf.h). Included in
+// PlaylistComponent.cpp (namespace lynx).
+
+bool PlaylistComponent::chordLaneShown() const
+{
+    return chordlane::laneOn(); // (a LYNX extra in every layout, off by default)
+}
+
+int PlaylistComponent::chordLaneHeight() const
+{
+    return chordLaneShown() ? (simpleHeaders ? chordLaneSimpleHeight : chordLaneFlHeight) : 0;
+}
+
+void PlaylistComponent::chordLaneChanged()
+{
+    if (chordLane == nullptr || videoLanes == nullptr || blocksView == nullptr)
+        return; // (not built yet)
+    if (chordLaneHeight() != laidOutChordHeight)
+        resized();
+    chordLane->repaint();
+    repaint();
+}
+
+// Round 190pf (research190oe P12): Smart Tempo — the preview window, then (on Follow) the tempo markers and the unwarped
+// clip in one undo step
+void PlaylistComponent::followClipTempo (int clip)
+{
+    if (smarttempo::blockedBy (engine.getSong()))
+    {
+        juce::AlertWindow::showMessageBoxAsync (juce::MessageBoxIconType::InfoIcon, tr ("Make the project tempo follow this clip"),
+                                                tr ("Something else moves the project's tempo (a tempo automation clip or pattern tempo events): remove it first."));
+        return;
+    }
+    double rate = 44100.0;
+    auto mono = smartTempoAudio (engine, clip, rate);
+    if (mono.empty())
+        return;
+    auto* box = new SmartTempoWindow (engine, clip, std::move (mono), rate, this);
+    juce::Component::SafePointer<PlaylistComponent> self (this);
+    box->enterModalState (true, juce::ModalCallbackFunction::create ([box, self] (int result) {
+                              if (result == 1 && box->apply() && self != nullptr)
+                              {
+                                  self->sortClips();
+                                  self->repaint();
+                              }
+                          }),
+                          true);
+}

+ 4 - 0
src/ui/MainComponent.cpp

@@ -4,6 +4,7 @@
 #include "ui/TrackIcons.h"
 #include "ui/WindowPlaces.h" // (round 190oa, DF-130)
 #include "core/Sections.h"
+#include "core/ChordLane.h"
 #include "core/EscClose.h"
 #include "core/DetailChain.h"
 #include "core/MeterScale.h"
@@ -5486,6 +5487,9 @@ void MainComponent::addPanelMenuItems (Panel panel, juce::PopupMenu& menu)
                 view.addSeparator();
                 view.addItem (tr ("Sections lane") + " (LYNX)", layoutStyle == layoutstyle::Style::pattern, sections::patternLaneOn(),
                               [] { workflowextras::setExtra ("playlist.sectionsLane", ! sections::patternLaneOn()); });
+                // round 190pf (research190oe P13): LYNX's Chord lane, off by default, in every layout
+                view.addItem (tr ("Chord lane") + " (LYNX)", true, chordlane::laneOn(),
+                              [] { workflowextras::setExtra ("playlist.chordLane", ! chordlane::laneOn()); });
                 // round 190oo (design review O-1, a LYNX extra): shade the faded part as the Clip-launch layout does
                 view.addItem (tr ("Shade faded audio (LYNX)"), true, PlaylistComponent::shadeFadedAudio, [this] {
                     PlaylistComponent::shadeFadedAudio = ! PlaylistComponent::shadeFadedAudio;

+ 30 - 1
src/ui/PianoRollComponent.cpp

@@ -1,4 +1,5 @@
 #include "ui/ShotShowing.h"
+#include "ui/WorkflowExtras.h" // round 190pf (the chord highlight switch)
 #include "ui/FlMods.h"
 #include "ui/Motion.h"
 #include "ui/FileChoosers.h"
@@ -1726,7 +1727,10 @@ void PianoRollComponent::paint (juce::Graphics& g)
             keyregions::Degrees degrees;
         };
         std::vector<RegionRows> regionRows;
-        if (gridHighlights && ! liveLookNotes && keyregions::hasKeyMarkers (pattern))
+        // round 190pf (P13): the Chord lane's chord at the song position lights its notes' rows (the scale's shade, the
+        // rows out of the chord the black-key shade); it wins over the scale and the key regions while it shows
+        const auto chordRows = gridHighlights && ! liveLookNotes && shownChord.root >= 0;
+        if (gridHighlights && ! liveLookNotes && ! chordRows && keyregions::hasKeyMarkers (pattern))
         {
             const auto rightTick = (std::int64_t) xToTick (grid.getRight()) + 1;
             for (const auto& span : keyregions::spans (pattern, std::max<std::int64_t> (rightTick, 1)))
@@ -1756,6 +1760,8 @@ void PianoRollComponent::paint (juce::Graphics& g)
                 // take the black-key shade, the rows in it the white-key one, black keys or not; rollup step 6: 190jo's
                 // black-key shade `prRowBlack`, as step 5 did for Automatic)
                 row = inScale (key) ? prRowIn : prRowBlack;
+            if (chordRows)
+                row = (shownChord.mask & (1 << (key % 12))) != 0 ? prRowIn : prRowBlack;
             if (liveLookNotes) // (round 190jn: Live's note editor, one grey with a darker line under each row)
                 row = juce::Colour (0xff464f53);
             if (bandRows.test ((std::size_t) key))
@@ -6508,6 +6514,24 @@ void PianoRollComponent::timerCallback()
         refreshChannelBox();
     updateChordReadout();
 
+    // round 190pf (P13): the rows follow the Chord lane's chord at the song position (a check of two ints per tick)
+    if (chordlane::pianoRollHighlight())
+    {
+        const auto& song = engine.getSong();
+        const auto now = song.chords().empty() ? chordlane::Highlight {}
+                                               : chordlane::highlightAt (song, (std::int64_t) engine.getTransport().positionTicks.load());
+        if (now != shownChord)
+        {
+            shownChord = now;
+            repaint();
+        }
+    }
+    else if (shownChord.root >= 0)
+    {
+        shownChord = {};
+        repaint();
+    }
+
     // the keys the channel plays light up on the keyboard (song, pattern, typing keyboard, MIDI)
     if (const auto lit = isShowing() ? soundingNow() : NoteMask {}; lit != litKeys)
     {
@@ -7059,6 +7083,11 @@ juce::PopupMenu PianoRollComponent::viewMenu()
     menu.addItem (tr ("Background waveform") + keyText ("pianoRoll.backgroundWave"), true, isBackgroundWaveShown(),
                   [this] { runAction ("pianoRoll.backgroundWave"); });
     menu.addItem (tr ("Ruler: song bars (LYNX)") + keyText ("pianoRoll.songBarsRuler"), true, songBarsRuler, [this] { runAction ("pianoRoll.songBarsRuler"); });
+    // round 190pf (research190oe P13): the rows light the Chord lane's chord at the song position
+    menu.addItem (tr ("Highlight the Chord lane's chord (LYNX)"), true, chordlane::pianoRollHighlight(), [this] {
+        workflowextras::setExtra ("pianoRoll.chordHighlight", ! chordlane::pianoRollHighlight());
+        repaint();
+    });
     if (layoutstyle::current() != layoutstyle::Style::clipLaunch) // (round 190on: the Clip-launch layout always offers them)
         menu.addItem (tr ("Stacked controller lanes (LYNX)") + keyText ("pianoRoll.stackedLanes"), true, stackedLanesExtra,
                       [this] { runAction ("pianoRoll.stackedLanes"); });

+ 8 - 0
src/ui/PianoRollComponent.h

@@ -1,5 +1,6 @@
 #pragma once
 
+#include "core/ChordLane.h"
 #include <juce_gui_basics/juce_gui_basics.h>
 
 #include "core/EventPaneSplit.h"
@@ -854,6 +855,13 @@ private:
     int previewKey = -1;
     int lastScaleDragKeys = 0; // (a snap-to-scale drag: the scale steps last applied)
     NoteMask litKeys {}; // keys sounding on the channel(s) shown: lit on the keyboard (issue #14, FL)
+    // round 190pf (research190oe P13): the Chord lane's chord at the song position, while "Highlight the Chord lane's
+    // chord" is on (the timer compares it; the grid repaints only when it changes)
+    chordlane::Highlight shownChord {};
+public:
+    chordlane::Highlight chordHighlightForShot() const noexcept { return shownChord; }
+    void setChordHighlightForShot (chordlane::Highlight h) { shownChord = h; repaint(); }
+private:
     NoteMask soundingNow() const;
     bool isLit (int key) const noexcept { return key >= 0 && key < 128 && ((litKeys[(std::size_t) (key >> 6)] >> (key & 63)) & 1u) != 0; }
     double playheadTick = -1.0;

+ 33 - 5
src/ui/PlaylistComponent.cpp

@@ -111,6 +111,8 @@
 #include "core/SectionOps.h"    // round 190ol (the Sections lane)
 #include "core/SignatureEdit.h" // round 190ol (P6: Simple time signature changes)
 #include "ui/SectionsLane190ol.h" // round 190ol (P1: the Sections lane)
+#include "ui/ChordLane190pf.h"   // round 190pf (P13: the Chord lane)
+#include "ui/SmartTempo190pf.h"  // round 190pf (P12: Smart Tempo)
 #include "core/LoopAnalysis.h" // round 190kx
 #include "core/TrackClips.h" // round 190ne
 #include "ui/LoopInfo.h"
@@ -561,6 +563,7 @@ void paintClipOutline (juce::Graphics& g, juce::Rectangle<float> r, juce::Colour
 } // namespace
 
 #include "SectionsLane190ol.inc" // round 190ol (research190oe P1): the Sections lane
+#include "ChordLane190pf.inc"   // round 190pf (research190oe P13): the Chord lane
 
 // Zoomed far out, a song of chopped audio shows a thousand clips a few pixels wide. Painted one by one, each is a
 // handful of rounded paths (frame, header, waveform, outline), and the GPU renderer pays per path: Thief's Playlist
@@ -1233,6 +1236,8 @@ PlaylistComponent::PlaylistComponent (AudioEngine& e)
     addChildComponent (*videoLanes);
     sectionsLane = std::make_unique<SectionsLaneView> (engine, *this); // round 190ol
     addChildComponent (*sectionsLane);
+    chordLane = std::make_unique<ChordLaneView> (engine, *this); // round 190pf
+    addChildComponent (*chordLane);
 
     grid::fillEditorBox (snapBox);
     snapBox.setTooltip (tr ("Playlist snap (magnet): \"Main\" follows the snap in the toolbar, or pick this window's own; hold Alt while dragging to ignore it"));
@@ -1468,7 +1473,7 @@ int PlaylistComponent::videoSectionHeight() const
     if (natural <= 0)
         return 0;
     // (the clip tracks keep two rows; with the Pattern Blocks section too, the video lanes take at most half)
-    const auto available = getHeight() - headerHeight - sectionsLaneHeight();
+    const auto available = getHeight() - headerHeight - sectionsLaneHeight() - chordLaneHeight();
     const auto least = VideoLanesView::dividerHeight + 20;
     const auto most = juce::jmax (least, engine.getSong().patternBlocksOn ? available / 2 : available - 2 * baseRowHeight());
     return juce::jlimit (least, most, videoHeight > 0 ? videoHeight : natural);
@@ -1946,7 +1951,11 @@ void PlaylistComponent::resized()
     laidOutSectionsHeight = lane;
     sectionsLane->setBounds (0, headerHeight, getWidth(), lane);
     sectionsLane->setVisible (lane > 0);
-    videoLanes->setBounds (0, headerHeight + lane, getWidth(), video);
+    const auto chords = chordLaneHeight(); // round 190pf: the Chord lane, under the Sections lane
+    laidOutChordHeight = chords;
+    chordLane->setBounds (0, headerHeight + lane, getWidth(), chords);
+    chordLane->setVisible (chords > 0);
+    videoLanes->setBounds (0, headerHeight + lane + chords, getWidth(), video);
     videoLanes->setVisible (video > 0);
     updateScrollBars();
 
@@ -8418,7 +8427,8 @@ void PlaylistComponent::insertTimeSelection()
 
     setSelection ({});
     engine.editSong ([from = song.loopStart, to = song.loopEnd] (Song& s) { noteedit::insertTime (s.playlist, s.markers(), from, to - from);
-                                                                      sections::insertTime (s.sections(), from, to - from); }); // (round 190ol)
+                                                                      sections::insertTime (s.sections(), from, to - from);
+                                                                      chordlane::insertTime (s.chords(), from, to - from); }); // (round 190ol, 190pf)
     sortClips();
 }
 
@@ -8431,7 +8441,8 @@ void PlaylistComponent::deleteTimeSelection()
 
     setSelection ({});
     engine.editSong ([from = song.loopStart, to = song.loopEnd] (Song& s) { noteedit::deleteTime (s.playlist, s.markers(), from, to);
-                                                                      sections::deleteTime (s.sections(), from, to); }); // (round 190ol)
+                                                                      sections::deleteTime (s.sections(), from, to);
+                                                                      chordlane::deleteTime (s.chords(), from, to); }); // (round 190ol, 190pf)
     sortClips();
 }
 
@@ -8445,6 +8456,7 @@ void PlaylistComponent::setLiveStyle (bool on)
     refreshTrackLayout(); // (round 190gw: the Clip-launch layout keeps LYNX's 38 px default row; round 190jn: Live's 19 px in its look)
     updateHeaderWidth();  // (round 190jn: Live's header row is wider)
     sectionsLaneChanged(); // (round 190ol: no Sections lane in the Clip-launch layout)
+    chordLaneChanged();    // (round 190pf: the Chord lane's look follows the layout)
     updateScrollBars();
     repaint();
 }
@@ -8809,7 +8821,8 @@ void PlaylistComponent::sliceInsertTimeSelection()
 
     setSelection ({});
     engine.editSong ([from = song.loopStart, to = song.loopEnd] (Song& s) { noteedit::sliceInsertTime (s.playlist, s.markers(), from, to - from);
-                                                                      sections::insertTime (s.sections(), from, to - from); }); // (round 190ol)
+                                                                      sections::insertTime (s.sections(), from, to - from);
+                                                                      chordlane::insertTime (s.chords(), from, to - from); }); // (round 190ol, 190pf)
     sortClips();
 }
 
@@ -8825,6 +8838,8 @@ void PlaylistComponent::trimTimeSelection()
         noteedit::trimTime (s.playlist, s.markers(), from, to);
         sections::deleteTime (s.sections(), to, std::numeric_limits<std::int64_t>::max() / 4); // (round 190ol)
         sections::deleteTime (s.sections(), 0, from);
+        chordlane::deleteTime (s.chords(), to, std::numeric_limits<std::int64_t>::max() / 4); // (round 190pf)
+        chordlane::deleteTime (s.chords(), 0, from);
         s.loopStart = s.loopEnd = 0; // (FL clears the time selection after a trim, FUN_00eb35f0)
     });
     sortClips();
@@ -9753,6 +9768,7 @@ void PlaylistComponent::setSimpleHeaders (bool on)
     updateHeaderWidth();
     refreshTrackLayout(); // (round 190jq: no automation lanes in Simple)
     sectionsLaneChanged(); // (round 190ol: the lane's look and visibility follow the layout)
+    chordLaneChanged();    // (round 190pf)
 }
 
 void PlaylistComponent::selectTrackChannel (int track)
@@ -10780,6 +10796,8 @@ juce::PopupMenu PlaylistComponent::rulerMenu (int x)
                 engine.editSong ([bar] (Song& s) { signatureedit::remove (s, bar); });
                 repaint();
             });
+        // round 190pf (research190oe P13): the Chord lane (a LYNX extra in every layout; here beside the Simple ruler's own)
+        menu.addItem (tr ("Chord lane"), true, chordlane::laneOn(), [] { workflowextras::setExtra ("playlist.chordLane", ! chordlane::laneOn()); });
         menu.addSeparator();
     }
     menu.addItem (tr ("Add marker here..."), [this, tick] { editMarkerName (tick, -1); });
@@ -12097,6 +12115,12 @@ juce::PopupMenu PlaylistComponent::buildAudioClipMenu (int index, int mouseX)
     // edited one by one; the channel's clips play the edited render (an ARA-edited channel plays its plugin instead)
     menu.addItem (tr ("Edit notes (polyphonic)..."), sample != nullptr && ! channel.ara.active(), false,
                   [this, ch] { PolyEditorWindows::open (engine, ch); });
+    // round 190pf (research190oe P12, P13): Smart Tempo (the project's tempo follows this free recording; Pattern and
+    // Simple) and the Chord lane's chords from this clip's notes (shown with the lane)
+    if (! liveStyle)
+        menu.addItem (tr ("Make the project tempo follow this clip..."), sample != nullptr, false, [this, index] { followClipTempo (index); });
+    if (chordLaneShown() && chordLane != nullptr)
+        menu.addItem (tr ("Detect chords to the Chord lane"), sample != nullptr, false, [this, index] { chordLane->detectFromAudio (index); });
     addLiveTrackItems (engine, menu, index, targets, [safe = juce::Component::SafePointer<PlaylistComponent> (this)] {
         if (safe != nullptr)
         {
@@ -15010,6 +15034,10 @@ void PlaylistComponent::changeListenerCallback (juce::ChangeBroadcaster* source)
         resized();
     else if (sectionsLaneHeight() != laidOutSectionsHeight) // round 190ol: the first section added, the last removed, undo
         resized();
+    else if (chordLaneHeight() != laidOutChordHeight) // round 190pf: the Chord lane switched on / off
+        resized();
+    if (chordLane != nullptr && chordLane->isVisible())
+        chordLane->repaint(); // (its own picture is kept while the chords and the view stay the same)
     blocksView->refresh();
     videoLanes->refresh();
     updateScrollBars();

+ 16 - 1
src/ui/PlaylistComponent.h

@@ -46,6 +46,7 @@ class EffectsPanel;
 class PatternPicker;
 class VideoLanesView;
 class SectionsLaneView;
+class ChordLaneView;
 
 // FL-style Playlist (arrangement): tracks vertically, time horizontally.
 //  - a tool strip (Pencil, Brush, Eraser, Mute, Knife, Lasso, Zoom, Listen, Slip); with the Pencil:
@@ -475,7 +476,7 @@ public:
     // has video tracks. `height` = the section's height (the divider drag; 0 = fit the lanes), clamped to the window.
     void setVideoHeight (int height);
     int videoSectionHeight() const;
-    int tracksTop() const { return headerHeight + sectionsLaneHeight() + videoSectionHeight(); } // the clip tracks' top edge
+    int tracksTop() const { return headerHeight + sectionsLaneHeight() + chordLaneHeight() + videoSectionHeight(); } // the clip tracks' top edge
     // The Sections lane (round 190ol, core/Sections.h; owner decision O-1): a thin lane under the ruler with the song's
     // sections. Simple: shown once the song has a section (the title bar's "Sections" button adds the first one, or hides
     // and shows it again); Pattern: the LYNX extra "Sections lane" (Playlist menu › View), off by default; Clip-launch: off.
@@ -485,6 +486,16 @@ public:
     void toggleSimpleSections();   // the Simple title bar's "Sections" button
     void sectionsLaneChanged();    // the extra switched, a layout change: lay the lane out again
     SectionsLaneView* getSectionsLaneForSnapshot() { return sectionsLane.get(); }
+    // The Chord lane (round 190pf, core/ChordLane.h): chords over the song under the ruler (under the Sections lane when it
+    // shows). A LYNX extra in every layout, off by default (Playlist menu › View, Settings › LYNX extras; the Simple ruler's
+    // menu too).
+    bool chordLaneShown() const;
+    int chordLaneHeight() const; // 0 when hidden
+    static constexpr int chordLaneFlHeight = 18, chordLaneSimpleHeight = 30;
+    void chordLaneChanged();     // the extra switched, a layout change: lay the lane out again
+    ChordLaneView* getChordLaneForSnapshot() { return chordLane.get(); }
+    // Round 190pf (research190oe P12): the audio clip menu's "Make the project tempo follow this clip..." (Smart Tempo)
+    void followClipTempo (int clip);
     VideoLanesView* getVideoLanesForSnapshot() { return videoLanes.get(); }
     static juce::Colour audioClipColour (const ChannelDef& channel);
 
@@ -1252,6 +1263,10 @@ private:
     std::unique_ptr<SectionsLaneView> sectionsLane;
     bool simpleSectionsHidden = false; // the Simple "Sections" button hid a lane that has sections (view only)
     int laidOutSectionsHeight = 0;
+    // The Chord lane (round 190pf)
+    friend class ChordLaneView;
+    std::unique_ptr<ChordLaneView> chordLane;
+    int laidOutChordHeight = 0;
 
     // issue #250 (round 190oq): deleted clips fade out as FL's do (ui/DeleteFade.h); `fadeOut` before they go
     ui::DeleteFade deleteFade { *this, ui::DeleteFade::playlistMs };

+ 233 - 0
src/ui/SmartTempo190pf.h

@@ -0,0 +1,233 @@
+#pragma once
+
+// Round 190pf (research190oe P12): Smart Tempo's preview (core/SmartTempo.h). The audio clip menu's LYNX extras › "Make the
+// project tempo follow this clip..." opens it: the clip's bars as found (a column per bar, its tempo; the line is the
+// tempo after smoothing), the first downbeat's beat, the pulse taken as found / half / double, a Smooth amount and how
+// far the bar lines then end from the downbeats. "Follow" writes the tempo markers and unwarps the clip (one undo step).
+// Header only: included by PlaylistComponent.cpp (and the shot route, which pictures the window without showing it).
+
+#include <algorithm>
+#include <cmath>
+#include <memory>
+#include <vector>
+
+#include <juce_gui_basics/juce_gui_basics.h>
+
+#include "core/MarkerPlan.h"
+#include "core/SmartTempo.h"
+#include "engine/AudioEngine.h"
+#include "ui/I18n.h"
+#include "ui/Theme.h"
+
+namespace lynx
+{
+// The bars' tempos: a column per bar, the smoothed tempo as a line, the lowest and highest BPM at the left
+class SmartTempoGraph final : public juce::Component
+{
+public:
+    SmartTempoGraph() { setSize (460, 150); }
+    void set (std::vector<double> rawBpm, std::vector<double> smoothBpm)
+    {
+        raw = std::move (rawBpm);
+        smooth = std::move (smoothBpm);
+        repaint();
+    }
+    void paint (juce::Graphics& g) override
+    {
+        using namespace theme;
+        auto r = getLocalBounds().toFloat();
+        g.setColour (colour::bg0);
+        g.fillRoundedRectangle (r, 4.0f);
+        if (raw.empty())
+        {
+            g.setColour (colour::textDisabled);
+            g.setFont (font (type::small));
+            g.drawText (tr ("No beats were found in this clip."), r, juce::Justification::centred);
+            return;
+        }
+        auto lo = *std::min_element (raw.begin(), raw.end()), hi = *std::max_element (raw.begin(), raw.end());
+        lo = std::floor (lo - 2.0);
+        hi = std::ceil (hi + 2.0);
+        const auto plot = r.reduced (8.0f).withTrimmedLeft (40.0f).withTrimmedBottom (14.0f);
+        g.setColour (colour::textSecondary);
+        g.setFont (font (type::caption));
+        g.drawText (juce::String (hi, 0), juce::Rectangle<float> (r.getX() + 4.0f, plot.getY() - 6.0f, 40.0f, 12.0f), juce::Justification::centredLeft);
+        g.drawText (juce::String (lo, 0), juce::Rectangle<float> (r.getX() + 4.0f, plot.getBottom() - 6.0f, 40.0f, 12.0f), juce::Justification::centredLeft);
+        const auto yOf = [&] (double bpm) { return plot.getBottom() - (float) ((bpm - lo) / std::max (1.0, hi - lo)) * plot.getHeight(); };
+        const auto w = plot.getWidth() / (float) raw.size();
+        for (std::size_t k = 0; k < raw.size(); ++k)
+        {
+            const auto x = plot.getX() + w * (float) k;
+            g.setColour (juce::Colour (0xff5b8fc9).withAlpha (0.75f));
+            g.fillRect (juce::Rectangle<float> (x + 0.5f, yOf (raw[k]), std::max (1.0f, w - 1.0f), plot.getBottom() - yOf (raw[k])));
+        }
+        if (smooth.size() == raw.size())
+        {
+            juce::Path line;
+            for (std::size_t k = 0; k < smooth.size(); ++k)
+            {
+                const auto x = plot.getX() + w * ((float) k + 0.5f);
+                k == 0 ? line.startNewSubPath (x, yOf (smooth[k])) : line.lineTo (x, yOf (smooth[k]));
+            }
+            g.setColour (colour::accent);
+            g.strokePath (line, juce::PathStrokeType (1.6f));
+        }
+        g.setColour (colour::textSecondary);
+        const auto step = std::max<std::size_t> (1, raw.size() / 8);
+        for (std::size_t k = 0; k < raw.size(); k += step)
+            g.drawText (juce::String ((int) k + 1), juce::Rectangle<float> (plot.getX() + w * (float) k, plot.getBottom() + 1.0f, 30.0f, 12.0f),
+                        juce::Justification::centredLeft);
+    }
+    std::vector<double> raw, smooth;
+};
+
+class SmartTempoWindow final : public juce::AlertWindow,
+                               private juce::Slider::Listener
+{
+public:
+    SmartTempoWindow (AudioEngine& e, int clip, std::vector<float> audio, double sampleRate, juce::Component* owner)
+        : juce::AlertWindow (tr ("Make the project tempo follow this clip"),
+                             tr ("The bars follow the recording: a tempo marker on each bar, and the clip plays exactly as recorded."),
+                             juce::MessageBoxIconType::NoIcon, owner),
+          engine (e), clipIndex (clip), mono (std::move (audio)), rate (sampleRate)
+    {
+        const auto& song = engine.getSong();
+        const auto start = clipIndex >= 0 && clipIndex < (int) song.playlist.size() ? song.playlist[(std::size_t) clipIndex].start : 0;
+        beatsPerBar = std::clamp (markers::signatureAt (song, start).first, 1, 16);
+        addCustomComponent (&graph);
+        juce::StringArray beats;
+        for (int b = 1; b <= beatsPerBar; ++b)
+            beats.add (juce::String (b));
+        addComboBox ("downbeat", beats, tr ("Bar 1 starts on beat"));
+        addComboBox ("pulse", { tr ("As detected"), tr ("Half"), tr ("Double") }, tr ("Tempo"));
+        getComboBoxComponent ("downbeat")->setSelectedItemIndex (0, juce::dontSendNotification);
+        getComboBoxComponent ("pulse")->setSelectedItemIndex (0, juce::dontSendNotification);
+        getComboBoxComponent ("downbeat")->onChange = [this] { analyse(); };
+        getComboBoxComponent ("pulse")->onChange = [this] { analyse(); };
+        smoothLabel.setText (tr ("Smooth"), juce::dontSendNotification);
+        smoothLabel.setBorderSize ({});
+        smoothSlider.setSliderStyle (juce::Slider::LinearHorizontal);
+        smoothSlider.setTextBoxStyle (juce::Slider::TextBoxRight, false, 56, 22);
+        smoothSlider.setRange (0.0, 100.0, 1.0);
+        smoothSlider.setTextValueSuffix (" %");
+        smoothSlider.setTooltip (tr ("0 %: every bar line on its downbeat. More: steadier tempos, the bar lines drift from the downbeats."));
+        smoothSlider.addListener (this);
+        smoothRow.addAndMakeVisible (smoothLabel);
+        smoothRow.addAndMakeVisible (smoothSlider);
+        smoothRow.onResize = [this] {
+            smoothLabel.setBounds (0, 0, smoothRow.getWidth(), 18);
+            smoothSlider.setBounds (0, 20, smoothRow.getWidth(), 24);
+        };
+        smoothRow.setSize (460, 46);
+        smoothRow.onResize(); // (the AlertWindow may keep this size: lay the row out now)
+        smoothLabel.setFont (getLookAndFeel().getAlertWindowFont());
+        smoothLabel.setColour (juce::Label::textColourId, findColour (juce::AlertWindow::textColourId));
+        addCustomComponent (&smoothRow);
+        info.setSize (460, 40);
+        info.setJustificationType (juce::Justification::topLeft);
+        addCustomComponent (&info);
+        addButton (tr ("Follow"), 1, juce::KeyPress (juce::KeyPress::returnKey));
+        addButton (tr ("Cancel"), 0, juce::KeyPress (juce::KeyPress::escapeKey));
+        analyse();
+    }
+
+    // the analysis and the plan again (the downbeat or the pulse changed): a few tens of ms for a song-long take
+    void analyse()
+    {
+        smarttempo::Options o;
+        o.beatsPerBar = beatsPerBar;
+        o.downbeatShift = std::max (0, getComboBoxComponent ("downbeat")->getSelectedItemIndex());
+        const auto pulse = getComboBoxComponent ("pulse")->getSelectedItemIndex();
+        o.tempoFactor = pulse == 1 ? 0.5 : pulse == 2 ? 2.0 : 1.0;
+        analysis = smarttempo::analyse (mono.data(), (long) mono.size(), rate, o);
+        replan();
+    }
+
+    void replan()
+    {
+        const auto& song = engine.getSong();
+        const auto smooth = smoothSlider.getValue() / 100.0;
+        plan = smarttempo::plan (song, clipIndex, analysis.bars, (double) mono.size() / std::max (1.0, rate), smooth);
+        std::vector<double> after;
+        for (const auto& m : plan.marks)
+            after.push_back (m.bpm);
+        graph.set (plan.rawBpm, after);
+        juce::String text;
+        if (smarttempo::blockedBy (song))
+            text = tr ("Something else moves the project's tempo (a tempo automation clip or pattern tempo events): remove it first.");
+        else if (! plan.ok)
+            text = tr ("No bars were found in this clip.");
+        else
+        {
+            const auto lo = *std::min_element (plan.rawBpm.begin(), plan.rawBpm.end()), hi = *std::max_element (plan.rawBpm.begin(), plan.rawBpm.end());
+            text = tr ("{0} bars, {1} to {2} BPM.", { juce::String ((int) plan.rawBpm.size()), juce::String (lo, 1), juce::String (hi, 1) });
+            text << " " << (plan.maxErrorMs < 0.5 ? tr ("Every bar line is on its downbeat.")
+                                                   : tr ("The bar lines end up to {0} ms from the downbeats.", { juce::String (plan.maxErrorMs, 1) }));
+            if (plan.unwarp)
+                text << " " << tr ("The clip's channel stops stretching to the tempo.");
+        }
+        info.setText (text, juce::dontSendNotification);
+        if (auto* follow = getButton (0))
+            follow->setEnabled (plan.ok);
+    }
+
+    bool apply()
+    {
+        if (! plan.ok)
+            return false;
+        auto done = false;
+        engine.editSong ([this, &done] (Song& s) { done = smarttempo::apply (s, clipIndex, plan); });
+        return done;
+    }
+
+    const smarttempo::Plan& currentPlan() const noexcept { return plan; }
+    void setSmoothForShot (double percent) { smoothSlider.setValue (percent, juce::sendNotificationSync); }
+
+private:
+    void sliderValueChanged (juce::Slider*) override { replan(); }
+
+    struct Row final : juce::Component
+    {
+        std::function<void()> onResize;
+        void resized() override
+        {
+            if (onResize)
+                onResize();
+        }
+    };
+
+    AudioEngine& engine;
+    int clipIndex = -1;
+    std::vector<float> mono;
+    double rate = 44100.0;
+    int beatsPerBar = 4;
+    smarttempo::Analysis analysis;
+    smarttempo::Plan plan;
+    SmartTempoGraph graph;
+    Row smoothRow;
+    juce::Label smoothLabel;
+    juce::Slider smoothSlider;
+    juce::Label info;
+};
+
+// The clip's whole file, mono (the analysis reads the file; the plan places it by the clip's offset). Empty without one.
+inline std::vector<float> smartTempoAudio (AudioEngine& engine, int clipIndex, double& rate)
+{
+    const auto& song = engine.getSong();
+    if (clipIndex < 0 || clipIndex >= (int) song.playlist.size())
+        return {};
+    const auto& clip = song.playlist[(std::size_t) clipIndex];
+    if (clip.kind != ClipKind::audio || clip.channel < 0 || clip.channel >= (int) song.channels.size())
+        return {};
+    const auto sample = engine.getSampleLibrary().load (juce::String::fromUTF8 (song.channels[(std::size_t) clip.channel].samplePath.c_str()));
+    if (sample == nullptr || sample->frames() == 0)
+        return {};
+    rate = sample->sampleRate;
+    const auto frames = (std::size_t) sample->frames();
+    std::vector<float> mono (sample->leftData(), sample->leftData() + frames);
+    if (sample->isStereo())
+        for (std::size_t i = 0; i < frames; ++i)
+            mono[i] = 0.5f * (mono[i] + sample->rightData()[i]);
+    return mono;
+}
+} // namespace lynx

+ 15 - 0
src/ui/TouchKeyboard.cpp

@@ -5,6 +5,7 @@
 #include <map>
 #include <set>
 
+#include "core/ChordLaneOps.h" // round 190pf
 #include "core/ChordReadout.h"
 #include "core/HeldNotes.h"
 #include "core/ProjectKey.h"
@@ -652,8 +653,21 @@ private:
         const bool fromSet = settings.projectChords && ! song.keyboardChords.empty();
         // the set the edit starts from: the project's, or the key's diatonic triads
         auto base = fromSet ? song.keyboardChords : key ? scalekeys::diatonicSet (*key) : std::vector<KeyboardChord> {};
+        // round 190pf (research190oe P13): the song's own chords (its Chord lane, core/ChordLane.h), each once in song order
+        const auto laneChords = chordlane::padSet (song.chords());
+        const auto addLaneItem = [this, &menu, laneChords] {
+            menu.addItem (tr ("The song's chords (Chord lane)"), ! laneChords.empty(), false, [this, laneChords] {
+                engine.editSong ([laneChords] (Song& s) { s.keyboardChords = laneChords; });
+                scalekeys::current().projectChords = true;
+                repaint();
+            });
+        };
         if (pad < 0 || pad >= (int) base.size())
+        {
+            if (! laneChords.empty())
+                addLaneItem();
             return menu;
+        }
         menu.addSectionHeader (tr ("Edit chord"));
         juce::PopupMenu roots, qualities;
         auto apply = [this, base, pad] (int root, int quality) {
@@ -689,6 +703,7 @@ private:
             scalekeys::current().projectChords = false;
             repaint();
         });
+        addLaneItem();
         return menu;
     }
 

+ 15 - 0
src/ui/WorkflowExtras.cpp

@@ -4,6 +4,7 @@
 #include "core/EscClose.h"
 #include "core/RulerGestures.h" // round 190nq (#227)
 #include "core/Sections.h"      // round 190ol (P1)
+#include "core/ChordLane.h"     // round 190pf (P13)
 
 #include "core/TrackClips.h"
 #include "core/TrackStates.h"
@@ -111,6 +112,10 @@ bool readUiOption (const juce::String& key, bool on)
         ruler::seekWithAnyTool() = on;
     else if (key == "sectionsLane") // round 190ol (P1): the Pattern layout's Sections lane
         sections::patternLaneOn() = on;
+    else if (key == "chordLane") // round 190pf (P13): the Chord lane, every layout
+        chordlane::laneOn() = on;
+    else if (key == "prChordHighlight") // round 190pf (P13): the Piano roll lights the Chord lane's chord
+        chordlane::pianoRollHighlight() = on;
     else if (key == "clipLanesFoldedLive") // round 190oo (CS O-3, LYNX extra)
         cliplanes::foldedOnOpen = on;
     else if (key == "liveScaleControl") // round 190oo (O-5, LYNX extra)
@@ -148,6 +153,8 @@ juce::String uiOptionsText()
            + "\ntrackClipsShown=" + juce::String (trackclips::shownInSelector() ? 1 : 0) // (round 190ne)
            + "\nrulerSeeksAnyTool=" + juce::String (ruler::seekWithAnyTool() ? 1 : 0) // (round 190nq, issue #227)
            + "\nsectionsLane=" + juce::String (sections::patternLaneOn() ? 1 : 0) // (round 190ol, P1)
+           + "\nchordLane=" + juce::String (chordlane::laneOn() ? 1 : 0) // (round 190pf, P13)
+           + "\nprChordHighlight=" + juce::String (chordlane::pianoRollHighlight() ? 1 : 0) // (round 190pf, P13)
            + "\nclipLanesFoldedLive=" + juce::String (cliplanes::foldedOnOpen ? 1 : 0) // (round 190oo, CS O-3)
            + "\nliveScaleControl=" + juce::String (livescale::shown ? 1 : 0) // (round 190oo, O-5)
            + "\ntrackStates=" + juce::String (trackstates::patternMenus() ? 1 : 0) // (round 190op, P4)
@@ -181,6 +188,10 @@ std::optional<bool> extraOn (std::string_view id)
         return ruler::seekWithAnyTool();
     if (id == "playlist.sectionsLane") // round 190ol (P1)
         return sections::patternLaneOn();
+    if (id == "playlist.chordLane") // round 190pf (P13)
+        return chordlane::laneOn();
+    if (id == "pianoRoll.chordHighlight") // round 190pf (P13)
+        return chordlane::pianoRollHighlight();
     if (id == "playlist.clipLanesFolded") // round 190oo (CS O-3)
         return cliplanes::foldedOnOpen;
     if (id == "controlBar.liveScale") // round 190oo (O-5)
@@ -224,6 +235,10 @@ bool setExtra (std::string_view id, bool on)
         ruler::seekWithAnyTool() = on;
     else if (id == "playlist.sectionsLane") // round 190ol (P1)
         sections::patternLaneOn() = on;
+    else if (id == "playlist.chordLane") // round 190pf (P13)
+        chordlane::laneOn() = on;
+    else if (id == "pianoRoll.chordHighlight") // round 190pf (P13)
+        chordlane::pianoRollHighlight() = on;
     else if (id == "playlist.clipLanesFolded") // round 190oo (CS O-3: from the next project opened)
         cliplanes::foldedOnOpen = on;
     else if (id == "controlBar.liveScale") // round 190oo (O-5)

+ 1 - 1
tests/Extras190amTests.inc

@@ -21,7 +21,7 @@ TEST (extras190am_extras_list)
         CHECK (item.note.back() == '.'); // one line of explanation, a sentence
         CHECK (item.note.find ("Also ") != std::string_view::npos); // ... that names the switch's own place
     }
-    CHECK (count == 36); // (round 190oq: editing.muteKeyToggles, general.startPage; round 190op: playlist.trackStates; round 190on: pianoRoll.stackedLanes; round 190ol: playlist.sectionsLane; round 190oo: playlist.shadeFadedAudio, project.clipLaunchStrips, simple.projectName, playlist.clipLanesFolded, controlBar.liveScale; round 190nq: playlist.rulerSeeksAnyTool; round 190ng: general.escCloses; round 190lo: polyEdit.prepareOnOpen; round 190kx: simple.loopDetect; round 190gz: project.linkTracks; round 190ht: playlist.trackInserts; round 190io: mixer.stripInserts; round 190iu: wheel zones, temporary tools, MIDI drop, Track-only; round 190jq: header width, pointer click, clip lanes; round 190jz: transport.wToStart)
+    CHECK (count == 38); // (round 190pf: playlist.chordLane, pianoRoll.chordHighlight; round 190oq: editing.muteKeyToggles, general.startPage; round 190op: playlist.trackStates; round 190on: pianoRoll.stackedLanes; round 190ol: playlist.sectionsLane; round 190oo: playlist.shadeFadedAudio, project.clipLaunchStrips, simple.projectName, playlist.clipLanesFolded, controlBar.liveScale; round 190nq: playlist.rulerSeeksAnyTool; round 190ng: general.escCloses; round 190lo: polyEdit.prepareOnOpen; round 190kx: simple.loopDetect; round 190gz: project.linkTracks; round 190ht: playlist.trackInserts; round 190io: mixer.stripInserts; round 190iu: wheel zones, temporary tools, MIDI drop, Track-only; round 190jq: header width, pointer click, clip lanes; round 190jz: transport.wToStart)
     for (const auto* id : { "mixer.loudness", "mixer.usedOnly", "mixer.keepLostLinks", "mixer.followPlaylist", "playlist.automationLanes",
                             "pianoRoll.songBarsRuler", "general.hoverValues", "playlist.trackInserts", "mixer.stripInserts" })
         CHECK (ids.count (id) == 1);