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) Pick the Bend lane's range in the piano roll (#426) (#448)

Asish9f0c13bf261e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 28253e05..3ad47b0d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,12 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
### Added
+- **Pick the Bend lane's range in the piano roll** (#426): the **±2 st** label at the top
+ left of the Bend lane is now a menu — ±2, 12, 24, 48 or 96 semitones — so a bend wider than
+ 2 semitones can be drawn on a note that has none, without recording one from an MPE
+ controller or Nota Remote first. The lane still widens by itself when a bend on the notes
+ needs more than the range picked (a step that would clip one is disabled in the menu), and
+ each clip keeps its pick for the session, like its scroll and zoom.
- **Send levels in the Arrangement's track headers** (#143): a track row tall enough for
them — a large row, or a standard one from 88 px — shows a small knob per return track
(A, B, …) under volume and pan, with the level beside it; hover names the return,
diff --git a/FEATURES.md b/FEATURES.md
index de8ea8ef..358bfd89 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -481,7 +481,9 @@ docks as a panel under any of the three, or floats in its own window — see
span; drag across a selected note to draw its curve (⌥ for a straight line), drag a point
to move it, double-click to add or delete a point, right-click for **Clear Bend /
Pressure / Slide** and **Clear All Expression**. The bend lane scales itself (±2, 12, 24,
- 48 or 96 semitones); each gesture is one undo step and plays back straight away.
+ 48 or 96 semitones) and its **±N st** label picks the least range it shows, so a big bend
+ can be drawn on a note without one; each gesture is one undo step and plays back straight
+ away.
- **Nota Remote — a phone as a controller**: **Remote** in the top bar (View → Connect
Phone…) shows a QR code; the phone opens a PWA with pads, keys in the project's scale with
chords, an XY pad with tilt, the mixer, macros and the Session grid — over Wi-Fi or a USB
diff --git a/specs/073-bend-lane-range/plan.md b/specs/073-bend-lane-range/plan.md
new file mode 100644
index 00000000..4b5f8cdd
--- /dev/null
+++ b/specs/073-bend-lane-range/plan.md
@@ -0,0 +1,48 @@
+# Implementation Plan: Pick the Bend lane's range in the piano roll
+
+**Branch**: `073-bend-lane-range` | **Date**: 2026-11-03 | **Spec**: [spec.md](spec.md)
+
+## Summary
+
+Make the Bend lane's `±N st` label a button that opens a menu of the lane's range steps. The
+pick is the least range the lane shows; the lane still widens to fit the bends on the notes.
+
+## Technical Context
+
+**Language/Version**: C# / .NET 10, Avalonia.
+
+**Primary Dependencies**: none new.
+
+**Audio-Thread Impact**: None. The range is a view setting of the piano roll on the UI thread;
+bends are stored and played in semitones as before.
+
+**Testing**: `BendLaneRangeTests` in the smoke test (`-- --bend-range` alone): the steps, the
+range shown for a pick and a bend, and which steps fit. The localization check scans the new
+Shortcuts texts. Manual check in the running app.
+
+## Design
+
+- `Nota.Application/Editing/BendLaneRange` — pure: `Steps` (2, 12, 24, 48, 96), `Default`,
+ `Fits(range, largestBend)` and `Shown(picked, largestBend)`. It replaces the step list that
+ was inline in the lane.
+- `PianoRollView.Expression.cs`:
+ - `BendPick` — the picked range, kept per clip in a static map keyed like `s_view`
+ (`_clipKey`), with the clip's start beat: the pick applies only while the clip at that
+ index still starts there, so a moved clip (which takes a new index) loses its pick instead
+ of handing it to the clip that took its index. A view without a clip identity (track mode)
+ keeps it on the instance.
+ `ForgetBendPicks` clears the map from `MainWindow.RefreshAfterLoad`, so a clip in another
+ project with the same track id and index opens at the default.
+ - `ExpressionLane.UpdateRange` stores the largest bend and shows `BendLaneRange.Shown`.
+ - `Render` draws the label with a caret (like the controller tab) in hot ink under the
+ pointer and keeps its rect; `OnPointerMoved` sets the hover and hand cursor;
+ `OnPointerPressed` opens `ShowRangeMenu` on a left press inside it unless a curve point is
+ under the pointer.
+ - `ShowRangeMenu` — a `MenuFlyout` of `MenuKit.Item`s, radio-checked on the range shown,
+ disabled where `Fits` is false.
+- `PreferencesWindow` — a Shortcuts row for the label; French in `fr.json`.
+
+## Constitution Check
+
+UI-only, no engine change, no dependency, no new ABI. Shared menu helpers, `Loc` for the new
+texts, unit "st" through `NotaNum.Unit` as before.
diff --git a/specs/073-bend-lane-range/spec.md b/specs/073-bend-lane-range/spec.md
new file mode 100644
index 00000000..4a2b0ce6
--- /dev/null
+++ b/specs/073-bend-lane-range/spec.md
@@ -0,0 +1,128 @@
+# Feature Specification: Pick the Bend lane's range in the piano roll
+
+**Feature Branch**: `073-bend-lane-range`
+
+**Created**: 2026-11-03
+
+**Status**: Implemented
+
+**Input**: GitHub issue nota-daw/nota#426: "Draw a pitch bend bigger than 2 semitones in the
+piano roll's Bend lane, from scratch, without an MPE controller. The Bend lane auto-scales to
+the bend already on a note, so a note with no bend always opens at ±2 st. […] A way to choose
+the Bend lane's range (±2 / 12 / 24 / 48 / 96 st) directly, e.g. a dropdown or clickable
+`±2 st` label in the lane, a right-click option, or a per-clip/per-track setting."
+
+## Nota Context
+
+**Feature area**:
+
+- [ ] Engine (C++, `src/native/nota.engine`)
+- [x] Managed app (C#, `src/managed/*`) — the piano roll's Bend lane
+- [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 lane under the piano roll's notes switches between
+VEL, BEND, PRES, SLIDE and a controller. The Bend lane draws each note's bend curve in
+semitones and scales itself to the largest bend on the clip's notes: ±2, 12, 24, 48 or 96
+semitones, read out by a `±N st` label at its top left. Drawing is clamped to the range shown,
+so on a clip without bends nothing past ±2 st can be drawn. The engine stores and plays bend in
+semitones whatever the lane shows. The roll is rebuilt for every clip it opens; its scroll and
+zoom are remembered per clip for the session (`s_view`).
+
+## User Scenarios & Testing
+
+### User Story 1 - Draw a big bend from scratch (Priority: P1)
+
+A user wants a note to bend up an octave. Its clip has no bends, so the Bend lane shows ±2 st.
+They click the `±2 st` label, choose ±12 st, and draw the bend up to +12.
+
+**Independent Test**: on a clip with no bends, open the Bend lane, click `±2 st ▾`, choose
+±12 st; the label reads ±12 st, the curve area spans ±12, and a stroke drawn to the top of the
+lane stores +12 semitones.
+
+**Acceptance Scenarios**:
+
+1. **Given** the Bend lane, **Then** its range label carries a caret and highlights with a hand
+ cursor under the pointer.
+2. **When** the user clicks the label, **Then** a menu lists ±2, 12, 24, 48 and 96 st with the
+ range shown checked.
+3. **When** the user picks a range, **Then** the lane shows at least that range and strokes
+ and points can reach it.
+
+### User Story 2 - Nothing gets clipped (Priority: P1)
+
+A clip already holds a 30 st bend (the lane shows ±48). Picking a narrower range would cut the
+curve off, so the steps that are too narrow are disabled; a pick narrower than a bend drawn
+later is widened past by the lane, as it does today.
+
+**Acceptance Scenarios**:
+
+1. **Given** a bend of 30 st on the clip, **When** the menu opens, **Then** ±2, 12 and 24 st
+ are disabled and ±48 and 96 st are enabled.
+2. **Given** a pick of ±12, **When** the notes' largest bend grows past 12 (a recording, an
+ undo, a paste), **Then** the lane widens to the smallest step that fits it.
+3. **Given** a pick of ±24 and a bend of 5 st, **Then** the lane shows ±24.
+
+### User Story 3 - The pick stays with the clip (Priority: P2)
+
+The user picks ±24 on a clip, opens another clip and comes back: the first clip still shows
+±24, the other one its own range.
+
+**Acceptance Scenarios**:
+
+1. **Given** a pick on a clip, **When** the clip is reopened in the same session, **Then** the
+ pick is kept, like the clip's scroll and zoom.
+2. **Given** a multi-clip (track mode) view, **Then** a pick holds while that view is open.
+
+### Edge Cases
+
+- **A curve point under the label**: it stays grabbable; the label only opens the menu where
+ no point is under the pointer.
+- **View-only lane** (no store for curves): the range can still be picked; it changes only the
+ view.
+- **Pressure and Slide lanes**: no label, no menu; their scale is 0..1.
+- **During a gesture** the range does not change, as before.
+- **A moved clip**: a clip is known by its track and index, and a move changes the index.
+ A pick holds only while the clip at that index starts where it did, so a moved clip opens at
+ the default and no other clip inherits its pick.
+
+## Requirements
+
+### Functional Requirements
+
+- **FR-001**: The Bend lane's range label MUST open a menu of the ranges ±2, 12, 24, 48 and
+ 96 semitones, the one shown checked.
+- **FR-002**: The lane MUST show the smallest step that is at least the picked range and fits
+ the largest bend on the notes.
+- **FR-003**: Steps that would clip a bend already on the notes MUST be disabled in the menu.
+- **FR-004**: The pick MUST be remembered per clip for the session, and forgotten when a
+ project is opened, created or recovered, since the new project reuses track ids.
+- **FR-005**: The gesture MUST be listed in Preferences → Shortcuts, through `Loc` with French.
+
+## Success Criteria
+
+- **SC-001**: Drawing a 12 st bend on a clip without bends takes one click on the label and one
+ menu choice, instead of recording a bend from an MPE controller or Nota Remote first.
+
+## Assumptions
+
+- The range is a view of the curve, not a property of the clip: bends are stored in semitones,
+ so nothing is saved with the project and nothing changes in the engine.
+- The pick is not saved across launches: once a clip has a big bend the lane fits it anyway.
+- The steps stay those the lane already uses (and the issue lists).
+
+## 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 — the piano roll on the UI thread
+- [x] No new managed/native crossings
+- [x] Smoke-test impact: `BendLaneRangeTests` cover the steps, the pick and the widening
+- [x] User-visible change → `CHANGELOG.md` `[Unreleased]` entry and FEATURES.md
+- [x] UI change → follows `DESIGN.md` (label ink, caret like the controller tab, MenuKit items)
diff --git a/specs/073-bend-lane-range/tasks.md b/specs/073-bend-lane-range/tasks.md
new file mode 100644
index 00000000..ddcafd31
--- /dev/null
+++ b/specs/073-bend-lane-range/tasks.md
@@ -0,0 +1,20 @@
+# Tasks: Pick the Bend lane's range in the piano roll
+
+**Input**: [spec.md](spec.md), [plan.md](plan.md)
+
+## Phase 1: User Stories 1 and 2 — pick a range, never clip (P1)
+
+- [x] T001 `BendLaneRange` (steps, default, `Fits`, `Shown`) in `src/managed/Nota.Application/Editing/BendLaneRange.cs` (FR-002)
+- [x] T002 `BendLaneRangeTests` in `tests/Nota.SmokeTest`, in the full run and alone as `--bend-range`
+- [x] T003 The range label as a button — caret, hover ink, hand cursor, a point under it still grabbable — in `src/managed/Nota.App/PianoRollView.Expression.cs` (FR-001)
+- [x] T004 The range menu: every step, the shown one checked, too-narrow steps disabled (FR-001, FR-003)
+
+## Phase 2: User Story 3 — the pick stays with the clip (P2)
+
+- [x] T005 `BendPick` per clip for the session, keyed like the view state; on the instance without a clip identity; forgotten on project load (FR-004)
+
+## Phase 3: Polish
+
+- [x] T006 Preferences → Shortcuts row, French in `fr.json` (FR-005)
+- [x] T007 `CHANGELOG.md` `[Unreleased]` and `FEATURES.md` entries
+- [x] T008 `scripts/build-linux.sh` steps pass (engine, managed, smoke test incl. localization checks)
diff --git a/src/managed/Nota.App/Languages/fr.json b/src/managed/Nota.App/Languages/fr.json
index 75234636..794349ad 100644
--- a/src/managed/Nota.App/Languages/fr.json
+++ b/src/managed/Nota.App/Languages/fr.json
@@ -573,6 +573,8 @@
"Draw the selected note's MPE curve · ⌥ draws a straight line · drag a point to move it": "Dessiner la courbe MPE de la note sélectionnée · ⌥ trace une ligne droite · glisser un point pour le déplacer",
"Add a point · on a point, delete it · right-click to clear the curve": "Ajouter un point · sur un point, le supprimer · clic droit pour effacer la courbe",
"Double-click in an MPE lane": "Double-clic dans un couloir MPE",
+ "Click the Bend lane's range": "Clic sur l’amplitude du couloir 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": "Choisir l’amplitude du couloir Bend : ±2, 12, 24, 48 ou 96 demi-tons · un bend déjà présent sur les notes peut l’élargir davantage",
"Click the controller tab": "Clic sur l’onglet de contrôleur",
"Show a MIDI controller under the notes · click it again to pick another CC, the pitch wheel or channel pressure": "Afficher un contrôleur MIDI sous les notes · cliquer à nouveau pour choisir un autre CC, la molette de hauteur ou la pression de canal",
"Drag in the Sustain lane": "Glisser dans le couloir Sustain",
diff --git a/src/managed/Nota.App/MainWindow.Files.cs b/src/managed/Nota.App/MainWindow.Files.cs
index 81b9eb3e..ce641819 100644
--- a/src/managed/Nota.App/MainWindow.Files.cs
+++ b/src/managed/Nota.App/MainWindow.Files.cs
@@ -455,6 +455,7 @@ public partial class MainWindow
_modular?.ForgetScopes(); // so do frozen Scope traces and Scope windows
LensWindow.CloseAll(); // and Lens windows
TrackArming.ForgetSelection(); // the arm-on-select memory too
+ PianoRollView.ForgetBendPicks(); // and the Bend lane ranges picked per clip
Timeline.Refresh();
_session?.Refresh();
// Popped out, the window stays up: show the new project's chain, not the old one's.
diff --git a/src/managed/Nota.App/PianoRollView.Expression.cs b/src/managed/Nota.App/PianoRollView.Expression.cs
index cc73cc13..b3d408ad 100644
--- a/src/managed/Nota.App/PianoRollView.Expression.cs
+++ b/src/managed/Nota.App/PianoRollView.Expression.cs
@@ -8,7 +8,9 @@
// stretch you drew over — on every selected note under the pointer;
// drag a point moves it (in time between its neighbours, and in value);
// double-click adds a point, or deletes the one under the pointer;
-// right-click Clear <lane> / Clear All Expression on the selected notes.
+// right-click Clear <lane> / Clear All Expression on the selected notes;
+// click the ±N st label (Bend) picks the lane's range, so a big bend can be drawn from
+// scratch — the lane still widens to fit a bigger bend already there.
// A click on a note's span with nothing selected there selects it (the highest under the
// pointer; ⇧ adds). Curves are immutable in the engine's store, so an edit stores a new curve
// and repoints the note (one undo step per gesture, like the velocity lane).
@@ -21,6 +23,7 @@ using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Media;
using Nota.Application;
+using Nota.Application.Editing;
using Nota.Application.Localization;
namespace Nota.App;
@@ -50,6 +53,30 @@ public sealed partial class PianoRollView
internal LaneMode Lane => _laneMode;
+ // The Bend lane's picked range is remembered per clip for the session, like its scroll and
+ // zoom (s_view): the roll is rebuilt for every clip it opens. A multi-clip view has no clip
+ // identity and keeps its pick for as long as it is open. A clip index is not a lasting
+ // identity (a moved clip goes to the end of its track), so a pick also holds the clip's
+ // start and applies only while the clip at that index still starts there: a pick is then
+ // lost by a moved clip rather than handed to the clip that took its index.
+ private static readonly Dictionary<(int, int), (double Start, double Range)> s_bendPick = new();
+ private double _bendPick = BendLaneRange.Default;
+
+ /// <summary>Forgets every clip's picked Bend range: a load or new project reuses track ids,
+ /// so another project's clip must not inherit a pick.</summary>
+ internal static void ForgetBendPicks() => s_bendPick.Clear();
+
+ private double BendPick
+ {
+ get => _clipKey.Item1 != int.MinValue && s_bendPick.TryGetValue(_clipKey, out var p)
+ && Math.Abs(p.Start - _set.ActiveClip.StartBeat) < 1e-9 ? p.Range : _bendPick;
+ set
+ {
+ _bendPick = value;
+ if (_clipKey.Item1 != int.MinValue) s_bendPick[_clipKey] = (_set.ActiveClip.StartBeat, value);
+ }
+ }
+
internal void SetLaneMode(LaneMode m)
{
if (m == _laneMode) return;
@@ -224,7 +251,10 @@ public sealed partial class PianoRollView
private bool _straight;
private int _ptNote = -1, _ptIdx = -1;
private (int Note, int Idx) _hoverPt = (-1, -1);
- private double _range = 2; // bend lane: ± semitones shown
+ private double _range = BendLaneRange.Default; // bend lane: ± semitones shown
+ private double _largestBend; // |bend| the notes reach, for the menu
+ private Rect _rangeRect; // the ±N st label, a button
+ private bool _rangeHot;
private NoteExpressionDim Dim => DimOf(_o._laneMode);
private const double Pad = 6;
@@ -256,16 +286,36 @@ public sealed partial class PianoRollView
return (float)Math.Clamp((h - Pad - y) / (h - 2 * Pad), 0, 1);
}
- // The bend scale follows what is there: ±2, 12, 24, 48 or 96 semitones.
+ // The bend scale follows what is there — ±2, 12, 24, 48 or 96 semitones — but never
+ // shows less than the range picked from the label.
private void UpdateRange()
{
if (Dim != NoteExpressionDim.Bend || _drag != Drag.None) return;
double m = 0;
for (int i = 0; i < _o._notes.Count; i++)
foreach (var (_, v) in Curve(i)) m = Math.Max(m, Math.Abs(v));
- _range = new[] { 2.0, 12, 24, 48, 96 }.FirstOrDefault(r => m <= r + 1e-3, 96);
+ _largestBend = m;
+ _range = BendLaneRange.Shown(_o.BendPick, m);
}
+ // The range menu under the label: every step, the shown one checked; a step too narrow
+ // for a bend already on the notes is disabled rather than clipping it.
+ private void ShowRangeMenu()
+ {
+ var f = new MenuFlyout();
+ foreach (double r in BendLaneRange.Steps)
+ {
+ var it = MenuKit.Item(RangeLabel(r), enabled: BendLaneRange.Fits(r, _largestBend));
+ it.ToggleType = MenuItemToggleType.Radio;
+ it.IsChecked = r == _range;
+ it.Click += (_, _) => { _o.BendPick = r; InvalidateVisual(); };
+ f.Items.Add(it);
+ }
+ f.ShowAt(this, showAtPointer: true);
+ }
+
+ private static string RangeLabel(double r) => "±" + NotaNum.Unit(r, "0", "st");
+
public override void Render(DrawingContext ctx)
{
double w = Bounds.Width, h = Bounds.Height;
@@ -327,9 +377,14 @@ public sealed partial class PianoRollView
if (Dim == NoteExpressionDim.Bend)
{
- var ft = new FormattedText("±" + NotaNum.Unit(_range, "0", "st"), NotaNum.Culture, FlowDirection.LeftToRight, Mono, 9, LabelText);
+ // The range label doubles as a button; the caret says it opens a menu.
+ var ink = _rangeHot ? KeyLabelHot : LabelText;
+ var ft = new FormattedText(RangeLabel(_range), NotaNum.Culture, FlowDirection.LeftToRight, Mono, 9, ink);
ctx.DrawText(ft, new Point(4, 3));
+ Glyph.Draw(ctx, GlyphKind.CaretDown, new Rect(4 + ft.Width + 2, 3 + (ft.Height - 6) / 2, 6, 6), ink);
+ _rangeRect = new Rect(0, 0, 4 + ft.Width + 2 + 6 + 4, 3 + ft.Height + 2);
}
+ else _rangeRect = default;
_o.DrawOutsideClip(ctx, w, h);
}
@@ -394,6 +449,13 @@ public sealed partial class PianoRollView
double beat = _o.XToBeat(p.X);
bool shift = (e.KeyModifiers & KeyModifiers.Shift) != 0;
+ // The range label: a point sitting under it stays grabbable.
+ if (pt.Properties.IsLeftButtonPressed && _rangeRect.Contains(p) && PointAt(p).Note < 0)
+ {
+ ShowRangeMenu();
+ e.Handled = true;
+ return;
+ }
if (pt.Properties.IsRightButtonPressed)
{
if (TargetsAt(beat, shift).Count == 0 && _o._selection.Count == 0) return;
@@ -469,12 +531,20 @@ public sealed partial class PianoRollView
return;
}
var hv = PointAt(p);
- if (hv != _hoverPt) { _hoverPt = hv; InvalidateVisual(); }
+ bool rangeHot = hv.Note < 0 && _rangeRect.Contains(p);
+ if (hv != _hoverPt || rangeHot != _rangeHot)
+ {
+ _hoverPt = hv; _rangeHot = rangeHot;
+ Cursor = rangeHot ? HandCursorShared : null;
+ InvalidateVisual();
+ }
}
protected override void OnPointerExited(PointerEventArgs e)
{
- if (_hoverPt.Note >= 0) { _hoverPt = (-1, -1); InvalidateVisual(); }
+ if (_hoverPt.Note < 0 && !_rangeHot) return;
+ _hoverPt = (-1, -1); _rangeHot = false; Cursor = null;
+ InvalidateVisual();
}
protected override void OnPointerReleased(PointerReleasedEventArgs e)
diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.cs
index c4504061..468a7431 100644
--- a/src/managed/Nota.App/PreferencesWindow.cs
+++ b/src/managed/Nota.App/PreferencesWindow.cs
@@ -1540,6 +1540,7 @@ public sealed partial class PreferencesWindow : NotaWindow
(Loc.T("Right-click velocity stem"), Loc.T("Reset velocity from a menu · same as the double-click")),
(Loc.T("Drag in the Bend / Pres / Slide lane"), Loc.T("Draw the selected note's MPE curve · ⌥ draws a straight line · drag a point to move it")),
(Loc.T("Double-click in an MPE lane"), Loc.T("Add a point · on a point, delete it · right-click to clear the curve")),
+ (Loc.T("Click the Bend lane's range"), Loc.T("Pick how far the Bend lane reaches: ±2, 12, 24, 48 or 96 semitones · a bend already on the notes can widen it further")),
(Loc.T("Click the controller tab"), Loc.T("Show a MIDI controller under the notes · click it again to pick another CC, the pitch wheel or channel pressure")),
(Loc.T("Drag in the Sustain lane"), Loc.T("Draw a pedal block on the grid · ⌘ off the grid · drag an edge to resize, the body to move · double-click or Delete removes it")),
(Loc.T("Drag in a controller lane"), Loc.T("Draw the controller's curve · ⌥ draws a straight line · drag a point to move it · double-click adds or deletes a point")),
diff --git a/src/managed/Nota.Application/Editing/BendLaneRange.cs b/src/managed/Nota.Application/Editing/BendLaneRange.cs
new file mode 100644
index 00000000..664fdefb
--- /dev/null
+++ b/src/managed/Nota.Application/Editing/BendLaneRange.cs
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// The range the piano roll's Bend lane shows (specs/073): ± semitones from one of a few fixed
+// steps. The lane fits itself to the bends already on the notes, so a clip without any bend
+// opens at ±2; the range the user picks in the lane is the least it shows, so a bigger bend can
+// be drawn from scratch. A bend never gets clipped: a curve that needs more widens the lane past
+// the pick. This is the one place that says which steps there are and which one is shown; the
+// lane only draws it and opens the menu.
+
+using System;
+using System.Collections.Generic;
+
+namespace Nota.Application.Editing;
+
+public static class BendLaneRange
+{
+ /// <summary>The ranges the lane can show, in ± semitones, smallest first.</summary>
+ public static IReadOnlyList<double> Steps { get; } = new[] { 2.0, 12, 24, 48, 96 };
+
+ /// <summary>The range before the user picks one: the smallest step.</summary>
+ public const double Default = 2;
+
+ // Rounding slack: a bend stored at 12.0004 st still fits ±12.
+ private const double Slack = 1e-3;
+
+ /// <summary>Whether ±<paramref name="range"/> shows a bend reaching
+ /// <paramref name="largestBend"/> semitones (either way) without clipping it.</summary>
+ public static bool Fits(double range, double largestBend) => Math.Abs(largestBend) <= range + Slack;
+
+ /// <summary>The range the lane shows: the smallest step at least as wide as the user's
+ /// <paramref name="picked"/> range that fits <paramref name="largestBend"/>; the widest
+ /// step when nothing fits.</summary>
+ public static double Shown(double picked, double largestBend)
+ {
+ foreach (double r in Steps)
+ if (r >= picked - Slack && Fits(r, largestBend)) return r;
+ return Steps[^1];
+ }
+}
diff --git a/tests/Nota.SmokeTest/BendLaneRangeTests.cs b/tests/Nota.SmokeTest/BendLaneRangeTests.cs
new file mode 100644
index 00000000..04580429
--- /dev/null
+++ b/tests/Nota.SmokeTest/BendLaneRangeTests.cs
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// The piano roll Bend lane's range (specs/073): the steps, the range picked from the lane's
+// label as the least it shows, and a bend already on the notes widening it past the pick.
+// Also runnable alone: `dotnet run --project tests/Nota.SmokeTest -- --bend-range`.
+
+using Nota.Application.Editing;
+
+namespace Nota.SmokeTest;
+
+internal static class BendLaneRangeTests
+{
+ public static IEnumerable<(bool Ok, string Label)> Run()
+ {
+ yield return (string.Join(",", BendLaneRange.Steps) == "2,12,24,48,96",
+ "the steps are ±2, 12, 24, 48 and 96 semitones");
+ yield return (BendLaneRange.Default == 2, "the lane opens at ±2 before a range is picked");
+
+ // Nothing picked: the lane fits what is there, as before.
+ yield return (BendLaneRange.Shown(BendLaneRange.Default, 0) == 2, "no bend shows ±2");
+ yield return (BendLaneRange.Shown(BendLaneRange.Default, 2) == 2, "a 2 st bend still fits ±2");
+ yield return (BendLaneRange.Shown(BendLaneRange.Default, 2.5) == 12, "a 2.5 st bend shows ±12");
+ yield return (BendLaneRange.Shown(BendLaneRange.Default, 12.0004) == 12,
+ "rounding slack: 12.0004 st fits ±12");
+ yield return (BendLaneRange.Shown(BendLaneRange.Default, 30) == 48, "a 30 st bend shows ±48");
+
+ // A pick: the least the lane shows, so a big bend can be drawn from scratch.
+ foreach (double r in BendLaneRange.Steps)
+ yield return (BendLaneRange.Shown(r, 0) == r, $"with no bend, picking ±{r} shows ±{r}");
+ yield return (BendLaneRange.Shown(24, 5) == 24, "a pick wider than the bend wins");
+ yield return (BendLaneRange.Shown(12, 30) == 48, "a bend wider than the pick widens the lane, never clipped");
+ yield return (BendLaneRange.Shown(96, 200) == 96, "past every step the widest is shown");
+ yield return (BendLaneRange.Shown(BendLaneRange.Default, -13) == 24, "a downward bend counts by its size");
+
+ // Which picks the menu offers: a step that would clip a bend on the notes is disabled.
+ yield return (BendLaneRange.Fits(12, 12) && BendLaneRange.Fits(12, -12), "±12 fits a 12 st bend either way");
+ yield return (!BendLaneRange.Fits(2, 2.5) && !BendLaneRange.Fits(12, -13), "a step narrower than the bend does not fit");
+ yield return (BendLaneRange.Fits(2, 0), "every step fits no bend");
+ }
+}
diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.cs
index 8e461561..6e552b36 100644
--- a/tests/Nota.SmokeTest/Program.cs
+++ b/tests/Nota.SmokeTest/Program.cs
@@ -324,6 +324,14 @@ if (args.Length >= 1 && args[0] == "--velocity-reset")
Console.WriteLine(failures == 0 ? "VELOCITY RESET PASSED" : $"VELOCITY RESET FAILED ({failures})");
return failures == 0 ? 0 : 1;
}
+// Piano-roll Bend lane range alone: `--bend-range`. Also part of the full run.
+if (args.Length >= 1 && args[0] == "--bend-range")
+{
+ Console.WriteLine("-- bend lane range --");
+ foreach (var (ok, label) in BendLaneRangeTests.Run()) Check(ok, label);
+ Console.WriteLine(failures == 0 ? "BEND RANGE PASSED" : $"BEND RANGE 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")
{
@@ -15421,6 +15429,8 @@ Console.WriteLine("-- velocity wheel --");
foreach (var (ok, label) in VelocityWheelTests.Run()) Check(ok, label);
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("-- status bar audio format --");
foreach (var (ok, label) in AudioFormatStatusTests.Run()) Check(ok, label);