Skip to content

armgit / nota

Public Imported from GitHub
0

Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.

(feat) Phrase lines in the arrangement (#517) (#570)

Asish2f879c77e31e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 70e5deb8..427f0835 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -42,6 +42,12 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
replacing or recording a clip on the computer updates its cell on the phone within a
second; a take being recorded grows as it records. Previews are sent only to a phone on
Scenes and only for the clips that changed.
+- **Phrase lines in the arrangement** (#517, specs/092). **Settings → Appearance → Phrase
+ lines** draws a heavier grid line every 4, 8, 16 or 32 bars, counted from bar 1, across
+ the lanes, the return and master rows and the ruler, so you can see where an 8- or 16-bar
+ phrase starts and ends. The line is a neutral grey a step above the bar line, works in
+ every colour theme (your own too) and stays behind the clips. It counts bars, so it
+ follows the time signature. Off by default, and remembered for every project.
- **A private Cue mix on its own outputs** (#483, specs/089). On an interface with more than
two outputs, **Settings → Outputs** sends Main (what the audience hears) to one
output pair and Cue (your own mix) to another, for example Main on 1/2 and Cue on 3/4.
diff --git a/FEATURES.md b/FEATURES.md
index ff1bc2c7..ea9a729b 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -210,6 +210,10 @@ docks as a panel under any of the three, or floats in its own window — see
on the editor used last (the arrangement while the audio clip editor shows ADSR or an
unwarped clip, which follow no grid). Hold ⌥ to drag freely; clip edges still attract a
dragged clip.
+- **Phrase lines** (Settings → Appearance; off by default, remembered app-wide): a heavier
+ neutral grid line every 4, 8, 16 or 32 bars, counted from bar 1, across the arrangement's
+ lanes, return / master rows and ruler, so the song's phrase structure reads at a glance.
+ It counts bars, so it follows the time signature, and it follows every colour theme.
- **Session View** — a clip grid (tracks × scenes) with an inspector that the toolbar's
**Inspector** key (the sidebar icon) shows or hides (remembered); on a narrow window the least-used
toolbar controls fold into a **⋯** menu. Named, coloured clips with note / waveform
@@ -1592,8 +1596,9 @@ audio effects after it keep running and keep their settings; saved with the proj
remembered; timeline, piano roll and audio editor zoom work on top of it. **Text size** —
Smaller / Default / Larger / Largest steps every text by −1 to +2 pt without changing the
layout (device cards keep theirs), live and remembered. **Waveform** —
- **Smooth** (default), **Solid** or **Bars** for audio clips on the lanes. **Track
- headers** — Left / Right side of the arrangement's track list.
+ **Smooth** (default), **Solid** or **Bars** for audio clips on the lanes. **Phrase
+ lines** — Off / 4 / 8 / 16 / 32 bars (see Snap grid). **Track headers** — Left / Right
+ side of the arrangement's track list.
- **Editing**: **Label every note in the piano roll** — the keys column names every note
instead of only C (off by default; very short rows keep C only). **Fade audio clips when
splitting** — on by default; a split then writes a 4 ms fade at the cut, which the corner
diff --git a/specs/092-phrase-lines/plan.md b/specs/092-phrase-lines/plan.md
new file mode 100644
index 00000000..4699368d
--- /dev/null
+++ b/specs/092-phrase-lines/plan.md
@@ -0,0 +1,48 @@
+# Implementation Plan: Phrase lines in the arrangement
+
+**Branch**: `092-phrase-lines` | **Date**: 2026-11-11 | **Spec**: [spec.md](spec.md)
+
+## Summary
+
+A Settings → Appearance choice (Off / 4 / 8 / 16 / 32) that makes the arrangement draw every
+Nth bar line, counted from bar 1, with a heavier neutral pen on the lanes, the footer rows and
+the ruler.
+
+## Technical Context
+
+**Language/Version**: C# / .NET 10, Avalonia.
+
+**Primary Dependencies**: none new.
+
+**Audio-Thread Impact**: None. Drawing on the UI thread and one more settings value.
+
+**Testing**: `PhraseLinesTests` in the smoke test (`-- --phrase-lines` alone): the choices,
+`Normalize`, `StartsPhrase` / `IsPhraseLine` in 4/4, 3/4 and an unset meter, and a sweep that
+every phrase line is one of `SnapGrid.GridLines` at every step and meter. The localization
+check scans the new texts. Manual check in the running app.
+
+## Design
+
+- `Nota.Application/Editing/PhraseLines` — pure: `Choices` (0, 4, 8, 16, 32), `Normalize`,
+ `StartsPhrase(bar, n)` for the ruler's bar loop and `IsPhraseLine(beat, n, beatsPerBar)` for
+ the grid's beat positions.
+- `Settings.ArrangementPhraseBars` (int, 0 = off), next to `ArrangementWaveform`.
+- `ArrangementView`:
+ - `PhraseBars` — normalised; a change calls `Redraw()` (ruler, lanes, footer rows).
+ - `PhrasePen` — `NotaPalette.Derived` mixing `GridBar` 35 % toward `TextTertiary`: a step
+ above the bar line in each of the four themes and in user themes, re-tinted on a theme
+ switch. A theme token was not added because user theme files must carry the exact
+ catalogue (`ThemeFile` rejects a file missing a token).
+ - `DrawGrid` picks `PhrasePen` for a phrase line before the bar / beat / sub-beat pens.
+ Every bar step (1, 2, 4 bars) divides every phrase length and sub-bar steps include the bar
+ lines, so phrase lines are always among the drawn lines.
+ - `RulerControl.RenderBars` draws a phrase bar's line full height in `PhrasePen` instead of
+ the 7 px tick; the time-mode ruler is untouched.
+- `MainWindow` applies the setting at start-up and on `Settings.Changed`, like the waveform.
+- `PreferencesWindow.PhraseLinesPicker` — a segmented control like `WaveformPicker`, with a
+ caption, between Waveform and Track headers. Texts in `en.json`.
+
+## Constitution Check
+
+UI-only, no engine change, no dependency, no new ABI. Colours from the palette (derived, no
+hex), texts through `Loc`.
diff --git a/specs/092-phrase-lines/spec.md b/specs/092-phrase-lines/spec.md
new file mode 100644
index 00000000..39c69bbe
--- /dev/null
+++ b/specs/092-phrase-lines/spec.md
@@ -0,0 +1,119 @@
+# Feature Specification: Phrase lines in the arrangement
+
+**Feature Branch**: `092-phrase-lines`
+
+**Created**: 2026-11-11
+
+**Status**: Implemented
+
+**Input**: GitHub issue nota-daw/nota#517: "See the arrangement's phrase structure at a glance.
+[…] An option in **Settings → Appearance**: **Phrase lines — Off / every 4 / 8 / 16 / 32
+bars**, off by default. When on, the arrangement draws a heavier grid line (a step above the bar
+line) every N bars, across the lanes and on the ruler, counting from bar 1. The line is a neutral
+grey from the theme, not the accent, and works in all four themes. It stays behind clips. It
+counts bars, not beats, so it follows time-signature changes once those exist (#421).
+Optionally the same lines in the piano roll's and audio editor's timeline. The choice is a user
+preference, not saved in the project."
+
+## Nota Context
+
+**Feature area**:
+
+- [ ] Engine (C++, `src/native/nota.engine`)
+- [x] Managed app (C#, `src/managed/*`) — the arrangement's grid and ruler, Settings
+- [x] UI (Avalonia) — follow `DESIGN.md` (Studio)
+- [ ] Plugin hosting
+- [ ] Build / packaging / CI
+- [ ] Docs only
+
+**Nota docs to keep in mind**: [`ARCHITECTURE.md`](../../ARCHITECTURE.md),
+[`CONTRIBUTING.md`](../../CONTRIBUTING.md), [`DESIGN.md`](../../DESIGN.md),
+[`FEATURES.md`](../../FEATURES.md).
+
+**Existing behaviour this builds on**: the arrangement draws one vertical line per snap-grid
+position at the drawn step (`SnapGrid.GridLines`), weighted bar › beat › sub-beat with the
+`GridBar`, `GridBeat` and `GridSubBeat` tokens, on the track lanes and the return / master rows
+(`ArrangementView.DrawGrid`). The ruler draws a 7 px `GridBar` tick at every bar and names every
+bar or every 4th. Settings → Appearance already holds arrangement looks (Waveform, Track
+headers) as segmented controls saved in `settings.json`; saving fires `Settings.Changed`, which
+the main window applies to the arrangement at once.
+
+## User Scenarios & Testing
+
+### User Story 1 - See where a phrase starts (Priority: P1)
+
+A producer arranges a song in 8-bar phrases. They open Settings → Appearance, set **Phrase
+lines** to **8**, and every 8th bar (1, 9, 17 …) carries a heavier line through every lane, the
+return and master rows and the ruler.
+
+**Independent Test**: set Phrase lines to 8 in a 4/4 project; bars 1, 9 and 17 draw the
+heavier line on the lanes and the ruler, bar 5 draws an ordinary bar line.
+
+**Acceptance Scenarios**:
+
+1. **Given** Phrase lines Off (the default), **Then** the arrangement looks as before.
+2. **Given** Phrase lines set to N, **Then** the bar lines at bars 1, N+1, 2N+1 … draw a line a
+ step heavier than a bar line, on the lanes, the footer rows and the ruler (the full ruler
+ height there), behind the clips.
+3. **When** the setting changes, **Then** the open arrangement repaints at once.
+4. **When** Nota restarts, **Then** the choice is kept; opening another project keeps it too.
+
+### User Story 2 - Readable in every theme (Priority: P1)
+
+The line is a neutral grey that reads one step above the bar line in Studio Dark / Light,
+Ember Graphite / Paper and in a user theme, and never takes the accent.
+
+**Acceptance Scenarios**:
+
+1. **Given** any theme, **Then** the phrase line sits between the bar line and the tertiary
+ text in tone, and follows a theme switch without a restart.
+2. **Given** a user theme file from before this feature, **Then** it still loads (no new token
+ is required).
+
+### Edge Cases
+
+- **Zoomed far out**: the grid's coarsest step is 4 bars and every phrase length is a multiple
+ of every bar step, so a phrase line is always a drawn grid line; it only changes the pen,
+ never adds lines between the grid's own.
+- **Odd meters**: a phrase counts bars — in 3/4, every 8 bars is every 24 beats.
+- **Ruler in time mode** (the read-out on m:ss): its ticks are seconds, not bars, so it draws
+ no phrase lines; the lanes still do.
+- **A hand-edited settings value** (3, 64, −4) reads as Off.
+
+## Requirements
+
+### Functional Requirements
+
+- **FR-001**: Settings → Appearance MUST offer **Phrase lines**: Off, 4, 8, 16, 32 bars; Off by
+ default; saved as a user preference, never in the project.
+- **FR-002**: When on, the arrangement MUST draw the bar lines at bars 1, N+1, 2N+1 … with a
+ phrase pen a step above the bar line on the lanes and the return / master rows, behind clips.
+- **FR-003**: The ruler MUST draw the same bars' line in the phrase pen over its full height.
+- **FR-004**: The phrase pen MUST be a neutral grey derived from the theme, never the accent,
+ and MUST NOT add a theme token (user themes must keep loading).
+- **FR-005**: Phrase positions MUST count bars, following the project's time signature.
+- **FR-006**: A change MUST apply to the open arrangement at once.
+
+## Success Criteria
+
+- **SC-001**: With Phrase lines on, the start of every N-bar phrase is visible without counting
+ bar numbers on the ruler.
+
+## Assumptions
+
+- The piano roll and audio editor timelines (optional in the issue) are left out: their
+ clip-relative bar counts make "from bar 1" ambiguous inside a clip; the arrangement is the
+ view the issue is about.
+- Time-signature changes along the song (#421) don't exist yet; with a single meter "every N
+ bars" is every N × beats-per-bar beats from beat 0.
+
+## Nota Compliance Checklist
+
+- [x] Every new source file carries the AGPL-3.0-only SPDX header
+- [x] No new dependency
+- [x] Audio-thread impact: none — UI-thread drawing and a setting
+- [x] No new managed/native crossings
+- [x] Smoke-test impact: `PhraseLinesTests` cover the choices, normalising, which bars carry a
+ line in several meters, and that every phrase line is a drawn grid line
+- [x] User-visible change → `CHANGELOG.md` `[Unreleased]` entry and FEATURES.md
+- [x] UI change → follows `DESIGN.md` (neutral grid ink, segmented control like Waveform)
diff --git a/specs/092-phrase-lines/tasks.md b/specs/092-phrase-lines/tasks.md
new file mode 100644
index 00000000..57a2d6b7
--- /dev/null
+++ b/specs/092-phrase-lines/tasks.md
@@ -0,0 +1,22 @@
+# Tasks: Phrase lines in the arrangement
+
+**Input**: [spec.md](spec.md), [plan.md](plan.md)
+
+## Phase 1: User Story 1 — see where a phrase starts (P1)
+
+- [x] T001 `PhraseLines` (choices, `Normalize`, `StartsPhrase`, `IsPhraseLine`) in `src/managed/Nota.Application/Editing/PhraseLines.cs` (FR-002, FR-005)
+- [x] T002 `PhraseLinesTests` in `tests/Nota.SmokeTest`, in the full run and alone as `--phrase-lines`
+- [x] T003 `Settings.ArrangementPhraseBars` (FR-001)
+- [x] T004 `ArrangementView.PhraseBars` and the phrase pen in `DrawGrid` — lanes and footer rows (FR-002)
+- [x] T005 The ruler's phrase bars full height in the phrase pen (FR-003)
+- [x] T006 Applied at start-up and on `Settings.Changed` in `MainWindow.axaml.cs` (FR-006)
+- [x] T007 Settings → Appearance → Phrase lines segmented control and caption, texts in `en.json` (FR-001)
+
+## Phase 2: User Story 2 — readable in every theme (P1)
+
+- [x] T008 `PhrasePen` derived from `GridBar` and `TextTertiary`, no new token (FR-004)
+
+## Phase 3: Polish
+
+- [x] T009 `CHANGELOG.md` `[Unreleased]` and `FEATURES.md` entries
+- [x] T010 Linux build steps pass (engine, managed, smoke test incl. localization and design checks)
diff --git a/src/managed/Nota.App/ArrangementView.Controls.cs b/src/managed/Nota.App/ArrangementView.Controls.cs
index e2baddbc..8e151236 100644
--- a/src/managed/Nota.App/ArrangementView.Controls.cs
+++ b/src/managed/Nota.App/ArrangementView.Controls.cs
@@ -13,6 +13,7 @@ using Avalonia.Layout;
using Avalonia.Media;
using Avalonia.Threading;
using Nota.Application;
+using Nota.Application.Editing;
using Nota.Presentation;
using Nota.Application.Localization;
@@ -186,7 +187,10 @@ public sealed partial class ArrangementView
double x = _o.BeatToX(beat);
if (x > w) break;
if (x < 0) continue;
- ctx.DrawLine(BarPen, new Point(x, h - 7), new Point(x, h));
+ // A phrase bar (specs/092) runs its heavier line the ruler's full height, so the
+ // phrase reads from the bar numbers down through the lanes.
+ if (PhraseLines.StartsPhrase(bar, _o._phraseBars)) ctx.DrawLine(PhrasePen, new Point(x, 0), new Point(x, h));
+ else ctx.DrawLine(BarPen, new Point(x, h - 7), new Point(x, h));
if (bar % labelEvery != 0) continue;
var ft = new NotaFormattedText((bar + 1).ToString(), CultureInfo.InvariantCulture,
FlowDirection.LeftToRight, NotaFonts.Measure, NotaType.Axis, RulerText);
diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.cs
index 310d7acd..594ee688 100644
--- a/src/managed/Nota.App/ArrangementView.cs
+++ b/src/managed/Nota.App/ArrangementView.cs
@@ -619,6 +619,20 @@ public sealed partial class ArrangementView : UserControl
set { if (_waveform == value) return; _waveform = value; _lanes.InvalidateVisual(); }
}
private WaveformStyle _waveform = WaveformStyle.Smooth;
+ /// <summary>A heavier grid line every this many bars, counted from bar 1; 0 = off
+ /// (Settings → Appearance, specs/092). Drawn on the lanes, the footer rows and the ruler.</summary>
+ public int PhraseBars
+ {
+ get => _phraseBars;
+ set
+ {
+ value = PhraseLines.Normalize(value);
+ if (_phraseBars == value) return;
+ _phraseBars = value;
+ Redraw();
+ }
+ }
+ private int _phraseBars;
/// <summary>Show/edit parameter-automation envelopes over the lanes (M9-A3).</summary>
public bool AutomationMode
{
@@ -3462,6 +3476,11 @@ public sealed partial class ArrangementView : UserControl
private static readonly IBrush ChromeBg = NotaPalette.BgSunken; // Brush.BgSunken
private static readonly IPen BeatPen = new Pen(NotaPalette.GridBeat, 1); // Brush.GridBeat
private static readonly IPen BarPen = new Pen(NotaPalette.GridBar, 1); // Brush.GridBar
+ // Phrase lines (specs/092): a step above the bar line, a neutral grey moved from the bar
+ // line toward the tertiary text — derived, so it follows every theme (user themes too) without
+ // a token of its own, and never the accent.
+ private static readonly IPen PhrasePen = new Pen(NotaPalette.Derived(
+ () => SliderTrack.Mix(NotaPalette.GridBar.Color, NotaPalette.TextTertiary.Color, 0.35)), 1);
private static readonly IPen SubBeatPen = new Pen(NotaPalette.GridSubBeat, 1); // finer than a beat
// Playhead: a 1px accent line with a 7×5 flag on the ruler, no glow (almanac § timeline).
// The brush is the palette slot itself — a SolidColorBrush built from its Color froze the
@@ -3683,8 +3702,9 @@ public sealed partial class ArrangementView : UserControl
private double BeatToX(double beat) => (beat - _scrollBeats) * _pixelsPerBeat;
/// <summary>The vertical grid over a lane-wide canvas: one line per snap position at the
- /// drawn step (SnapGrid.GridLines, the same set Snap() lands on), weighted bar › beat ›
- /// sub-beat. Shared by the lanes and the footer rows.</summary>
+ /// drawn step (SnapGrid.GridLines, the same set Snap() lands on), weighted phrase › bar ›
+ /// beat › sub-beat. A phrase line is always one of those lines (every bar step divides a
+ /// phrase), so it only changes the pen. Shared by the lanes and the footer rows.</summary>
private void DrawGrid(DrawingContext ctx, double w, double h)
{
if (_pixelsPerBeat <= 0) return;
@@ -3693,7 +3713,8 @@ public sealed partial class ArrangementView : UserControl
foreach (double b in SnapGrid.GridLines(_scrollBeats, _scrollBeats + w / _pixelsPerBeat, step, _beatsPerBar))
{
double x = BeatToX(b);
- var pen = IsWhole(b / bar) ? BarPen : IsWhole(b) ? BeatPen : SubBeatPen;
+ var pen = PhraseLines.IsPhraseLine(b, _phraseBars, _beatsPerBar) ? PhrasePen
+ : IsWhole(b / bar) ? BarPen : IsWhole(b) ? BeatPen : SubBeatPen;
ctx.DrawLine(pen, new Point(x, 0), new Point(x, h));
}
diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.cs
index d543fffd..d702a28b 100644
--- a/src/managed/Nota.App/MainWindow.axaml.cs
+++ b/src/managed/Nota.App/MainWindow.axaml.cs
@@ -425,14 +425,16 @@ public partial class MainWindow : Window
};
Timeline.Waveform = (WaveformStyle)Math.Clamp(vm.Settings.Current.ArrangementWaveform, 0, 2);
Timeline.ClipStyle = Looks.ClipStyleOf(vm.Settings.Current);
+ Timeline.PhraseBars = vm.Settings.Current.ArrangementPhraseBars;
vm.Engine.SplitFades = vm.Settings.Current.SplitFades;
ApplyHeadersRight(vm.Settings.Current.ArrangementHeadersRight);
InitSnapGrid();
- // Settings → Appearance can switch the waveform style and the header side while the arrangement is open.
+ // Settings → Appearance can switch the waveform style, the phrase lines and the header side while the arrangement is open.
vm.Settings.Changed += () =>
{
Timeline.Waveform = (WaveformStyle)Math.Clamp(vm.Settings.Current.ArrangementWaveform, 0, 2);
Timeline.ClipStyle = Looks.ClipStyleOf(vm.Settings.Current); // a pick, or the look's default
+ Timeline.PhraseBars = vm.Settings.Current.ArrangementPhraseBars;
vm.Engine.SplitFades = vm.Settings.Current.SplitFades;
ApplyHeadersRight(vm.Settings.Current.ArrangementHeadersRight);
};
diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.cs
index 3afce031..7f5fb594 100644
--- a/src/managed/Nota.App/PreferencesWindow.cs
+++ b/src/managed/Nota.App/PreferencesWindow.cs
@@ -29,6 +29,7 @@ using Avalonia.Platform.Storage;
using Avalonia.Threading;
using Microsoft.Extensions.DependencyInjection;
using Nota.Application;
+using Nota.Application.Editing;
using Nota.Application.Localization;
using Nota.Application.Themes;
using Nota.Presentation;
@@ -1297,6 +1298,33 @@ public sealed partial class PreferencesWindow : NotaWindow
return host;
}
+ // Off / 4 / 8 / 16 / 32 for the arrangement's phrase lines (specs/092, #517): a heavier
+ // grid line every N bars from bar 1. Saving fires Settings.Changed, which repaints the
+ // arrangement at once.
+ private static Control PhraseLinesPicker()
+ {
+ var settings = App.Services.GetRequiredService<ISettingsService>();
+ var strip = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 2 };
+ var buttons = new List<(int Bars, ToggleButton Btn)>();
+ int current = PhraseLines.Normalize(settings.Current.ArrangementPhraseBars);
+ foreach (int bars in PhraseLines.Choices)
+ {
+ var n = bars;
+ var label = n == 0 ? Loc.T("common.off") : n.ToString(NotaNum.Culture);
+ var btn = new ToggleButton { Classes = { "seg" }, FontSize = 11, Content = label, IsChecked = current == n };
+ btn.Click += (_, _) =>
+ {
+ foreach (var (bn, bb) in buttons) bb.IsChecked = bn == n;
+ if (settings.Current.ArrangementPhraseBars == n) return;
+ settings.Current.ArrangementPhraseBars = n;
+ settings.Save();
+ };
+ buttons.Add((n, btn));
+ strip.Children.Add(btn);
+ }
+ return new Border { Classes = { "segmented" }, HorizontalAlignment = HorizontalAlignment.Left, Child = strip };
+ }
+
// Left / Right for the arrangement's track-header column (#72). Saving fires
// Settings.Changed, which moves the column at once and ticks the View menu item.
// The same event repaints these buttons, so a change from the View menu updates an
@@ -1415,6 +1443,8 @@ public sealed partial class PreferencesWindow : NotaWindow
Row("", Caption(Loc.T("preferences.accent_caption"))),
Row(Loc.T("preferences.waveform"), WaveformPicker()),
Row("", Caption(Loc.T("preferences.how_audio_clips_draw_on"))),
+ Row(Loc.T("preferences.phrase_lines"), PhraseLinesPicker()),
+ Row("", Caption(Loc.T("preferences.phrase_lines_caption"))),
Row(Loc.T("preferences.track_headers"), HeaderSidePicker()),
Row("", Caption(Loc.T("preferences.which_side_of_the_arrangement"))),
Row(Loc.T("preferences.interface_scale"), ScalePicker()),
diff --git a/src/managed/Nota.Application/Editing/PhraseLines.cs b/src/managed/Nota.Application/Editing/PhraseLines.cs
new file mode 100644
index 00000000..0736cb08
--- /dev/null
+++ b/src/managed/Nota.Application/Editing/PhraseLines.cs
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Phrase lines in the arrangement (specs/092, #517): a heavier grid line every 4, 8, 16 or
+// 32 bars, counted from bar 1, so a song's phrase structure reads at a glance. A user
+// preference (Settings → Appearance), never saved in a project. This is the one place that
+// says which lengths there are and which bars carry a line; the lanes and the ruler only
+// draw it. Bars, not beats: a line lands on the same bar in any meter.
+
+using System;
+using System.Collections.Generic;
+
+namespace Nota.Application.Editing;
+
+public static class PhraseLines
+{
+ /// <summary>The phrase lengths Settings offers, in bars; 0 is Off (the default).</summary>
+ public static IReadOnlyList<int> Choices { get; } = new[] { 0, 4, 8, 16, 32 };
+
+ /// <summary><paramref name="bars"/> when it is one of <see cref="Choices"/>, else Off — so
+ /// a hand-edited settings file can never draw a line every 3 bars.</summary>
+ public static int Normalize(int bars)
+ {
+ foreach (int c in Choices)
+ if (c == bars) return bars;
+ return 0;
+ }
+
+ /// <summary>Whether the bar with zero-based index <paramref name="bar"/> (bar 1 is 0)
+ /// starts a phrase of <paramref name="phraseBars"/> bars.</summary>
+ public static bool StartsPhrase(int bar, int phraseBars)
+ {
+ int n = Normalize(phraseBars);
+ return n > 0 && bar >= 0 && bar % n == 0;
+ }
+
+ /// <summary>Whether a grid line at <paramref name="beat"/> is a phrase line: it sits on a
+ /// bar line and that bar starts a phrase of <paramref name="phraseBars"/> bars.</summary>
+ public static bool IsPhraseLine(double beat, int phraseBars, int beatsPerBar)
+ {
+ if (Normalize(phraseBars) == 0) return false;
+ double bars = beat / SnapGrid.BarBeats(beatsPerBar);
+ double whole = Math.Round(bars);
+ return Math.Abs(bars - whole) < 1e-6 && StartsPhrase((int)whole, phraseBars);
+ }
+}
diff --git a/src/managed/Nota.Application/Localization/en.json b/src/managed/Nota.Application/Localization/en.json
index d82482a0..200b4229 100644
--- a/src/managed/Nota.Application/Localization/en.json
+++ b/src/managed/Nota.Application/Localization/en.json
@@ -3673,6 +3673,8 @@
"preferences.per_note_expression_from_mpe": "Per-note expression from MPE controllers",
"preferences.performance": "Performance",
"preferences.phones_and_tablets_on_this": "Phones and tablets on this network",
+ "preferences.phrase_lines": "Phrase lines",
+ "preferences.phrase_lines_caption": "A heavier grid line every 4, 8, 16 or 32 bars, counted from bar 1, across the arrangement and its ruler — so you can see where a phrase or section starts.",
"preferences.pick_how_far_the_bend": "Pick how far the Bend lane reaches: ±2, 12, 24, 48 or 96 semitones · a bend already on the notes can widen it further",
"preferences.play_c4_d4_e4_f4": "Play C4 D4 E4 F4",
"preferences.play_from_that_point": "Play from that point",
diff --git a/src/managed/Nota.Application/Settings.cs b/src/managed/Nota.Application/Settings.cs
index e0fac88a..56944120 100644
--- a/src/managed/Nota.Application/Settings.cs
+++ b/src/managed/Nota.Application/Settings.cs
@@ -187,6 +187,10 @@ public sealed class Settings
/// saved 0 moves to the new default), 1 solid — one column per pixel, 2 bars — spaced
/// peak strokes.</summary>
public int ArrangementWaveform { get; set; }
+ /// <summary>A heavier grid line every this many bars across the arrangement's lanes and
+ /// ruler, counted from bar 1 (Settings → Appearance, #517): 0 off (default), 4, 8, 16 or
+ /// 32. Anything else reads as off (<see cref="Editing.PhraseLines.Normalize"/>).</summary>
+ public int ArrangementPhraseBars { get; set; }
/// <summary>Splitting an audio clip writes a short fade at the cut (issue #286). On by
/// default; a missing key in an older settings file stays on. MIDI clips are left alone.
/// The command palette and the clip menu can still fade a join when this is off.</summary>
diff --git a/tests/Nota.SmokeTest/PhraseLinesTests.cs b/tests/Nota.SmokeTest/PhraseLinesTests.cs
new file mode 100644
index 00000000..b4f8e714
--- /dev/null
+++ b/tests/Nota.SmokeTest/PhraseLinesTests.cs
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Phrase lines in the arrangement (specs/091): the choices, a stored value read back, and
+// which bars carry the heavier line — counted from bar 1, by bars in any meter, and always on
+// a line the snap grid draws anyway. Also runnable alone:
+// `dotnet run --project tests/Nota.SmokeTest -- --phrase-lines`.
+
+using Nota.Application;
+using Nota.Application.Editing;
+
+namespace Nota.SmokeTest;
+
+internal static class PhraseLinesTests
+{
+ public static IEnumerable<(bool Ok, string Label)> Run()
+ {
+ yield return (string.Join(",", PhraseLines.Choices) == "0,4,8,16,32",
+ "the choices are Off, 4, 8, 16 and 32 bars");
+ yield return (new Settings().ArrangementPhraseBars == 0, "phrase lines are off by default");
+
+ // A stored value: one of the choices is kept, anything else reads as Off.
+ foreach (int c in PhraseLines.Choices)
+ yield return (PhraseLines.Normalize(c) == c, $"a stored {c} is kept");
+ yield return (PhraseLines.Normalize(3) == 0 && PhraseLines.Normalize(-4) == 0 && PhraseLines.Normalize(64) == 0,
+ "a hand-edited 3, -4 or 64 reads as Off");
+
+ // Which bars start a phrase: bar 1, then every N bars.
+ yield return (PhraseLines.StartsPhrase(0, 16) && PhraseLines.StartsPhrase(16, 16) && PhraseLines.StartsPhrase(32, 16),
+ "every 16 bars: bars 1, 17 and 33 start a phrase");
+ yield return (!PhraseLines.StartsPhrase(4, 16) && !PhraseLines.StartsPhrase(15, 16) && !PhraseLines.StartsPhrase(17, 16),
+ "every 16 bars: bars 5, 16 and 18 do not");
+ yield return (PhraseLines.StartsPhrase(4, 4) && !PhraseLines.StartsPhrase(6, 4), "every 4 bars: bar 5 does, bar 7 does not");
+ yield return (!PhraseLines.StartsPhrase(0, 0) && !PhraseLines.StartsPhrase(8, 0), "Off: no bar starts a phrase");
+ yield return (!PhraseLines.StartsPhrase(-8, 8), "nothing before bar 1");
+ yield return (!PhraseLines.StartsPhrase(6, 3), "a length that is not a choice draws nothing");
+
+ // A grid line by its beat: on a bar line, and on a phrase bar.
+ yield return (PhraseLines.IsPhraseLine(0, 8, 4) && PhraseLines.IsPhraseLine(32, 8, 4) && PhraseLines.IsPhraseLine(64, 8, 4),
+ "4/4, every 8 bars: beats 0, 32 and 64");
+ yield return (!PhraseLines.IsPhraseLine(16, 8, 4) && !PhraseLines.IsPhraseLine(33, 8, 4) && !PhraseLines.IsPhraseLine(32.5, 8, 4),
+ "4/4, every 8 bars: not beat 16 (bar 5), 33 or 32.5");
+ yield return (PhraseLines.IsPhraseLine(24, 8, 3) && !PhraseLines.IsPhraseLine(32, 8, 3),
+ "3/4 counts bars, not beats: beat 24 is bar 9, beat 32 is inside bar 11");
+ yield return (PhraseLines.IsPhraseLine(64, 16, 0) && !PhraseLines.IsPhraseLine(48, 16, 0),
+ "an unset meter reads as 4/4: beat 64 is bar 17, beat 48 is bar 13");
+ yield return (PhraseLines.IsPhraseLine(64.0000001, 16, 4), "rounding slack: 64.0000001 is still bar 17");
+ yield return (!PhraseLines.IsPhraseLine(0, 0, 4), "Off: no line at all");
+
+ // Every phrase line is a line the snap grid already draws, whatever its step and meter,
+ // so the grid only has to weight it — never add a line between its own.
+ bool onGrid = true;
+ foreach (int meter in new[] { 3, 4, 5, 7 })
+ foreach (int n in new[] { 4, 8, 16, 32 })
+ for (int i = 0; i < GridStep.Count; i++)
+ {
+ double step = GridStep.Of(i, false).Beats(meter);
+ var lines = new HashSet<double>(SnapGrid.GridLines(0, meter * 70, step, meter));
+ for (int bar = 0; bar < 70; bar += n)
+ if (!lines.Contains(bar * (double)meter)) onGrid = false;
+ }
+ yield return (onGrid, "every phrase line falls on a drawn grid line at every step and meter");
+ }
+}
diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.cs
index 404c32ad..e9eeb5ce 100644
--- a/tests/Nota.SmokeTest/Program.cs
+++ b/tests/Nota.SmokeTest/Program.cs
@@ -383,6 +383,14 @@ if (args.Length >= 1 && args[0] == "--bend-range")
Console.WriteLine(failures == 0 ? "BEND RANGE PASSED" : $"BEND RANGE FAILED ({failures})");
return failures == 0 ? 0 : 1;
}
+// Arrangement phrase lines alone: `--phrase-lines`. Also part of the full run.
+if (args.Length >= 1 && args[0] == "--phrase-lines")
+{
+ Console.WriteLine("-- phrase lines --");
+ foreach (var (ok, label) in PhraseLinesTests.Run()) Check(ok, label);
+ Console.WriteLine(failures == 0 ? "PHRASE LINES PASSED" : $"PHRASE LINES FAILED ({failures})");
+ return failures == 0 ? 0 : 1;
+}
// Filter knob glide alone: `--glide`. Also part of the full run.
if (args.Length >= 1 && args[0] == "--glide")
{
@@ -15746,6 +15754,8 @@ Console.WriteLine("-- velocity reset --");
foreach (var (ok, label) in VelocityResetTests.Run()) Check(ok, label);
Console.WriteLine("-- bend lane range --");
foreach (var (ok, label) in BendLaneRangeTests.Run()) Check(ok, label);
+Console.WriteLine("-- phrase lines --");
+foreach (var (ok, label) in PhraseLinesTests.Run()) Check(ok, label);
Console.WriteLine("-- status bar audio format --");
foreach (var (ok, label) in AudioFormatStatusTests.Run()) Check(ok, label);