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) Reset a note's velocity to the default from the velocity lane (#418)

vv7r4497c8666747
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 69a99cec..06ba4fce 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,13 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
### Added
+- **Reset a note's velocity to the default**: in the piano roll's velocity lane, double-click a
+ note's stem — or right-click it and choose **Reset velocity** — to put the note back to the
+ default velocity (0.8, the one a first note gets). When the note is selected, the whole
+ selection is reset. One undo step brings the old velocities back, even though the double-click
+ also clicked the stem. A note already at the default is left alone and a locked reference
+ clip's notes are never touched. Grabbing a stem by its cap no longer makes it jump to the pixel
+ you pressed: it moves from where it is.
- **French interface and a Language setting**: Preferences → Appearance → **Language** lists
English and Français (each in its own name). The choice is saved and applies after a restart;
the row says so and offers a **Restart** button (the usual unsaved-changes prompt comes first).
diff --git a/FEATURES.md b/FEATURES.md
index 01608d62..fde9fdb8 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -328,6 +328,9 @@ docks as a panel under any of the three, or floats in its own window — see
plays on its own loop clock, so its editor counts from the slot's start and doesn't seek.
- Drag a note's left edge to move its start (the end stays put); stacked notes keep
separate velocity stems (grab a stem by its cap, ⇧-click to add it to the selection).
+ - **Reset velocity**: double-click a velocity stem, or right-click it → **Reset velocity**, to put
+ the note — or the whole selection, when the note is selected — back to the default velocity
+ (0.8); one undo step. Notes already at the default and a reference clip's notes are left alone.
- Notes replace the same-pitch notes they land on instead of stacking: moved, stretched,
drawn or pasted notes cut or remove what they cover once the selection is let go
(click elsewhere, Esc, another clip, save); until then the part that will go is drawn
diff --git a/specs/069-velocity-reset-default/checklists/requirements.md b/specs/069-velocity-reset-default/checklists/requirements.md
new file mode 100644
index 00000000..0ea283d9
--- /dev/null
+++ b/specs/069-velocity-reset-default/checklists/requirements.md
@@ -0,0 +1,35 @@
+# Specification Quality Checklist: Reset a note's velocity to the default
+
+**Purpose**: Validate specification completeness and quality before proceeding to planning
+**Created**: 2026-11-01
+**Feature**: [spec.md](../spec.md)
+
+## Content Quality
+
+- [X] No implementation details (languages, frameworks, APIs)
+- [X] Focused on user value and business needs
+- [X] Written for non-technical stakeholders
+- [X] All mandatory sections completed
+
+## Requirement Completeness
+
+- [X] No [NEEDS CLARIFICATION] markers remain
+- [X] Requirements are testable and unambiguous
+- [X] Success criteria are measurable
+- [X] Success criteria are technology-agnostic (no implementation details)
+- [X] All acceptance scenarios are defined
+- [X] Edge cases are identified
+- [X] Scope is clearly bounded
+- [X] Dependencies and assumptions identified
+
+## Feature Readiness
+
+- [X] All functional requirements have clear acceptance criteria
+- [X] User scenarios cover primary flows
+- [X] Feature meets measurable outcomes defined in Success Criteria
+- [X] No implementation details leak into specification
+
+## Notes
+
+- The Nota Context section names the file and the existing behaviour because the repository's spec template asks for it; the requirements themselves stay about behaviour.
+- Open design points were settled with defaults, listed under Assumptions (fixed 0.8, double-click only, no setting).
diff --git a/specs/069-velocity-reset-default/contracts/velocity-lane.md b/specs/069-velocity-reset-default/contracts/velocity-lane.md
new file mode 100644
index 00000000..602f2197
--- /dev/null
+++ b/specs/069-velocity-reset-default/contracts/velocity-lane.md
@@ -0,0 +1,28 @@
+# Contract: velocity lane gestures
+
+The piano roll's lane, **Vel** tab only. Other tabs are unchanged.
+
+| Gesture | Where | Effect |
+|---|---|---|
+| Click / drag a stem | a stem within reach | unchanged: sets the velocity where it lands; a selection moves by the drag |
+| ⇧-click a stem | a stem | unchanged: adds it to the selection |
+| **Double-click a stem** | a stem | resets the stem's note — or the whole selection when the stem belongs to it — to 0.8; one undo step with the first click |
+| **Right-click a stem** | a stem | selects it as a press does, then opens a menu with **Reset velocity** |
+| Right-click empty lane | no stem within reach | nothing |
+
+## Menu
+
+| Item | Enabled | Effect |
+|---|---|---|
+| **Reset velocity** | when at least one target is not already at 0.8 | same as the double-click |
+
+Targets: the selection when the stem is selected, else the stem's note; locked and ghost notes never.
+
+## Texts (English key → French)
+
+| Key | French |
+|---|---|
+| `Reset velocity` | `Réinitialiser la vélocité` |
+| `Double-click a velocity stem` / `Right-click a velocity stem` | rows of Preferences → Shortcuts → Piano roll |
+
+(The two Shortcuts descriptions are written in the implementation, in the style of the neighbouring rows, and added to `fr.json`.)
diff --git a/specs/069-velocity-reset-default/data-model.md b/specs/069-velocity-reset-default/data-model.md
new file mode 100644
index 00000000..d1462810
--- /dev/null
+++ b/specs/069-velocity-reset-default/data-model.md
@@ -0,0 +1,31 @@
+# Data Model: Reset a note's velocity to the default
+
+No data is added, saved or migrated. A note's velocity already travels in the project file as a float in 0..1; this feature only changes its value.
+
+## Default velocity
+
+| Field | Type | Rule |
+|---|---|---|
+| `VelocityReset.Default` | float | 0.8. Not a setting. Also the initial "last touched" velocity and the playable keys' velocity. |
+
+**Equality**: two velocities are the same when they differ by less than half a MIDI step (0.5 / 127). A note at the default is never touched by a reset.
+
+## Reset targets
+
+Input: the lane's note list, the selection (indices), the stem hit (index), each note's lock state.
+
+- Stem in the selection → every selected, unlocked note.
+- Stem outside the selection → that note only, and it becomes the selection.
+- Locked notes (a reference clip) and ghost notes → never targets.
+
+Output: the targets whose velocity is not already the default. Empty = nothing changes, no undo step, menu item disabled.
+
+## State
+
+```
+idle ──press on a stem──▶ burst open (seeded undo step, notes changed live)
+burst open ──second press of a double-click on the same stem──▶ reset applied inside the same burst
+burst open ──idle 600 ms / another edit / undo / redo──▶ closed (Remember: last touched = this note)
+```
+
+One undo step per burst. A reset after a long pause is its own burst (its own step).
diff --git a/specs/069-velocity-reset-default/plan.md b/specs/069-velocity-reset-default/plan.md
new file mode 100644
index 00000000..39893333
--- /dev/null
+++ b/specs/069-velocity-reset-default/plan.md
@@ -0,0 +1,90 @@
+# Implementation Plan: Reset a note's velocity to the default
+
+**Branch**: `069-velocity-reset-default` | **Date**: 2026-11-01 | **Spec**: [spec.md](spec.md)
+
+**Input**: Feature specification from `/specs/069-velocity-reset-default/spec.md`
+
+## Summary
+
+A double-click on a note's stem in the piano roll's velocity lane, or **Reset velocity** from the stem's right-click menu, puts the note (or the whole selection, when the stem belongs to it) back to the default velocity 0.8. The reset is one undo step that returns to the velocities from before the double-click. Managed UI only: the lane (`PianoRollView.VelocityLane`) gains the two gestures; the rule "which notes, to what" is a small pure helper in `Nota.Application/Editing` so the smoke test can cover it; the undo behaviour reuses the velocity-wheel burst (specs/063). No engine, ABI or file-format change.
+
+## Nota: Read Before Planning
+
+- **UI work** → [`DESIGN.md`](../../DESIGN.md) (menu follows the existing piano-roll lane menus; no new visual element) and the `nota-design` skill.
+- **Anything** → [`CONTRIBUTING.md`](../../CONTRIBUTING.md); user-visible text goes through `Loc` with a French entry ([specs/068-ui-language](../068-ui-language/spec.md)).
+- Engine rules (`ARCHITECTURE.md` AR table): not touched.
+
+## Technical Context
+
+**Language/Version**: C# / .NET 10 (managed app); no C++ change.
+
+**Primary Dependencies**: Avalonia 12 (already used); no new dependency.
+
+**Storage**: N/A — a velocity is already a field of every note in the project file; nothing new is saved.
+
+**Audio-Thread Impact**: None: UI-only change. A reset pushes notes through the existing live path (`SetClipNotesLive`, no undo checkpoint) and the existing undo seed, exactly as a velocity-wheel burst does; nothing new reaches the audio thread.
+
+**Testing**: smoke test (`tests/Nota.SmokeTest`): the pure rule (`VelocityReset`) in a new `VelocityResetTests`, run by `scripts/build.sh`; localization checks (French key present, no raw literal). The gesture wiring in the lane is verified by hand (quickstart) and by a screenshot hook run, as the lane has no headless pointer harness.
+
+**Target Platform**: macOS, Windows, Linux (desktop app).
+
+**Project Type**: desktop-app.
+
+**Performance Goals**: a reset on a 1,000-note selection is imperceptible (one pass over the selection, one live push).
+
+**Constraints**: the reset must not add a second undo step on top of the first click of a double-click; locked and ghost notes are never touched; other lane tabs unchanged.
+
+**Scale/Scope**: one lane, two gestures, one helper, ~3 new interface strings, two docs rows.
+
+## Constitution Check
+
+| Principle | Status |
+|---|---|
+| I. Real-time audio safety | Pass — no audio-thread code; edits use the existing command path. |
+| II. Boundary discipline | Pass — no ABI change. |
+| III. Licensing hygiene | Pass — new files carry the SPDX header; no dependency. |
+| IV. Verification gate | Pass — pure rule covered by the smoke test; `scripts/build.sh` runs it. |
+| V. One logical change per PR | Pass — one feature: reset velocity. |
+| VI. Documentation in sync | Planned — CHANGELOG, FEATURES.md, Shortcuts pane (`nota-shortcuts`), user manual EN + RU (`nota-docs`), French strings. |
+| VII. Spec-first | Pass — spec, plan, tasks before code. |
+| VIII. Safety rules not weakened | Pass. |
+
+Re-checked after design: no change. No violation to justify.
+
+## Project Structure
+
+### Documentation (this feature)
+
+```text
+specs/069-velocity-reset-default/
+├── plan.md
+├── research.md
+├── data-model.md
+├── quickstart.md
+├── contracts/velocity-lane.md
+├── checklists/requirements.md
+└── tasks.md # /speckit-tasks
+```
+
+### Source Code
+
+```text
+src/managed/
+├── Nota.Application/Editing/VelocityReset.cs # new: the default and the pick/apply rule (pure)
+└── Nota.App/
+ ├── PianoRollView.cs # VelocityLane: double-click, right-click menu,
+ │ # burst reuse; s_lastVel and KeyVelocity read the shared default
+ ├── PreferencesWindow.cs # Shortcuts → Piano roll: two rows
+ └── Languages/fr.json # French for the new texts
+tests/Nota.SmokeTest/
+├── VelocityResetTests.cs # new
+└── Program.cs # run the new tests
+CHANGELOG.md · FEATURES.md # entries
+../nota-docs (separate repo) # piano-roll page EN + RU, coverage.yml
+```
+
+**Structure Decision**: the rule lives beside `VelocityWheel` and `NoteOverwrite` in `Nota.Application/Editing` (pure, testable); the lane keeps pointer handling, menu and undo timing, like the wheel does.
+
+## Complexity Tracking
+
+No violations.
diff --git a/specs/069-velocity-reset-default/quickstart.md b/specs/069-velocity-reset-default/quickstart.md
new file mode 100644
index 00000000..2f37b903
--- /dev/null
+++ b/specs/069-velocity-reset-default/quickstart.md
@@ -0,0 +1,46 @@
+# Quickstart: validating the velocity reset
+
+Prerequisites: the repo builds (`scripts/build.sh`). Run the app from the repo root: `dotnet run --project src/managed/Nota.App`.
+
+## 1. Automated gate
+
+`scripts/build.sh` runs the smoke test; the new `VelocityResetTests` must pass:
+
+| Check | Proves |
+|---|---|
+| Default | the default is 0.8 and the "last touched" start value and the playable keys' value read it |
+| One stem | a stem outside the selection targets only that note |
+| Selection | a stem inside the selection targets every selected note |
+| Locked | locked notes are never targets |
+| Already default | a note at 0.8, or within half a MIDI step of it, is not a target; nothing to do |
+
+The localization checks must stay green (French entry for each new text, no raw literal).
+
+## 2. Manual: double-click (User Story 1, 2)
+
+1. Open a MIDI clip in the piano roll, draw two notes, drag the first note's stem to the top.
+2. Double-click that stem. Expect the stem at about 80 % height (`vel 102` in the note tooltip) and the sound follow.
+3. ⌘Z once. Expect the stem back at the top, not slightly lower.
+4. Select both notes, give them different velocities, double-click one of the two stems. Expect both at 0.8; ⌘Z once restores both.
+5. Select one note, double-click the other, unselected, note's stem. Expect only that one reset and the selection to move to it.
+6. Double-click a stem already at 0.8. Expect no visible change; ⌘Z undoes the step before, not a no-op.
+7. Double-click empty lane space. Expect nothing.
+
+## 3. Manual: menu (User Story 3)
+
+1. Right-click a stem not at 0.8. Expect a menu with **Reset velocity**; choose it. Expect 0.8; ⌘Z restores.
+2. Right-click a stem of a selected note. Expect the whole selection to reset.
+3. Right-click a stem already at 0.8. Expect **Reset velocity** disabled.
+4. Right-click empty lane space. Expect no menu.
+5. Switch the tab to Pres or Bend. Expect their own right-click "Clear" menus and double-click add / remove point, unchanged.
+
+## 4. Edge cases
+
+- Play a loop while resetting: the next note plays at the new velocity, no glitch.
+- Open a clip with a locked reference clip behind it: its stems do not react.
+- A Session slot's roll: reset and ⌘Z behave the same (the engine receives the change within a second).
+- Language French (`NOTA_UI_LANGUAGE=fr`): the menu item and the Shortcuts rows read in French.
+
+## 5. Docs (FR-008)
+
+Preferences → Shortcuts → Piano roll lists both gestures; `CHANGELOG.md` `[Unreleased]` has an Added entry; `FEATURES.md` and the user manual's piano-roll page (EN + RU) describe them.
diff --git a/specs/069-velocity-reset-default/research.md b/specs/069-velocity-reset-default/research.md
new file mode 100644
index 00000000..b64911bd
--- /dev/null
+++ b/specs/069-velocity-reset-default/research.md
@@ -0,0 +1,52 @@
+# Research: Reset a note's velocity to the default
+
+## R1. Where the default comes from
+
+**Decision**: one shared constant, `VelocityReset.Default = 0.8f`, in `Nota.Application/Editing`. `PianoRollView.s_lastVel` (the value before any note was touched) and `KeyVelocity` (the playable keys) initialise from it.
+
+**Rationale**: today 0.8 is written in two places (`PianoRollView.cs` lines 241 and 1850). Naming it once keeps "the default a new note gets" and "what the reset restores" from drifting apart. The reset itself never reads `s_lastVel` (spec FR-004).
+
+**Alternatives**: a user setting for the default — out of scope (spec Assumptions); reading `s_lastVel` — rejected, it equals the edited note's velocity right after an edit, so the reset would do nothing.
+
+## R2. What 0.8 is in MIDI terms
+
+**Decision**: store 0.8f as is; the engine converts to 1..127 (≈ 101.6, so 102). A note whose velocity is within half a MIDI step of the default (|v − 0.8| < 0.5/127) counts as already at the default (FR-005: no change, no undo step).
+
+**Rationale**: velocities are floats in the project; comparing exactly would call 0.8000001 "changed". The half-step tolerance matches how the roll shows velocity (`vel N` of 127).
+
+**Alternatives**: exact compare — rejected (spurious undo steps); snapping all velocities to integers — out of scope.
+
+## R3. One undo step for a double-click
+
+**Problem**: a double-click is two presses. Today every press-release in the lane applies the clicked height and calls `CommitNotes()`, one undo step each. A reset on the second press would add a second step, so undo would return to the first click's value, not to the value before the double-click (spec FR-003).
+
+**Decision**: reuse the velocity-wheel burst (specs/063: `_velWheelBurst`, `_velWheelTimer`, `EndVelocityWheel`, `Remember`). A lane gesture opens the burst (arrangement clips: seed the undo step with the notes as they were, `CommitNotes(seed: true)`, then push live; a Session slot: hold and commit when the burst closes). A press closes an open burst first, except the second press of a double-click on the same stem, which continues it. The burst closes after the existing idle time (600 ms) or before any undo/redo/other edit, as the wheel's does, and the `Remember` call keeps "last touched" in step.
+
+**Rationale**: the wheel already solved "several nearby edits are one undo step" including the Session-slot case, and `EndVelocityWheel` is already called before undo and redo.
+
+**Alternatives**:
+- Undo the first click from the lane — the roll has no access to the engine's undo, and a lane that undoes would also undo unrelated steps.
+- Restore the old velocities live, then commit — leaves an extra no-op undo step.
+- Ignore it (undo returns to the first click's value) — a first click lands within a few pixels of the stem's current height, so the drift is small, but it costs a second ⌘Z and breaks the spec; rejected.
+
+**Cost**: a lane drag or click in a Session slot reaches the engine when the burst closes (≤ 600 ms later), as the wheel does there. Arrangement clips push live, so playback follows at once.
+
+## R4. The right-click menu
+
+**Decision**: a `MenuFlyout` with one item, **Reset velocity** (`MenuKit.Item`, `enabled:` false when every target is already at the default), shown on a right-press that lands on a stem (the same `Nearest` pick as a left press). The press also applies the selection rule: a stem outside the selection becomes the selection; a stem inside keeps it. No menu on empty lane space.
+
+**Rationale**: `MenuKit.Item` supports a disabled state (`ClipEditorKit.ShowMenu` does not); the other lane tabs open their "Clear" menu from the right press the same way (`PianoRollView.Expression.cs`).
+
+**Alternatives**: `ClipEditorKit.ShowMenu` — radio-toggle items, no disabled state; a keyboard shortcut — out of scope.
+
+## R5. Testing without a pointer harness
+
+**Decision**: the rule is a pure function, `VelocityReset.Targets(selection, hit, count, isLocked, velocities)` plus `IsDefault`, tested in `VelocityResetTests` (single, selection, outside selection, locked, already default, tolerance, bounds). The lane wiring, the undo count and the menu are checked by hand per the quickstart, and the English / French strings by the existing localization checks.
+
+**Rationale**: the smoke test has no way to inject pointer events into `PianoRollView`; the repository tests such views through pure helpers (`VelocityWheel`, `NoteOverwrite`, `NotePlacementDrag`).
+
+## R6. Docs and strings
+
+**Decision**: new interface text: `Reset velocity` (menu), and two Shortcuts rows — `Double-click a velocity stem`, `Right-click a velocity stem`, each with a description. All through `Loc.T` with entries in `fr.json`. `nota-shortcuts` checks the Shortcuts list; `nota-features` and `nota-docs` cover FEATURES.md and the manual (EN + RU, piano-roll page, `coverage.yml`).
+
+**Rationale**: spec FR-008 and the project's Documentation-in-sync principle.
diff --git a/specs/069-velocity-reset-default/spec.md b/specs/069-velocity-reset-default/spec.md
new file mode 100644
index 00000000..071a5b9b
--- /dev/null
+++ b/specs/069-velocity-reset-default/spec.md
@@ -0,0 +1,121 @@
+# Feature Specification: Reset a note's velocity to the default
+
+**Feature Branch**: `069-velocity-reset-default`
+
+**Created**: 2026-11-01
+
+**Status**: Draft
+
+**Input**: User description: "Piano roll velocity lane: add a way to put a note's velocity back to the default a freshly created note gets. Today the velocity lane (the vertical stem with a cap under each note) only lets you set a value by clicking or dragging; once a velocity is changed there is no way to return to the default. Proposed: double-click a note's stem resets that note, or every selected note when the stem belongs to the selection, to the default velocity 0.8 (about 102 of 127), as one undo step. A right-click on a stem offers the same reset in a menu ("Reset velocity"), like the "Clear" menus of the lane's other tabs. The default stays 0.8 and does not follow the 'last touched note' velocity that newly drawn notes reuse."
+
+## Nota Context
+
+**Feature area**: UI (Avalonia, `src/managed/Nota.App/PianoRollView.cs`, the velocity lane) — managed only, no engine or ABI change.
+
+**Existing behaviour this builds on**:
+
+- The velocity lane under the piano roll draws one stem per note with a small cap. A press on a stem sets the note's velocity where it was clicked (one stem), or moves the whole selection by the drag distance (several); ⇧-click adds a stem to the selection. Nothing resets a velocity.
+- A note drawn on the grid takes the length and velocity of the note last touched (#44). Before any note was touched, that velocity is 0.8. The playable keys also use 0.8.
+- Elsewhere in Nota a double-click puts a control back to its default: device-card knobs, Mosaic's velocity curve, Chord's velocity offset, Velocity's random amount.
+- The lane's other tabs (Bend, Pres, Slide, CC) draw curves with points, where a double-click already adds or removes a point. They have a right-click menu instead: "Clear <tab>" and "Clear All Expression" (the controller tab: "Clear <controller>"), which returns the value to rest (bend 0, pressure 0, slide centred). The velocity lane has no right-click menu.
+- Velocity edits are committed as undo steps through the same path as every other note edit.
+
+**Nota docs to keep in mind**: [`ARCHITECTURE.md`](../../ARCHITECTURE.md), [`CONTRIBUTING.md`](../../CONTRIBUTING.md), [`DESIGN.md`](../../DESIGN.md), [`FEATURES.md`](../../FEATURES.md).
+
+## User Scenarios & Testing
+
+### User Story 1 - Put one velocity back (Priority: P1)
+
+A user has dragged a note's velocity stem somewhere and wants the standard level back. They double-click that stem: the note returns to the default velocity, 0.8 (102 of 127), and the stem, the note's shade and the sound follow. Undo restores the velocity it had before the double-click.
+
+**Why this priority**: it is the whole request — today the only way back is to guess the height by eye.
+
+**Independent Test**: draw a note, drag its stem to the top, double-click the stem; the stem sits at the default height, and ⌘Z brings the stem back to the top in one step.
+
+**Acceptance Scenarios**:
+
+1. **Given** a note at any velocity, **When** the user double-clicks its stem in the velocity lane, **Then** its velocity becomes 0.8.
+2. **Given** a note already at 0.8, **When** the user double-clicks its stem, **Then** nothing changes and no undo step is added.
+3. **Given** a reset, **When** the user undoes once, **Then** the note has the velocity it had before the double-click.
+
+---
+
+### User Story 2 - Put a selection back (Priority: P2)
+
+With several notes selected, double-clicking the stem of one of them resets all selected notes to 0.8 at once, so a whole phrase that was shaped by hand can be flattened to the default level in one gesture.
+
+**Why this priority**: the lane already moves a selection as a group; resetting should follow the same rule, but a single note is the common case.
+
+**Independent Test**: select three notes with different velocities, double-click one of the three stems; all three read 0.8 and one undo restores all three.
+
+**Acceptance Scenarios**:
+
+1. **Given** a selection of several notes, **When** the user double-clicks the stem of a selected note, **Then** every selected note goes to 0.8, as one undo step.
+2. **Given** a selection, **When** the user double-clicks the stem of a note outside it, **Then** only that note is reset and the selection becomes that note, as a click on the stem already does.
+
+---
+
+### User Story 3 - Reset from a menu (Priority: P2)
+
+A user who prefers a menu, or who does not know the double-click, right-clicks a stem in the velocity lane and chooses **Reset velocity**. It does the same as the double-click: the note under the pointer, or every selected note when it belongs to the selection, goes to 0.8, in one undo step. This is the same gesture as the lane's other tabs, where a right-click offers "Clear".
+
+**Why this priority**: it makes the reset findable without reading anything and keeps the lane consistent across its tabs.
+
+**Independent Test**: right-click a stem; a menu offers **Reset velocity**; choosing it sets the note to 0.8 and one undo restores it.
+
+**Acceptance Scenarios**:
+
+1. **Given** a note at any velocity other than the default, **When** the user right-clicks its stem and chooses **Reset velocity**, **Then** its velocity becomes 0.8.
+2. **Given** a selection, **When** the user right-clicks the stem of a selected note and chooses **Reset velocity**, **Then** every selected note goes to 0.8 in one undo step.
+3. **Given** a right-click on empty space in the lane, **When** the menu would open, **Then** no menu opens.
+4. **Given** every note it would reset is already at 0.8, **When** the menu opens, **Then** **Reset velocity** is shown disabled.
+
+---
+
+### User Story 4 - The reset is documented (Priority: P3)
+
+Preferences → Shortcuts lists the double-click and the right-click on a velocity stem, and the user manual's piano-roll page describes them, so the gesture can be learned without trying things at random.
+
+**Why this priority**: the double-click has no visible control, so it depends on being written down.
+
+**Independent Test**: open Preferences → Shortcuts → Piano roll; a row describes the double-click on a velocity stem, and one describes the right-click, in English and in French.
+
+**Acceptance Scenarios**:
+
+1. **Given** Preferences → Shortcuts, **When** the user reads the Piano roll group, **Then** rows name the double-click and the right-click on a velocity stem and what they do.
+
+### Edge Cases
+
+- A double-click is two presses. The first press still sets the velocity where it landed, as it does today; the double-click then overrides it. One undo after the double-click returns to the velocity from before the double-click, not to the value the first press produced.
+- A press within a few pixels of a stem's cap grabs it: the stem moves with the pointer from where it is instead of jumping to the pixel clicked (a click farther from the cap still sets the height where it landed, as before). So a double-click on a note already at the default changes nothing and adds no undo step.
+- A double-click on empty space in the lane (no stem within reach) does nothing, as a single click does today.
+- Stems of a locked reference clip, or ghost notes, are not on offer in the lane and are not reset.
+- Notes that start together share one x position; the stem picked for the double-click is the same one a single click would pick.
+- The other lane tabs (Bend, Pres, Slide, CC) are untouched: their double-click still adds or removes a point, and their right-click menus are unchanged. The new gestures apply to the Vel tab only.
+- Drum Rack and folded views use the same lane and behave the same way.
+- A velocity edit made while the clip plays follows the live path: the reset is heard on the next note, with no glitch.
+
+## Requirements
+
+- **FR-001**: A double-click on a note's stem in the piano roll's velocity lane sets that note's velocity to the default, 0.8 (102 of 127).
+- **FR-002**: When the stem belongs to the selection, every selected note is reset; otherwise only that note is, and it becomes the selection.
+- **FR-003**: The reset is one undo step that returns every affected note to the velocity it had before the double-click, including when the first press of the double-click had already changed one.
+- **FR-004**: The default is a fixed value, independent of the "last touched note" velocity that newly drawn notes reuse. After a reset, that last-touched value is the default, like after any velocity edit.
+- **FR-005**: A note already at the default is left as it is and adds no undo step.
+- **FR-006**: A right-click on a note's stem in the velocity lane opens a menu with one item, **Reset velocity**, that does what the double-click does (FR-001 to FR-005, same note-or-selection rule, same undo behaviour). The item is disabled when every note it would reset is already at the default. A right-click on empty space opens no menu.
+- **FR-007**: Locked and ghost notes are never reset; the other lane tabs and the note grid are unaffected.
+- **FR-008**: Preferences → Shortcuts lists both gestures in the Piano roll group, FEATURES.md and the user manual (EN and RU) describe it, `CHANGELOG.md` `[Unreleased]` has an Added entry, and all new interface text goes through `Loc` with an English key and a French translation.
+
+## Success Criteria
+
+- **SC-001**: A user can put any note's velocity back to the default with one double-click, or with a right-click and one menu choice, with no typing.
+- **SC-002**: After a reset on any number of selected notes, a single undo restores all of them.
+- **SC-003**: The smoke test covers the reset (single note, selection, already-default, undo, the menu item and its disabled state), and `scripts/build.sh` passes, including the localization checks.
+
+## Assumptions
+
+- "The default" is 0.8, the value a first-ever drawn note and the playable keys already use; it is not a user setting in this feature. A setting could follow if users ask for another default.
+- The gestures are the double-click, matching the rest of Nota, and a right-click menu, matching the lane's other tabs. No new keyboard shortcut is added.
+- The Drum pattern editor (a separate step grid with its own accent levels) is out of scope.
+- The other tabs (Bend, Pres, Slide, CC) already return to rest through their "Clear" menus, and their double-click is taken by adding or removing points, so they are not changed.
+- The French wording of the new Shortcuts row follows the glossary of specs/068-ui-language.
diff --git a/specs/069-velocity-reset-default/tasks.md b/specs/069-velocity-reset-default/tasks.md
new file mode 100644
index 00000000..80f193f9
--- /dev/null
+++ b/specs/069-velocity-reset-default/tasks.md
@@ -0,0 +1,85 @@
+# Tasks: Reset a note's velocity to the default
+
+**Input**: [spec.md](spec.md), [plan.md](plan.md), [research.md](research.md), [data-model.md](data-model.md), [contracts/velocity-lane.md](contracts/velocity-lane.md)
+
+**Tests**: the pure rule gets smoke checks (spec SC-003). The lane's pointer wiring has no headless harness; it is checked by hand from [quickstart.md](quickstart.md).
+
+**Format**: `[ID] [P?] [Story] Description`. Paths are from the repo root.
+
+## Phase 1: Setup
+
+- [X] T001 Branch `feat/velocity-reset-default` from `develop` (done with the spec); confirm `scripts/build.sh` is green before the first edit (baseline).
+
+## Phase 2: Foundational (blocks every story)
+
+- [X] T002 Create `src/managed/Nota.Application/Editing/VelocityReset.cs` (SPDX header, comment header saying why it exists, namespace `Nota.Application.Editing`): `public const float Default = 0.8f;` `IsDefault(float v)` true when `|v − Default| < 0.5 / 127`; `Targets(IReadOnlyCollection<int> selection, int hit, int count, Func<int,bool> isLocked, IReadOnlyList<float> velocities)` returning the indices to reset: the selection's unlocked notes when `hit` is in it, else `{hit}`; locked and out-of-range indices excluded; notes already at the default excluded (data-model: "Reset targets"). The view writes `Default` itself; there is no `Apply`.
+- [X] T003 [P] Create `tests/Nota.SmokeTest/VelocityResetTests.cs` with `public static IEnumerable<(bool Ok, string Label)> Run()` in the style of `VelocityWheelTests.cs`: default is 0.8; stem outside the selection → only that note; stem inside → every selected note; a locked note is never a target; a note at 0.8 and one within half a MIDI step of it are not targets (nothing to do → empty); a note one MIDI step away is a target; out-of-range indices are dropped. Register it in `tests/Nota.SmokeTest/Program.cs` at both places `VelocityWheelTests.Run()` is called (the full run and the `--` alone run, lines ≈308 and ≈15323).
+- [X] T004 Make the default single-sourced in `src/managed/Nota.App/PianoRollView.cs`: `s_lastVel` starts at `VelocityReset.Default` (line ≈241) and `KeyVelocity` (line ≈1850) reads it; update the comment above `s_lastVel` ("0.8") to point at the constant.
+
+**Checkpoint**: `dotnet run --project tests/Nota.SmokeTest -c Release -- --velocity-reset` (add the alone-run flag next to the others in `Program.cs`) passes.
+
+## Phase 3: User Story 1 — Put one velocity back (P1) 🎯 MVP
+
+**Goal**: double-click a stem → that note goes to 0.8; one ⌘Z returns to the value before the double-click.
+
+**Independent test**: quickstart §2, steps 1–3, 6, 7.
+
+- [X] T005 [US1] In `PianoRollView.VelocityLane.OnPointerPressed` (`src/managed/Nota.App/PianoRollView.cs`, ≈line 2815): stop closing the burst unconditionally. Close it (`_o.EndVelocityWheel()`) unless this is the second press of a double-click (`e.ClickCount == 2`) on the same stem as the open lane burst; remember that stem when a lane gesture opens the burst.
+- [X] T006 [US1] Make the lane's click/drag a velocity burst (research R3): on the first press of a gesture, open `_velWheelBurst` and, when `HasLivePath`, seed the undo step with `CommitNotes(_notes.ToList(), _owner.ToList(), seed: true)` before `Apply`; push changes with `PushLive` instead of committing at release when `HasLivePath`; a Session slot (no live path) keeps its notes in the view and commits when the burst closes (`EndVelocityWheel` already does). Restart `_velWheelTimer` on release (extract the timer start from `WheelVelocity` into a small `RestartVelocityBurstTimer()` and call it from both). Set `_velWheelNote = _velNote` so `Remember` runs at close. `OnPointerReleased` no longer calls `CommitNotes()` itself.
+- [X] T007 [US1] On `ClickCount == 2` (after T005's guard): compute `VelocityReset.Targets(...)` for the hit stem, set each target's velocity to `VelocityReset.Default`, `PushLive`/hold as T006, `Invalidate()`, `Changed?.Invoke()`; no targets → do nothing (no seed, no step). Keep the burst open; do not start a drag for the second press (`_drag = false`).
+- [X] T008 [US1] Verify by hand (quickstart §2 steps 1–3, 6, 7; §4 playing loop and locked clip). Fix what the pass finds.
+
+**Checkpoint**: a single note resets with one double-click and one undo.
+
+## Phase 4: User Story 2 — Put a selection back (P2)
+
+**Goal**: the stem of a selected note resets the whole selection; a stem outside the selection resets only itself and becomes the selection.
+
+**Independent test**: quickstart §2 steps 4–5.
+
+- [X] T009 [US2] In the double-click branch of T007, apply the selection rule from `VelocityReset.Targets` (selected stem → whole selection kept; other stem → `_selection.Clear(); _selection.Add(hit)` as a single press already does, after `SettlePlacement()` as the existing press code does). Do not let the first press's group-drag state (`_grabbed`) carry into the reset.
+- [X] T010 [US2] Verify by hand (quickstart §2 steps 4–5): both notes at 0.8 after one double-click; one ⌘Z restores both; the unselected stem case moves the selection.
+
+## Phase 5: User Story 3 — Reset from a menu (P2)
+
+**Goal**: right-click a stem → **Reset velocity**.
+
+**Independent test**: quickstart §3.
+
+- [X] T011 [US3] In `VelocityLane`, handle the right press: pick the stem with `Nearest`, none → return (no menu); apply the selection rule of T009; open a `MenuFlyout` with `MenuKit.Item(Loc.T("Reset velocity"), click: …, enabled: targets.Count > 0)` anchored on the lane (pattern: `PianoRollView.Expression.cs` `ShowClearMenu`, but with `MenuKit.Item` for the disabled state). The click handler runs the same reset path as T007 as its own burst (open, seed, apply, close at once: `EndVelocityWheel()`).
+- [X] T012 [P] [US3] Add the French entry for `Reset velocity` to `src/managed/Nota.App/Languages/fr.json` (`Réinitialiser la vélocité`).
+- [X] T013 [US3] Verify by hand (quickstart §3) including: the Pres / Bend tabs keep their own menus; English and French (`NOTA_UI_LANGUAGE=fr`).
+
+## Phase 6: User Story 4 — Documented (P3)
+
+**Goal**: the gestures are findable.
+
+- [X] T014 [US4] Run the `nota-shortcuts` skill. In `src/managed/Nota.App/PreferencesWindow.cs` (Piano roll group, next to `Drag velocity stem`, ≈line 1529) add two rows: `Double-click a velocity stem` → `Put the note back to the default velocity (0.8) · the whole selection's when the note is selected`; `Right-click a velocity stem` → `Reset velocity from a menu`. Add both rows' texts to `fr.json` (T014 and T012 may share one edit pass). Check the pane on screen at 100 % in English and French.
+- [X] T015 [P] [US4] `CHANGELOG.md` `[Unreleased]` Added entry (user-facing, in the file's voice); run the `nota-features` skill for `FEATURES.md` (the Piano Roll bullet list: add the reset next to the velocity stem line).
+- [X] T016 [P] [US4] Run the `nota-docs` skill: piano-roll page of the user manual in `../nota-docs`, EN + RU, plus `coverage.yml` (sources: `PianoRollView.cs`, `VelocityReset.cs`); `npm run build && npm run check` there. A separate PR in that repo. Also: `scripts/shortcuts.mjs` could not read the app's Shortcuts list since the strings went through `Loc.T`; it now reads through the wrapper and `npm run shortcuts` regenerates `reference/shortcuts` (EN + RU), which had drifted from the app.
+
+## Phase 7: Polish and gate
+
+- [X] T017 `scripts/build.sh` green (macOS; run it with `MSBUILDDISABLENODEREUSE=1 DOTNET_CLI_USE_MSBUILD_SERVER=0` and an idle machine — the two "overloaded" timing checks are load-sensitive).
+- [X] T018 `/speckit-converge` reports Converged; tick the boxes above.
+- [ ] T019 Take before/after screenshots of the lane (the menu open on a stem, English) for the PR description, crop to the window; open the PR with the `nota-pr` skill (branch off `develop`, `(feat) …`, your noreply email, no AI trailer); the docs PR follows.
+
+## Dependencies
+
+- T001 → T002 → T003, T004 (T003 and T004 are independent files).
+- US1 (T005–T008) needs T002 and T004. US2 (T009–T010) needs US1. US3 (T011–T013) needs T006's burst helpers and T002. US4 (T014–T016) can start once the gesture texts are fixed (after T011).
+- Polish needs everything above.
+
+## Parallel opportunities
+
+- T003 ∥ T004 (different files).
+- T012 ∥ T011 once the key text is fixed; T015 ∥ T016.
+
+## Implementation strategy
+
+MVP = Phase 2 + User Story 1: a working double-click on one stem with one undo step, shippable on its own. Add the selection rule (US2), the menu (US3), then the docs (US4); the PR can carry all four since they are one small feature in one file plus a helper.
+
+## Phase 8: Convergence
+
+- [X] T020 Leave tool-preview (ghost) notes out of the reset: in `src/managed/Nota.App/PianoRollView.cs` `VelocityLane.ResetVelocity` and `CanReset`, pass `i => _o.IsLocked(i) || _o.IsGhost(i)` instead of `_o.IsLocked` to `VelocityReset.Targets`, per FR-007 and the Edge Cases ("ghost notes … are not reset") (partial)
+- [X] T021 Review follow-up (nota-daw/nota#418): a press within 6 px of a stem's cap is a grab, not a set (`VelocityLane._grabCap` in `src/managed/Nota.App/PianoRollView.cs`), so a double-click on a note at the default adds no undo step, per FR-003 and FR-005 (partial); `VelocityReset.Targets` tracks duplicates in a `HashSet` instead of scanning the result list.
diff --git a/src/managed/Nota.App/Languages/fr.json b/src/managed/Nota.App/Languages/fr.json
index 49c15b9b..0aa3ebda 100644
--- a/src/managed/Nota.App/Languages/fr.json
+++ b/src/managed/Nota.App/Languages/fr.json
@@ -560,6 +560,11 @@
"Drag the playhead line": "Glisser la ligne de la tête de lecture",
"Scrub the playhead · on the ruler or over empty grid": "Balayer avec la tête de lecture · sur la règle ou sur la grille vide",
"Drag velocity stem": "Glisser une tige de vélocité",
+ "Double-click velocity stem": "Double-clic sur une tige de vélocité",
+ "Put the note back to the default velocity (0.8) · the whole selection's when the note is selected · undo is one step": "Remettre la note à la vélocité par défaut (0,8) · toute la sélection si la note est sélectionnée · l’annulation se fait en une seule étape",
+ "Right-click velocity stem": "Clic droit sur une tige de vélocité",
+ "Reset velocity from a menu · same as the double-click": "Réinitialiser la vélocité depuis un menu · comme le double-clic",
+ "Reset velocity": "Réinitialiser la vélocité",
"Set velocity · selected notes move together · ⇧ adds a note": "Régler la vélocité · les notes sélectionnées bougent ensemble · ⇧ ajoute une note",
"Drag in the Bend / Pres / Slide lane": "Glisser dans le couloir Bend / Pres / Slide",
"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",
diff --git a/src/managed/Nota.App/PianoRollView.cs b/src/managed/Nota.App/PianoRollView.cs
index 611d5e2b..707ef97d 100644
--- a/src/managed/Nota.App/PianoRollView.cs
+++ b/src/managed/Nota.App/PianoRollView.cs
@@ -236,9 +236,9 @@ public sealed partial class PianoRollView : UserControl
// The last note touched — clicked, moved, resized or its velocity drawn — in any clip (#44):
// a new note takes its length and velocity. Before any is touched, a new note is one grid
- // step at 0.8.
+ // step at VelocityReset.Default (0.8).
private static double s_lastLen = double.NaN;
- private static float s_lastVel = 0.8f;
+ private static float s_lastVel = VelocityReset.Default;
private void Remember(int i)
{
if (i < 0 || i >= _notes.Count) return;
@@ -1472,6 +1472,14 @@ public sealed partial class PianoRollView : UserControl
Invalidate(); Changed?.Invoke();
}
}
+ RestartVelocityBurstTimer();
+ return true;
+ }
+
+ // The burst closes after this much quiet: the wheel's, and the velocity lane's (a double-click
+ // on a stem is one burst, so one undo step, specs/069).
+ private void RestartVelocityBurstTimer()
+ {
if (_velWheelTimer is null)
{
_velWheelTimer = new DispatcherTimer { Interval = VelocityWheelIdle };
@@ -1479,7 +1487,6 @@ public sealed partial class PianoRollView : UserControl
}
_velWheelTimer.Stop();
_velWheelTimer.Start();
- return true;
}
/// <summary>Closes the open velocity burst. A Session slot commits it (one undo step);
@@ -1876,7 +1883,7 @@ public sealed partial class PianoRollView : UserControl
private double _pressY, _pressRowH;
private int PitchAt(double y) => _o.PitchAtY(y);
- private const float KeyVelocity = 0.8f;
+ private const float KeyVelocity = VelocityReset.Default;
// The label mode (C-only vs. every note) is app-wide: follow it while on
// screen only — a roll is rebuilt for every clip, so a lasting subscription would leak.
@@ -2856,31 +2863,149 @@ public sealed partial class PianoRollView : UserControl
// selected note with it, each keeping its offset (so a stacked chord moves together).
private readonly Dictionary<int, float> _grabbed = new();
private double _grabY;
+ // A press within a few pixels of the cap is a grab: the stem moves with the pointer from
+ // where it is, it does not jump to the pixel clicked. A click on a note already at the
+ // default therefore changes nothing, and the double-click that follows adds no undo step.
+ private const double CapGrab = 6;
+ private bool _grabCap;
- protected override void OnPointerPressed(PointerPressedEventArgs e)
+ // A lane gesture is a velocity burst (the wheel's, specs/063): its first real change seeds
+ // the undo step with the notes as they were, then streams live; the burst stays open for
+ // the idle time after the release, so the second click of a double-click joins the same
+ // step. A Session slot has no live path: it holds the change and commits when the burst
+ // closes. A click that changes nothing opens nothing, so it adds no undo step.
+ private List<NotaNote>? _pre;
+ private List<int>? _preOwner;
+ private int _burstStem = -1;
+
+ // A reference clip's notes and a tool preview's ghost notes are not on offer to a reset.
+ private bool NotOnOffer(int i) => _o.IsLocked(i) || _o.IsGhost(i);
+
+ private void Snapshot() { _pre = _o._notes.ToList(); _preOwner = _o._owner.ToList(); }
+
+ private void OpenBurst()
+ {
+ if (_o._velWheelBurst) return;
+ _o._velWheelBurst = true;
+ if (_o.HasLivePath) _o.CommitNotes(_pre ?? _o._notes.ToList(), _preOwner ?? _o._owner.ToList(), seed: true);
+ }
+
+ private void StreamLive()
+ {
+ if (_o.HasLivePath && _o._velWheelBurst) _o.PushLive(_o._notes, _o._owner);
+ }
+
+ // The stem a press landed on, with the selection it makes: a stem outside the selection
+ // becomes the selection (a pending placement lets go first, which can shift indices, so
+ // the stem is found again); ⇧ adds it. -1 when nothing is within reach.
+ private int Pick(Point p, bool shift)
{
- if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
- _o.EndVelocityWheel(); // a press starts a new edit: close the wheel's burst first
- var p = e.GetPosition(this);
int hit = Nearest(p);
- if (hit < 0) return;
- bool shift = (e.KeyModifiers & KeyModifiers.Shift) != 0;
- // The lane never takes focus, so a stem that changes the selection lets a pending
- // placement go here; settling can shift indices, so find the stem again.
+ if (hit < 0) return -1;
if ((shift || !_o._selection.Contains(hit)) && _o.SettlePlacement())
{
hit = Nearest(p);
- if (hit < 0) return;
+ if (hit < 0) return -1;
}
if (shift) _o._selection.Add(hit);
else if (!_o._selection.Contains(hit)) { _o._selection.Clear(); _o._selection.Add(hit); }
+ return hit;
+ }
+
+ /// <summary>Puts the note under <paramref name="hit"/> — or the whole selection, when it
+ /// is in it — back to the default velocity (specs/069). False when every target is
+ /// already there: nothing changes, no undo step.</summary>
+ private bool ResetVelocity(int hit)
+ {
+ var vels = new List<float>(_o._notes.Count);
+ foreach (var n in _o._notes) vels.Add(n.Velocity);
+ var targets = VelocityReset.Targets(_o._selection, hit, vels, NotOnOffer);
+ if (targets.Count == 0) return false;
+ OpenBurst();
+ foreach (int i in targets)
+ {
+ var n = _o._notes[i];
+ n.Velocity = VelocityReset.Default;
+ _o._notes[i] = n;
+ }
+ _o._velWheelNote = hit;
+ StreamLive();
+ _o.Remember(hit);
+ _o.Invalidate(); _o.Changed?.Invoke();
+ _o.RestartVelocityBurstTimer();
+ return true;
+ }
+
+ /// <summary>Whether a reset on this stem would change anything (the menu item's state).</summary>
+ private bool CanReset(int hit)
+ {
+ var vels = new List<float>(_o._notes.Count);
+ foreach (var n in _o._notes) vels.Add(n.Velocity);
+ return VelocityReset.Targets(_o._selection, hit, vels, NotOnOffer).Count > 0;
+ }
+
+ private void ShowResetMenu(int hit)
+ {
+ var flyout = new MenuFlyout();
+ flyout.Items.Add(MenuKit.Item(Loc.T("Reset velocity"), click: () =>
+ {
+ _o.EndVelocityWheel(); // its own step, apart from anything just before it
+ Snapshot();
+ ResetVelocity(hit);
+ _o.EndVelocityWheel();
+ }, enabled: CanReset(hit)));
+ flyout.ShowAt(this);
+ }
+
+ protected override void OnPointerPressed(PointerPressedEventArgs e)
+ {
+ var props = e.GetCurrentPoint(this).Properties;
+ bool left = props.IsLeftButtonPressed, right = props.IsRightButtonPressed;
+ if (!left && !right) return;
+ var p = e.GetPosition(this);
+ bool shift = (e.KeyModifiers & KeyModifiers.Shift) != 0;
+
+ // The second press of a double-click on the stem whose burst is still open continues
+ // that burst; any other press starts a new edit, so the open burst closes first.
+ int near = Nearest(p);
+ bool again = left && e.ClickCount >= 2 && near >= 0 && near == _burstStem
+ && _o._velWheelBurst && _o._velWheelNote == near;
+ if (!again) _o.EndVelocityWheel();
+ if (near < 0) return;
+
+ int hit = Pick(p, left && shift);
+ if (hit < 0) return;
+ if (!again) Snapshot();
+
+ if (right)
+ {
+ _o.Invalidate(); _o.Changed?.Invoke();
+ ShowResetMenu(hit);
+ e.Handled = true;
+ return;
+ }
+
+ _burstStem = hit;
+ if (e.ClickCount >= 2)
+ {
+ // A double-click puts the note — or the selection — back to the default. The first
+ // click already set the height it landed on; this overrides it in the same step.
+ _drag = false; _grabbed.Clear();
+ ResetVelocity(hit);
+ _o.Invalidate(); _o.Changed?.Invoke();
+ e.Handled = true;
+ return;
+ }
+
_grabbed.Clear();
foreach (int i in _o._selection)
if (i >= 0 && i < _o._notes.Count) _grabbed[i] = _o._notes[i].Velocity;
_velNote = hit; _drag = true;
- // A click on one stem sets it where you clicked; a group moves by the drag distance.
- if (_grabbed.Count == 1) Apply(p.Y);
+ _grabCap = Math.Abs(CapY(hit) - p.Y) <= CapGrab;
_grabY = p.Y;
+ // A click on one stem away from its cap sets it where you clicked; a group, or a grab on
+ // the cap, moves by the drag distance.
+ if (_grabbed.Count == 1 && !_grabCap) Apply(p.Y);
e.Pointer.Capture(this);
_o.Invalidate(); _o.Changed?.Invoke();
e.Handled = true;
@@ -2904,20 +3029,35 @@ public sealed partial class PianoRollView : UserControl
if (!_drag) return;
_drag = false; _grabbed.Clear(); e.Pointer.Capture(null);
_o.Remember(_velNote);
- _o.CommitNotes(); _o.Changed?.Invoke();
+ // The burst (when the gesture changed anything) stays open for the double-click's
+ // second click; the idle timer, an undo or the next edit closes it.
+ if (_o._velWheelBurst) { _o._velWheelNote = _velNote; _o.RestartVelocityBurstTimer(); }
+ _o.Changed?.Invoke();
}
private void Apply(double y)
{
- if (_grabbed.Count == 1)
+ if (_grabbed.Count == 1 && !_grabCap)
{
if (_velNote < 0 || _velNote >= _o._notes.Count) return;
var n = _o._notes[_velNote];
- n.Velocity = (float)Math.Clamp((Bounds.Height - y) / Usable, 0.02, 1.0);
+ float v = (float)Math.Clamp((Bounds.Height - y) / Usable, 0.02, 1.0);
+ if (v == n.Velocity) return;
+ OpenBurst();
+ n.Velocity = v;
_o._notes[_velNote] = n;
+ StreamLive();
return;
}
float d = (float)((_grabY - y) / Usable);
+ bool changed = false;
+ foreach (var (i, v0) in _grabbed)
+ {
+ if (i < 0 || i >= _o._notes.Count) continue;
+ if (Math.Clamp(v0 + d, 0.02f, 1f) != _o._notes[i].Velocity) { changed = true; break; }
+ }
+ if (!changed) return;
+ OpenBurst();
foreach (var (i, v0) in _grabbed)
{
if (i < 0 || i >= _o._notes.Count) continue;
@@ -2925,6 +3065,7 @@ public sealed partial class PianoRollView : UserControl
n.Velocity = Math.Clamp(v0 + d, 0.02f, 1f);
_o._notes[i] = n;
}
+ StreamLive();
}
}
}
diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.cs
index a00043b2..e998f8e6 100644
--- a/src/managed/Nota.App/PreferencesWindow.cs
+++ b/src/managed/Nota.App/PreferencesWindow.cs
@@ -1526,6 +1526,8 @@ public sealed partial class PreferencesWindow : NotaWindow
(Loc.T("Click · drag the ruler"), Loc.T("Move the playhead there · drag to scrub, snapped to the grid · ⌥ off the grid")),
(Loc.T("Drag the playhead line"), Loc.T("Scrub the playhead · on the ruler or over empty grid")),
(Loc.T("Drag velocity stem"), Loc.T("Set velocity · selected notes move together · ⇧ adds a note")),
+ (Loc.T("Double-click velocity stem"), Loc.T("Put the note back to the default velocity (0.8) · the whole selection's when the note is selected · undo is one step")),
+ (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 controller tab"), Loc.T("Show a MIDI controller under the notes · click it again to pick another CC, the pitch wheel or channel pressure")),
diff --git a/src/managed/Nota.Application/Editing/VelocityReset.cs b/src/managed/Nota.Application/Editing/VelocityReset.cs
new file mode 100644
index 00000000..8aad6bf3
--- /dev/null
+++ b/src/managed/Nota.Application/Editing/VelocityReset.cs
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Putting a note's velocity back to the default in the piano roll's velocity lane (specs/069):
+// a double-click on a stem, or Reset velocity in its right-click menu. This is the one place
+// that says what the default is and which notes a reset touches; the lane only handles the
+// pointer and the undo timing. The default is fixed: it is not the "last touched" velocity a
+// newly drawn note reuses, or the reset would do nothing right after an edit.
+
+using System;
+using System.Collections.Generic;
+
+namespace Nota.Application.Editing;
+
+public static class VelocityReset
+{
+ /// <summary>The velocity a freshly created note gets before any note was touched, and the
+ /// one the playable keys use: 0.8, about 102 of 127.</summary>
+ public const float Default = 0.8f;
+
+ // Half a MIDI step: velocities closer than this are the same velocity to the user.
+ private const float Tolerance = 0.5f / 127f;
+
+ /// <summary>Whether a velocity already is the default, to within half a MIDI step.</summary>
+ public static bool IsDefault(float velocity) => MathF.Abs(velocity - Default) < Tolerance;
+
+ /// <summary>The notes a reset on the stem of note <paramref name="hit"/> changes: every
+ /// selected note when the stem belongs to the selection, else that note alone. Locked notes
+ /// (a reference clip's) and notes already at the default are left out; so is anything out of
+ /// range. Empty means there is nothing to do, so no undo step and a disabled menu item.</summary>
+ public static List<int> Targets(IReadOnlyCollection<int> selection, int hit,
+ IReadOnlyList<float> velocities, Func<int, bool> isLocked)
+ {
+ var picked = new List<int>();
+ if (hit < 0 || hit >= velocities.Count) return picked;
+ IEnumerable<int> candidates = selection.Contains(hit) ? selection : new[] { hit };
+ var seen = new HashSet<int>();
+ foreach (int i in candidates)
+ if (i >= 0 && i < velocities.Count && !isLocked(i) && !IsDefault(velocities[i]) && seen.Add(i))
+ picked.Add(i);
+ picked.Sort();
+ return picked;
+ }
+}
diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.cs
index 7bdadd00..0c7e3a66 100644
--- a/tests/Nota.SmokeTest/Program.cs
+++ b/tests/Nota.SmokeTest/Program.cs
@@ -316,6 +316,14 @@ if (args.Length >= 1 && args[0] == "--velocity-wheel")
Console.WriteLine(failures == 0 ? "VELOCITY WHEEL PASSED" : $"VELOCITY WHEEL FAILED ({failures})");
return failures == 0 ? 0 : 1;
}
+// Piano-roll velocity reset alone: `--velocity-reset`. Also part of the full run.
+if (args.Length >= 1 && args[0] == "--velocity-reset")
+{
+ Console.WriteLine("-- velocity reset --");
+ foreach (var (ok, label) in VelocityResetTests.Run()) Check(ok, label);
+ Console.WriteLine(failures == 0 ? "VELOCITY RESET PASSED" : $"VELOCITY RESET 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")
{
@@ -15400,6 +15408,8 @@ foreach (var (ok, label) in TransportDisplayTests.Run()) Check(ok, label);
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("-- status bar audio format --");
foreach (var (ok, label) in AudioFormatStatusTests.Run()) Check(ok, label);
diff --git a/tests/Nota.SmokeTest/VelocityResetTests.cs b/tests/Nota.SmokeTest/VelocityResetTests.cs
new file mode 100644
index 00000000..622b224e
--- /dev/null
+++ b/tests/Nota.SmokeTest/VelocityResetTests.cs
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Reset velocity in the piano roll's velocity lane (specs/069): the default, what counts as
+// already at it, and which notes a reset on a stem changes.
+// Also runnable alone: `dotnet run --project tests/Nota.SmokeTest -- --velocity-reset`.
+
+using Nota.Application.Editing;
+
+namespace Nota.SmokeTest;
+
+internal static class VelocityResetTests
+{
+ private static string Show(IEnumerable<int> t) => string.Join(",", t);
+
+ public static IEnumerable<(bool Ok, string Label)> Run()
+ {
+ yield return (VelocityReset.Default == 0.8f, "the default velocity is 0.8");
+ yield return (VelocityReset.IsDefault(0.8f), "0.8 is the default");
+ yield return (VelocityReset.IsDefault(0.8f + 0.003f) && VelocityReset.IsDefault(0.8f - 0.003f),
+ "within half a MIDI step of 0.8 counts as the default");
+ yield return (!VelocityReset.IsDefault(0.8f + 1f / 127f) && !VelocityReset.IsDefault(0.8f - 1f / 127f),
+ "one MIDI step away from 0.8 is not the default");
+
+ var vel = new List<float> { 0.2f, 0.5f, 0.8f, 1f, 0.05f };
+ static bool None(int _) => false;
+ var sel = new HashSet<int> { 0, 1, 2 };
+
+ yield return (Show(VelocityReset.Targets(new HashSet<int>(), 1, vel, None)) == "1",
+ "a stem with nothing selected resets that note only");
+ yield return (Show(VelocityReset.Targets(sel, 1, vel, None)) == "0,1",
+ "a stem in the selection resets every selected note not already at the default");
+ yield return (Show(VelocityReset.Targets(sel, 3, vel, None)) == "3",
+ "a stem outside the selection resets that note only");
+ yield return (VelocityReset.Targets(sel, 2, vel, None).Count == 2
+ && !VelocityReset.Targets(sel, 2, vel, None).Contains(2),
+ "a selected note already at the default is left out");
+ yield return (VelocityReset.Targets(new HashSet<int>(), 2, vel, None).Count == 0,
+ "a note already at the default is not a target: nothing to do, no undo step");
+ yield return (Show(VelocityReset.Targets(sel, 0, vel, i => i == 1)) == "0",
+ "a locked note is never a target, even inside the selection");
+ yield return (VelocityReset.Targets(new HashSet<int>(), 0, vel, i => i == 0).Count == 0,
+ "a locked stem resets nothing");
+ yield return (VelocityReset.Targets(sel, -1, vel, None).Count == 0
+ && VelocityReset.Targets(sel, 99, vel, None).Count == 0,
+ "a stem index out of range resets nothing");
+ yield return (Show(VelocityReset.Targets(new HashSet<int> { 0, 9, -3 }, 0, vel, None)) == "0",
+ "selection indices out of range are dropped");
+ yield return (VelocityReset.Targets(new HashSet<int> { 4 }, 4, vel, None).Count == 1,
+ "a very quiet note is a target");
+ }
+}