Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
C# audioaudio-unitavaloniacpp20cross-platformdawdigital-audio-workstationdspjucelinux-audiomcp-servermidimusicmusic-productionpiano-rollplugin-hostsequencersynthesizervstvst3
(fix) Curved automation eases instead of jumping, short clips keep their name on one line, plug-in cards show the plug-in's window again (#590, #591) (#594)
Egor Khindikaynenf90a639a2413
diff --git a/.specify/bugs/automation-curve-step/assessment.md b/.specify/bugs/automation-curve-step/assessment.mdnew file mode 100644index 00000000..57312ff3--- /dev/null+++ b/.specify/bugs/automation-curve-step/assessment.md@@ -0,0 +1,83 @@+# Bug Assessment: Curved automation segments jump almost instantly (ease-out is a near-step)++- **Slug**: automation-curve-step+- **Created**: 2026-11-12+- **Source**: https://github.com/nota-daw/nota/issues/591 (host: github.com, allowlisted; written by the reporter in this session)+- **Verdict**: valid+- **Severity**: medium++## Report (verbatim or summarized)++After bending an automation segment, the ease-out direction draws as a near-vertical drop then+a flat line, and playback jumps the same way. Ease-in looks smooth. Expected: both directions+smooth and mirror-symmetric, no jump at either end.++## Symptom++A bent segment with positive curve reaches almost its whole change at the very start of the+segment — audibly a step — while a negative curve looks fine.++## Reproduction++1. Add an automation lane (track volume) with points low → high → low.+2. Drag the middle of the falling segment to bend it.+3. The segment drops vertically right after the peak, then stays flat; playback matches.++## Suspected Code Paths++- `src/native/nota.engine/src/engine/Automation.h:52` — `AutomationLane::shape`: `t^e`,+ `e = 2^(−4·curve)` ∈ [1/16, 16]. Used by every lane, clip envelope and controller curve.+- Managed mirrors: `ArrangementView.cs:3564` (`Shape`), `ClipEditorView.cs:398`,+ `AudioClipEditorView.cs:979` (`EnvShape`), `PianoRollView.Controllers.cs:257`,+ `Nota.Application/Editing/ControllerStroke.cs:164`, plus the oracle in+ `tests/Nota.SmokeTest/ControllerStrokeTests.cs`.+- Bend-handle inversions (`0.5^e = frac`): `ArrangementView.AutoEditor.cs:222`,+ `ClipEditorView.cs:496`, `AudioClipEditorView.cs:1325`.+- Segment slicing that relied on the power curve being self-similar:+ `ControllerStroke.Apply` (left piece keeps its curve), `sliceCtlPoints`+ (`MidiController.cpp`), the controller-take fold in `Engine_Render.cpp`.++## Root Cause Hypothesis++For `e < 1` the power curve has an infinite slope at t = 0: at `curve = 1` the value is half+way by t ≈ 2·10⁻⁵ — effectively a step in the engine as well as on screen. The curve family is+also asymmetric (ease-in is gentle, ease-out is a cliff). The 16-step polyline makes it look+worse (≈84 % of the change in the first step). Confidence: high.++## Proposed Remediation++**Preferred**: replace the shape with a symmetric exponential,+`shape(t, c) = expm1(k·t) / expm1(k)`, `k = −c·K` (K = 8). Slopes are finite at both ends,+ease-in and ease-out mirror each other, and the bend handle inverts in closed form+(`shape(½) = 1/(e^{k/2}+1)` ⇒ `k = 2·ln(1/frac − 1)`). Because exponentials are+shift-invariant, any sub-range [t0, t1] of a segment is exactly the same family with+`c·(t1 − t0)`: slicing becomes exact (`ControllerStroke` no longer needs its fit search, and+native slicing scales the curve instead of keeping it). Put the managed math in one shared+helper; draw curved segments with pixel-based sampling.++**Alternatives**:+- Keep the power curve but narrow the exponent range — still an infinite slope at t = 0 for+ every ease-out, so the step only softens.++**Files likely to change**:+- `src/native/nota.engine/src/engine/Automation.h`, `Engine_Automation.cpp` (self-test),+ `MidiController.cpp`, `Engine_Render.cpp`+- `src/managed/Nota.Application/Editing/AutomationCurve.cs` (new), `ControllerStroke.cs`+- `src/managed/Nota.App/ArrangementView.cs`, `ArrangementView.AutoEditor.cs`,+ `ClipEditorView.cs`, `AudioClipEditorView.cs`, `PianoRollView.Controllers.cs`+- `tests/Nota.SmokeTest/ControllerStrokeTests.cs`++**Tests to add or update**:+- Native self-test: at `curve = 1`, t = 0.01 reads well under 0.1 (no jump); ±1 mirror.+- Managed: shape matches the native formula; midpoint inversion round-trips; slicing a+ shaped segment keeps its values on both sides of a stroke.++## Risks & Considerations++- Saved projects keep their curve numbers but sound gentler at the extremes (the old ±1 was a+ near-step). Worth a CHANGELOG note.+- `std::expm1` on the audio thread costs about what the two `pow` calls did.++## Open Questions++- None.diff --git a/.specify/bugs/automation-curve-step/fix.md b/.specify/bugs/automation-curve-step/fix.mdnew file mode 100644index 00000000..8c0a6b6d--- /dev/null+++ b/.specify/bugs/automation-curve-step/fix.md@@ -0,0 +1,52 @@+# Bug Fix: Curved automation segments jump almost instantly++- **Slug**: automation-curve-step+- **Fixed**: 2026-11-12+- **Assessment**: ./assessment.md+- **Status**: applied++## Summary++The segment shape is now `expm1(k·t)/expm1(k)` with `k = −curve·8`, in the engine+(`AutomationLane::shape`) and in one shared managed helper (`AutomationCurve`) that replaces+five copies. Slopes are finite at both ends and ±curve mirror each other. The shape is+shift-invariant, so a piece [t0, t1] of a segment is exactly the same shape with+`curve·(t1 − t0)`. Every place that cuts a curved segment now scales the curve that way+(`AutomationLane::subCurve` / `pieceCurve`, `AutomationCurve.Sub`). Before, those places relied+on the power curve being self-similar at the start of a segment, or laid the cut as straight+pieces, or as a fitted curve. The bend handles invert in closed form, and curves are drawn+with about one step every 3 px instead of a fixed 12–16.++## Changes++| File | Change | Notes |+|------|--------|-------|+| `src/native/nota.engine/src/engine/Automation.h/.cpp` | modified | New `shape`; `kCurveSteepness`, `subCurve`, `pieceCurve`. |+| `src/native/nota.engine/src/engine/Engine_Automation.cpp` | modified | `automationCurveSelfTest`: no jump at the steep end, ease-in mirrors ease-out, a cut piece reads the same values. |+| `src/native/nota.engine/src/engine/Engine_Tracks.cpp` | modified | `appendLaneFrom` is one exact point, not 32 straight pieces. `endSegmentAt` shortens the last point before a cut (`laneRemap`, `laneDuplicate`, `laneInsertGap`). After an inserted gap (Insert Silence / Duplicate Time), the resumed point carries the rest of the segment through the cut (review follow-up). `laneSliceExact` and `stitchEnvelopes` scale interior/edge curves. |+| `src/native/nota.engine/src/engine/MidiController.h/.cpp` | modified | `ctlPieceCurve`. `sliceCtlPoints` keeps the shape at both edges (the start used to go linear). |+| `src/native/nota.engine/src/engine/Engine_Render.cpp` | modified | A controller take shortens the curve of the point before its range, and where it hands back to the old curve (`closeCtlRange`) the hand-back point carries the rest of the old segment (review follow-up). |+| `src/managed/Nota.Application/Editing/AutomationCurve.cs` | added | `Shape`, `Lerp`, `FromMidpoint`, `Sub`, `DrawSteps`. |+| `src/managed/Nota.Application/Editing/ControllerStroke.cs` | modified | The left piece is shortened exactly, and the right remainder is exact. The 41-candidate fit search and recursive splitting are removed. |+| `src/managed/Nota.App/ArrangementView.cs`, `ArrangementView.AutoEditor.cs`, `ClipEditorView.cs`, `AudioClipEditorView.cs`, `PianoRollView.Controllers.cs` | modified | Use `AutomationCurve`. Bend via `FromMidpoint` (handle range 1–99 % so ±1 is reachable). Pixel-based curve steps. |+| `tests/Nota.SmokeTest/ControllerStrokeTests.cs` | modified | New oracle. Both sides of a stroke are exact (< 1e-4). Shape checks: no jump, mirror, midpoint round-trip, managed = engine formula. |+| `tests/Nota.SmokeTest/SectionRearrangeTests.cs` | modified | The value oracle uses the new shape. |+| `tests/Nota.SmokeTest/Program.cs` | modified | Insert Silence and Duplicate Time keep a curved segment on both sides of the gap. |+| `src/native/nota.engine/src/engine/Engine_Automation.cpp` (`midiCtlSelfTest`) | modified | 9: a controller take over a curved segment keeps the old shape before it and after the hand-back. 10: a slice of curved controller segments matches at both edges. |+| `CHANGELOG.md` | modified | `[Unreleased]` → Fixed entry. |++## Diff Highlights++```cpp+static double shape(double t, float curve) {+ const double k = -static_cast<double>(curve) * kCurveSteepness;+ if (std::fabs(k) < 1e-6) return t;+ return std::expm1(k * t) / std::expm1(k);+}+```++## Risks++- Saved curves keep their numbers but sound gentler at the extremes (`curve = 1` reaches+ 50 % at t ≈ 0.09 instead of 0.00002). This is noted in the CHANGELOG.+- Audio-thread cost: two `expm1` calls replace two `pow` calls.diff --git a/.specify/bugs/automation-curve-step/test.md b/.specify/bugs/automation-curve-step/test.mdnew file mode 100644index 00000000..33c80791--- /dev/null+++ b/.specify/bugs/automation-curve-step/test.md@@ -0,0 +1,20 @@+# Bug Test: automation-curve-step++- **Slug**: automation-curve-step+- **Tested**: 2026-11-12+- **Fix**: ./fix.md+- **Verdict**: resolved++## Checks++- `scripts/build.sh`: the managed and native builds pass. In the smoke test every curve,+ stroke and section check passes, including the new ones: the steep end has no jump,+ ease-in mirrors ease-out, the bend round-trips through the midpoint, the managed shape+ matches the engine, both sides of a stroke are exact, and section move / duplicate keep+ curved automation. The engine `automationCurveSelfTest` passes.+- Remaining smoke failures: the render-pool load checks ("four indivisible VST3 jobs",+ "overloaded"). They fail the same way on clean `develop` on this machine (Rider running:+ 117 late blocks, burst 13), so they are unrelated to this fix.+- Headless render (docs shots harness, Studio Dark, whole song fitted): an "Audio 8" clip+ narrower than its name reads "Audi…" on one line. A low → high (−0.8) → low (+1)+ volume lane eases smoothly on both sides of the peak, with no vertical drop.diff --git a/.specify/bugs/clip-name-wrap/assessment.md b/.specify/bugs/clip-name-wrap/assessment.mdnew file mode 100644index 00000000..1a7a2c59--- /dev/null+++ b/.specify/bugs/clip-name-wrap/assessment.md@@ -0,0 +1,56 @@+# Bug Assessment: Short clips wrap their name onto a second line++- **Slug**: clip-name-wrap+- **Created**: 2026-11-12+- **Source**: https://github.com/nota-daw/nota/issues/590 (host: github.com, allowlisted; written by the reporter in this session)+- **Verdict**: valid+- **Severity**: low++## Report (verbatim or summarized)++When a clip is narrower than its name, the name wraps onto a second line ("Au… / 8") and+spills over the waveform. Expected: one line, cut with an ellipsis ("Audio…").++## Symptom++A clip label in the arrangement breaks between words when the clip is short; each line is+trimmed separately. It should stay on one line and end in an ellipsis.++## Reproduction++1. Add an audio track and drop a sample into the arrangement.+2. Split the clip, or trim it shorter than its name.+3. The title wraps onto a second line.++## Suspected Code Paths++- `src/managed/Nota.App/ArrangementView.LaneControl.cs:1608` — clip name in the content view+ (`NotaFormattedText` with `MaxTextWidth` + `CharacterEllipsis`, no line limit).+- `src/managed/Nota.App/ArrangementView.LaneControl.cs:1657` — the same label in the title-band+ (classic) look.+- `src/managed/Nota.App/ArrangementView.Sections.cs:629` — section-span labels, same pattern.++## Root Cause Hypothesis++Avalonia's `FormattedText` word-wraps at `MaxTextWidth` and applies `Trimming` per line, so+without `MaxLineCount = 1` a long name becomes several trimmed lines. Confidence: high (other+views — `SessionView.Grid`, `PianoRollView.ClipStrip`, `StereoMapView` — already set it).++## Proposed Remediation++**Preferred**: set `MaxLineCount = 1` on the three arrangement labels.++**Files likely to change**:+- `src/managed/Nota.App/ArrangementView.LaneControl.cs`+- `src/managed/Nota.App/ArrangementView.Sections.cs`++**Tests to add or update**:+- Visual check: a short clip with a two-word name renders one ellipsised line.++## Risks & Considerations++- None beyond the label; layout height already assumes one line.++## Open Questions++- None.diff --git a/.specify/bugs/clip-name-wrap/fix.md b/.specify/bugs/clip-name-wrap/fix.mdnew file mode 100644index 00000000..96567274--- /dev/null+++ b/.specify/bugs/clip-name-wrap/fix.md@@ -0,0 +1,30 @@+# Bug Fix: Short clips wrap their name onto a second line++- **Slug**: clip-name-wrap+- **Fixed**: 2026-11-12+- **Assessment**: ./assessment.md+- **Status**: applied++## Summary++The arrangement's clip names (both looks) and section-span labels set `MaxLineCount = 1`, so a+name wider than its clip stays on one line and ends in an ellipsis instead of word-wrapping.++## Changes++| File | Change | Notes |+|------|--------|-------|+| `src/managed/Nota.App/ArrangementView.LaneControl.cs` | modified | `MaxLineCount = 1` on the clip name in the content view and in the title band. |+| `src/managed/Nota.App/ArrangementView.Sections.cs` | modified | The same on section-span labels. |+| `CHANGELOG.md` | modified | `[Unreleased]` → Fixed entry. |++## Diff Highlights++```csharp+{ MaxTextWidth = Math.Max(8, rect.Width - 14), MaxLineCount = 1, Trimming = TextTrimming.CharacterEllipsis };+```++## Verification++- Headless render of the arrangement zoomed out so clips are narrower than their names: one+ ellipsised line (see test.md).diff --git a/.specify/bugs/clip-name-wrap/test.md b/.specify/bugs/clip-name-wrap/test.mdnew file mode 100644index 00000000..8f6244ae--- /dev/null+++ b/.specify/bugs/clip-name-wrap/test.md@@ -0,0 +1,20 @@+# Bug Test: clip-name-wrap++- **Slug**: clip-name-wrap+- **Tested**: 2026-11-12+- **Fix**: ./fix.md+- **Verdict**: resolved++## Checks++- `scripts/build.sh`: the managed and native builds pass. In the smoke test every curve,+ stroke and section check passes, including the new ones: the steep end has no jump,+ ease-in mirrors ease-out, the bend round-trips through the midpoint, the managed shape+ matches the engine, both sides of a stroke are exact, and section move / duplicate keep+ curved automation. The engine `automationCurveSelfTest` passes.+- Remaining smoke failures: the render-pool load checks ("four indivisible VST3 jobs",+ "overloaded"). They fail the same way on clean `develop` on this machine (Rider running:+ 117 late blocks, burst 13), so they are unrelated to this fix.+- Headless render (docs shots harness, Studio Dark, whole song fitted): an "Audio 8" clip+ narrower than its name reads "Audi…" on one line. A low → high (−0.8) → low (+1)+ volume lane eases smoothly on both sides of the peak, with no vertical drop.diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 46a03f00..b2813a50 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -586,6 +586,21 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.MCP: `list_audio_inputs`, `set_track_input`, `get_track_input`.### Fixed+- **Curved automation eases instead of jumping** (#591): bending a segment towards an+ ease-out made it reach almost all of its change at the very start — a near-vertical drop+ on screen and an audible step in playback — while the opposite bend looked gentle. Every+ curved segment (automation lanes, clip envelopes, MIDI controller lanes) now follows a+ smooth exponential: no jump at either end, and ease-in and ease-out mirror each other.+ Curves in saved projects keep their bend but play gentler at the extremes. Cutting a+ curved segment (moving or duplicating a section, drawing over a controller lane,+ recording controllers, splitting clips) now keeps its shape exactly on both sides, and+ the curves are drawn smoothly at any zoom.+- **Plug-in cards show the plug-in's window again**: since the new look, the info section's+ own surface covered the picture of the plug-in's window on its card. The picture now+ shows through the section, on S and on L, under the wash that keeps the text readable.+- **Short clips keep their name on one line** (#590): a clip narrower than its name wrapped+ the name onto a second line over the waveform. The name now stays on one line and ends in+ an ellipsis; section names in the arrangement do the same.- **Track header meters stay inside the header** (#584): on a Compact or a low Standard row atrack's level meter ran into the bottom edge of its header, and a folded group's meter ranunder its name and buttons. Every header meter now fits its row, and a group's meter standsdiff --git a/src/managed/Nota.App/ArrangementView.AutoEditor.cs b/src/managed/Nota.App/ArrangementView.AutoEditor.csindex 75bc0832..cd30a220 100644--- a/src/managed/Nota.App/ArrangementView.AutoEditor.cs+++ b/src/managed/Nota.App/ArrangementView.AutoEditor.cs@@ -218,10 +218,9 @@ public sealed partial class ArrangementViewfloat v0 = _bendLeft.Value, v1 = _bendRight.Value;if (Math.Abs(v1 - v0) < 1e-4f) { _bendLeft.Curve = 0f; _owner.InvalidateVisual(); return; }double val = YToValue(_bendTrack, i, pos.Y);- double frac = Math.Clamp((val - v0) / (v1 - v0), 0.02, 0.98);- // Solve Shape(0.5, curve) == frac -> 0.5^e = frac -> e = ln(frac)/ln(0.5).- double e = Math.Log(frac) / Math.Log(0.5);- _bendLeft.Curve = (float)Math.Clamp(-Math.Log2(e) / 4.0, -1.0, 1.0);+ double frac = Math.Clamp((val - v0) / (v1 - v0), 0.01, 0.99);+ // The curve whose midpoint reaches the pointer (#591).+ _bendLeft.Curve = Nota.Application.Editing.AutomationCurve.FromMidpoint(frac);CommitAutoDuringDrag(_bendTrack); // engine follows the curve bend live_owner.InvalidateVisual();}@@ -370,7 +369,7 @@ public sealed partial class ArrangementViewdouble bx = _o.BeatToX(b.Beat), by2 = ValueToY(t, i, b.Value);if (a.Curve == 0f) { ctx.DrawLine(segPen, new Point(ax, ay), new Point(bx, by2)); continue; }// Curved segment: polyline of shaped sub-samples (M9-D).- const int steps = 16;+ int steps = Nota.Application.Editing.AutomationCurve.DrawSteps(bx - ax);var prev = new Point(ax, ay);for (int s = 1; s <= steps; s++){diff --git a/src/managed/Nota.App/ArrangementView.LaneControl.cs b/src/managed/Nota.App/ArrangementView.LaneControl.csindex a6d1e401..1a2902b6 100644--- a/src/managed/Nota.App/ArrangementView.LaneControl.cs+++ b/src/managed/Nota.App/ArrangementView.LaneControl.cs@@ -1607,7 +1607,7 @@ public sealed partial class ArrangementViewstring text = string.IsNullOrEmpty(c.Name) ? label : c.Name;var ft = new NotaFormattedText(text, CultureInfo.InvariantCulture,FlowDirection.LeftToRight, NotaFonts.SansSemiBold, NotaType.ClipName, content)- { MaxTextWidth = Math.Max(8, rect.Width - 14), Trimming = TextTrimming.CharacterEllipsis };+ { MaxTextWidth = Math.Max(8, rect.Width - 14), MaxLineCount = 1, Trimming = TextTrimming.CharacterEllipsis };using var _ = ctx.PushClip(rect);ctx.DrawText(ft, new Point(rect.X + 7, rect.Y + (LabelH - ft.Height) / 2 + 1));}@@ -1656,7 +1656,7 @@ public sealed partial class ArrangementViewstring text = string.IsNullOrEmpty(c.Name) ? label : c.Name;var ft = new NotaFormattedText(text, CultureInfo.InvariantCulture,FlowDirection.LeftToRight, NotaFonts.SansSemiBold, NotaType.Eyebrow, NotaPalette.InkOn(band))- { MaxTextWidth = Math.Max(8, rect.Width - 10), Trimming = TextTrimming.CharacterEllipsis };+ { MaxTextWidth = Math.Max(8, rect.Width - 10), MaxLineCount = 1, Trimming = TextTrimming.CharacterEllipsis };using var _ = ctx.PushClip(rect);ctx.DrawText(ft, new Point(rect.X + 5, rect.Y + (TitleBandH - ft.Height) / 2));}diff --git a/src/managed/Nota.App/ArrangementView.Sections.cs b/src/managed/Nota.App/ArrangementView.Sections.csindex 861b8d96..5ea79ddb 100644--- a/src/managed/Nota.App/ArrangementView.Sections.cs+++ b/src/managed/Nota.App/ArrangementView.Sections.cs@@ -626,7 +626,7 @@ public sealed partial class ArrangementViewif (r.Width <= 22) return;var ft = new NotaFormattedText(_o.SectionDisplayName(s), CultureInfo.InvariantCulture,FlowDirection.LeftToRight, Typeface.Default, 9, warm ? WarmInk : ColdInk)- { MaxTextWidth = Math.Max(8, r.Width - 10), Trimming = TextTrimming.CharacterEllipsis };+ { MaxTextWidth = Math.Max(8, r.Width - 10), MaxLineCount = 1, Trimming = TextTrimming.CharacterEllipsis };ctx.DrawText(ft, new Point(r.X + 7, r.Y + (r.Height - ft.Height) / 2));}diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.csindex 6ea2d3b8..5e889221 100644--- a/src/managed/Nota.App/ArrangementView.cs+++ b/src/managed/Nota.App/ArrangementView.cs@@ -3560,9 +3560,9 @@ public sealed partial class ArrangementView : UserControlreturn b;}- // Power-curve shaping, mirroring native AutomationLane::shape (M9-D).+ // Segment shaping (M9-D, #591): the shared AutomationCurve, mirroring native AutomationLane::shape.internal static double Shape(double t, float curve)- => curve == 0f ? t : Math.Pow(t, Math.Pow(2.0, -curve * 4.0));+ => AutomationCurve.Shape(t, curve);// ---- data colours (mirror the tokens in NotaTheme.axaml) --private static readonly IBrush LaneBgA = NotaPalette.BgApp; // lanes on the grounddiff --git a/src/managed/Nota.App/AudioClipEditorView.cs b/src/managed/Nota.App/AudioClipEditorView.csindex 1a6665b1..2aac22fe 100644--- a/src/managed/Nota.App/AudioClipEditorView.cs+++ b/src/managed/Nota.App/AudioClipEditorView.cs@@ -976,7 +976,7 @@ public sealed class AudioClipEditorView : UserControl// The value axis spans the wave area below the ruler and the marker strip.private double EnvValToY(double v, double h) { double pad = 6, top = WaveTop + pad; double t = (Math.Clamp(v, _envMin, _envMax) - _envMin) / (_envMax - _envMin); return top + (1 - t) * Math.Max(1, h - pad - top); }private double EnvYToVal(double y, double h) { double pad = 6, top = WaveTop + pad; double t = (h - pad - y) / Math.Max(1, h - pad - top); return _envMin + Math.Clamp(t, 0, 1) * (_envMax - _envMin); }- private static double EnvShape(double t, float curve) => curve == 0f ? t : Math.Pow(t, Math.Pow(2.0, -curve * 4.0));+ private static double EnvShape(double t, float curve) => AutomationCurve.Shape(t, curve);private int HitEnv(double x, double y, double w, double h){for (int i = 0; i < _env.Count; i++)@@ -1321,9 +1321,8 @@ public sealed class AudioClipEditorView : UserControlif (Math.Abs(v1 - v0) < 1e-4) bl.curve = 0f;else{- double frac = Math.Clamp((EnvYToVal(p.Y, Bounds.Height) - v0) / (v1 - v0), 0.02, 0.98);- double ee = Math.Log(frac) / Math.Log(0.5);- bl.curve = (float)Math.Clamp(-Math.Log2(ee) / 4.0, -1.0, 1.0);+ double frac = Math.Clamp((EnvYToVal(p.Y, Bounds.Height) - v0) / (v1 - v0), 0.01, 0.99);+ bl.curve = AutomationCurve.FromMidpoint(frac);}Redraw();}@@ -1865,9 +1864,10 @@ public sealed class AudioClipEditorView : UserControldouble ax = EnvBeatToX(a.beat, w), ay = EnvValToY(a.val, h), bx = EnvBeatToX(b.beat, w), by = EnvValToY(b.val, h);if (a.curve == 0f) { ctx.DrawLine(pen, new Point(ax, ay), new Point(bx, by)); continue; }Point prev = new(ax, ay);- for (int s = 1; s <= 16; s++)+ int steps = AutomationCurve.DrawSteps(bx - ax);+ for (int s = 1; s <= steps; s++){- double tt = s / 16.0;+ double tt = s / (double)steps;double vy = a.val + (b.val - a.val) * EnvShape(tt, a.curve);Point cur = new(ax + (bx - ax) * tt, EnvValToY(vy, h));ctx.DrawLine(pen, prev, cur); prev = cur;diff --git a/src/managed/Nota.App/ClipEditorView.cs b/src/managed/Nota.App/ClipEditorView.csindex 4de95506..45e0cd39 100644--- a/src/managed/Nota.App/ClipEditorView.cs+++ b/src/managed/Nota.App/ClipEditorView.cs@@ -395,7 +395,7 @@ public sealed class ClipEditorView : UserControlprivate double XToBeat(double x, double w) => Math.Clamp(_roll.XToBeat(x) - Offset, 0, _clipBeats);private static double ValToY(double v, double h) { double pad = 6; return pad + (1 - Math.Clamp(v, 0, 1)) * (h - 2 * pad); }private static double YToVal(double y, double h) { double pad = 6; return Math.Clamp((h - pad - y) / Math.Max(1, h - 2 * pad), 0, 1); }- private static double Shape(double t, float curve) => curve == 0f ? t : Math.Pow(t, Math.Pow(2.0, -curve * 4.0));+ private static double Shape(double t, float curve) => Nota.Application.Editing.AutomationCurve.Shape(t, curve);private int HitPoint(double x, double y, double w, double h){@@ -492,9 +492,8 @@ public sealed class ClipEditorView : UserControlif (k < 0 || k + 1 >= ord.Count) return;double v0 = bl.Val, v1 = ord[k + 1].Val;if (Math.Abs(v1 - v0) < 1e-4) { bl.Curve = 0f; InvalidateVisual(); return; }- double frac = Math.Clamp((YToVal(p.Y, Bounds.Height) - v0) / (v1 - v0), 0.02, 0.98);- double ee = Math.Log(frac) / Math.Log(0.5);- bl.Curve = (float)Math.Clamp(-Math.Log2(ee) / 4.0, -1.0, 1.0);+ double frac = Math.Clamp((YToVal(p.Y, Bounds.Height) - v0) / (v1 - v0), 0.01, 0.99);+ bl.Curve = Nota.Application.Editing.AutomationCurve.FromMidpoint(frac);InvalidateVisual();}}@@ -526,9 +525,10 @@ public sealed class ClipEditorView : UserControldouble ax = BeatToX(a.Beat, w), ay = ValToY(a.Val, h), bx = BeatToX(b.Beat, w), by = ValToY(b.Val, h);if (a.Curve == 0f) { ctx.DrawLine(pen, new Point(ax, ay), new Point(bx, by)); continue; }Point prev = new(ax, ay);- for (int s = 1; s <= 16; s++)+ int steps = Nota.Application.Editing.AutomationCurve.DrawSteps(bx - ax);+ for (int s = 1; s <= steps; s++){- double tt = s / 16.0;+ double tt = s / (double)steps;double vy = a.Val + (b.Val - a.Val) * Shape(tt, a.Curve);Point cur = new(ax + (bx - ax) * tt, ValToY(vy, h));ctx.DrawLine(pen, prev, cur); prev = cur;diff --git a/src/managed/Nota.App/Controls/PluginPreviewBackdrop.cs b/src/managed/Nota.App/Controls/PluginPreviewBackdrop.csindex 7a6527bd..8a91b8fd 100644--- a/src/managed/Nota.App/Controls/PluginPreviewBackdrop.cs+++ b/src/managed/Nota.App/Controls/PluginPreviewBackdrop.cs@@ -4,9 +4,10 @@// The picture of a hosted plug-in's own window behind its device card (specs/046): the// engine keeps a JPEG of the window as it was last hidden; this draws it covering the area// — one uniform scale, anchored to the top where plug-ins put their logo, centred across,-// cropped, never stretched — under NotaPalette.PluginPreviewWash, the card's own surface-// colour, so the card's text reads as on the plain card in every theme. Decoration only: it takes no clicks.-// No preview yet → draws nothing, the card looks as it always did.+// cropped, never stretched — under NotaPalette.PluginPreviewWash, the section's own surface+// colour, so the card's text reads as on a plain section in every theme. Decoration only: it+// takes no clicks. It stands under an unfilled RuleSection and paints that section's surface+// first, so with no preview yet the card looks as it always did.using System;using System.Collections.Generic;@@ -85,19 +86,26 @@ internal sealed class PluginPreviewBackdrop : Controlprivate void OnThemeChanged() => InvalidateVisual();+ // It stands under an unfilled section (PluginCard), so it paints that section's surface+ // itself, in its rounded shape: with no picture the card looks like any other section.public override void Render(DrawingContext ctx){+ double w = Bounds.Width, h = Bounds.Height;+ if (w <= 0 || h <= 0) return;+ var shape = new RoundedRect(new Rect(0, 0, w, h), NotaRadius.GroupValue);+ ctx.DrawRectangle(NotaPalette.DeviceSection, null, shape);if (_image is not { } img) return;- double w = Bounds.Width, h = Bounds.Height, iw = img.Size.Width, ih = img.Size.Height;- if (w <= 0 || h <= 0 || iw <= 0 || ih <= 0) return;+ double iw = img.Size.Width, ih = img.Size.Height;+ if (iw <= 0 || ih <= 0) return;// Cover: the larger of the two fits, so no edge is left empty and nothing stretches.double s = Math.Max(w / iw, h / ih);double dw = iw * s, dh = ih * s;var dest = new Rect((w - dw) / 2, 0, dw, dh);- using (ctx.PushClip(new Rect(0, 0, w, h)))+ using (ctx.PushClip(shape))+ {ctx.DrawImage(img, new Rect(img.Size), dest);-- ctx.FillRectangle(NotaPalette.PluginPreviewWash, new Rect(0, 0, w, h));+ ctx.FillRectangle(NotaPalette.PluginPreviewWash, new Rect(0, 0, w, h));+ }}}diff --git a/src/managed/Nota.App/Controls/RuleSection.cs b/src/managed/Nota.App/Controls/RuleSection.csindex 9a36b776..f7ffba08 100644--- a/src/managed/Nota.App/Controls/RuleSection.cs+++ b/src/managed/Nota.App/Controls/RuleSection.cs@@ -33,6 +33,10 @@ internal sealed class RuleSection : Decorator/// <summary>Kept for older call sites: a pressed-in section has no dividing rules.</summary>public SectionEdge Edges { get; init; } = SectionEdge.Auto;+ /// <summary>False: only the pressed-in edge, no fill — for a section over a picture that+ /// paints the section's own surface itself (a plug-in card's window preview).</summary>+ public bool Filled { get; init; } = true;+public RuleSection() => ClipToBounds = true;protected override Size MeasureOverride(Size availableSize)@@ -65,6 +69,6 @@ internal sealed class RuleSection : Decoratorpublic override void Render(DrawingContext context){base.Render(context);- NotaDepth.Section(context, this, new RoundedRect(new Rect(Bounds.Size), NotaRadius.GroupValue));+ NotaDepth.Section(context, this, new RoundedRect(new Rect(Bounds.Size), NotaRadius.GroupValue), Filled);}}diff --git a/src/managed/Nota.App/DeviceCards/PluginCard.cs b/src/managed/Nota.App/DeviceCards/PluginCard.csindex fedd4900..5902352f 100644--- a/src/managed/Nota.App/DeviceCards/PluginCard.cs+++ b/src/managed/Nota.App/DeviceCards/PluginCard.cs@@ -9,7 +9,7 @@// knob grid (search + pages), and, for a plug-in with a sidechain bus, its source.// The size is editor state kept by the chain view (a hosted plug-in has no "view" param).// Once the plug-in's window has been open, the info column stands on a picture of it-// (PluginPreviewBackdrop, specs/046): the whole S body, the info column on L.+// (PluginPreviewBackdrop, specs/046): the info section, on S and on L.using System;using System.Collections.Generic;@@ -59,12 +59,14 @@ internal static class PluginCardpublic static Control Build(DeviceCardContext ctx, int di, PluginInfo info, ViewState state){- if (state.Mini) return Section(InfoColumn(ctx, di, info, mini: true));+ if (state.Mini) return new Panel { Children = { Backdrop(ctx, di), Section(InfoColumn(ctx, di, info, mini: true), filled: false) } };var e = ctx.Engine; int t = ctx.TrackId;bool sidechain = di >= 0 && e.DeviceAcceptsSidechain(t, di);var grid = new Grid { ColumnDefinitions = new ColumnDefinitions(sidechain ? $"{InfoW},*,{ScW}" : $"{InfoW},*"), ColumnSpacing = 5 };- grid.Children.Add(new Panel { Children = { Backdrop(ctx, di), Section(InfoColumn(ctx, di, info, mini: false)) } });+ // The section draws only its edge here: the backdrop paints the section's surface,+ // then the window picture and the wash, so the fill doesn't cover the picture.+ grid.Children.Add(new Panel { Children = { Backdrop(ctx, di), Section(InfoColumn(ctx, di, info, mini: false), filled: false) } });var pars = Section(Params(ctx, di, state)); Grid.SetColumn(pars, 1); grid.Children.Add(pars);if (sidechain){@@ -345,9 +347,9 @@ internal static class PluginCard}// A device section: card ground, hairline, radius 6.- private static Decorator Section(Control child, double pad = 8)+ private static Decorator Section(Control child, double pad = 8, bool filled = true){- var d = DeviceCardKit.Section(child);+ var d = filled ? DeviceCardKit.Section(child) : new RuleSection { Filled = false, Child = child };d.Padding = new Thickness(pad, 6, pad, pad);return d;}diff --git a/src/managed/Nota.App/DeviceChainView.Plugin.cs b/src/managed/Nota.App/DeviceChainView.Plugin.csindex c4c9299f..f1128fdb 100644--- a/src/managed/Nota.App/DeviceChainView.Plugin.cs+++ b/src/managed/Nota.App/DeviceChainView.Plugin.cs@@ -27,10 +27,8 @@ public sealed partial class DeviceChainViewBypassed: _engine.DeviceBypassed(_trackId, effect ? di : -1), Bypassable: true,CanMove: effect, CanDelete: true, PresetKind: -1, IsInstrument: !effect, Width: width, Kind: k,HeaderExtra: toggle, Compact: state.Mini);+ // The picture of the plug-in's window stands behind the info section (PluginCard).Control padded = new Border { Padding = new Thickness(NotaSpace.DeviceInset), Child = body };- // On S the picture of the plug-in's window fills the body (on L, PluginCard puts it- // behind the info column only).- if (state.Mini) padded = new Panel { Children = { PluginCard.Backdrop(ctx, di), padded } };return BuildCardShell(spec, padded);}}diff --git a/src/managed/Nota.App/PianoRollView.Controllers.cs b/src/managed/Nota.App/PianoRollView.Controllers.csindex c64d6979..0a86306f 100644--- a/src/managed/Nota.App/PianoRollView.Controllers.cs+++ b/src/managed/Nota.App/PianoRollView.Controllers.cs@@ -254,7 +254,7 @@ public sealed partial class PianoRollViewreturn (float)(a.Value + (b.Value - a.Value) * Shape((beat - a.Beat) / span, a.Curve));}- private static double Shape(double t, float curve) => curve == 0f ? t : Math.Pow(t, Math.Pow(2.0, -curve * 4.0));+ private static double Shape(double t, float curve) => AutomationCurve.Shape(t, curve);// Sorted, the last point given for any one beat kept; a switch keeps only its changes.private List<AutomationPoint> Normalize(IEnumerable<AutomationPoint> pts)@@ -456,10 +456,11 @@ public sealed partial class PianoRollViewfor (int i = 1; i < c.Count; i++){var a = c[i - 1]; var b = c[i];+ int steps = a.Curve != 0 ? AutomationCurve.DrawSteps(XOf(b.Beat) - XOf(a.Beat)) : 0;if (a.Curve != 0)- for (int s = 1; s < 12; s++)+ for (int s = 1; s < steps; s++){- double t = s / 12.0;+ double t = s / (double)steps;g.LineTo(new Point(XOf(a.Beat + (b.Beat - a.Beat) * t), ValueToY((float)(a.Value + (b.Value - a.Value) * Shape(t, a.Curve)))));}g.LineTo(new Point(XOf(b.Beat), ValueToY(b.Value)));diff --git a/src/managed/Nota.App/Theme/NotaDepth.cs b/src/managed/Nota.App/Theme/NotaDepth.csindex be25b83a..2bab7448 100644--- a/src/managed/Nota.App/Theme/NotaDepth.cs+++ b/src/managed/Nota.App/Theme/NotaDepth.cs@@ -27,6 +27,6 @@ internal static class NotaDepth=> ctx.DrawRectangle(NotaPalette.SurfaceHover, null, r, Shadow(owner, "Shadow.Lifted"));/// <summary>A pressed-in section of a device card.</summary>- public static void Section(DrawingContext ctx, StyledElement owner, RoundedRect r)- => ctx.DrawRectangle(NotaPalette.DeviceSection, null, r, Shadow(owner, "Shadow.Section"));+ public static void Section(DrawingContext ctx, StyledElement owner, RoundedRect r, bool filled = true)+ => ctx.DrawRectangle(filled ? NotaPalette.DeviceSection : Brushes.Transparent, null, r, Shadow(owner, "Shadow.Section"));}diff --git a/src/managed/Nota.App/Theme/NotaPalette.cs b/src/managed/Nota.App/Theme/NotaPalette.csindex 7a51343b..8fdfe6db 100644--- a/src/managed/Nota.App/Theme/NotaPalette.cs+++ b/src/managed/Nota.App/Theme/NotaPalette.cs@@ -461,12 +461,12 @@ internal static class NotaPalettepublic static readonly Color[] TrackColors = { TrackSlots[0].Color, TrackSlots[1].Color, TrackSlots[2].Color, TrackSlots[3].Color, TrackSlots[4].Color, TrackSlots[5].Color, TrackSlots[6].Color, TrackSlots[7].Color, TrackSlots[8].Color };public static readonly Color[] ReturnColors = { ReturnSlots[0].Color, ReturnSlots[1].Color };- /// <summary>The one gradient in the device cards (specs/046): the card's own surface laid+ /// <summary>The one gradient in the device cards (specs/046): the section's own surface laid/// over the picture of a plug-in's window, heavier at the top (name, facts) and bottom- /// (buttons) than in the middle, so the card's text reads as on the plain card in every- /// theme. Washes of SurfaceCard, so it re-tints with the theme.</summary>+ /// (buttons) than in the middle, so the card's text reads as on a plain section in every+ /// theme. Washes of DeviceSection, so it re-tints with the theme.</summary>public static readonly LinearGradientBrush PluginPreviewWash = VGradient(- (Wash(SurfaceCard, 0xDB), 0), (Wash(SurfaceCard, 0x9E), 0.5), (Wash(SurfaceCard, 0xE6), 1));+ (Wash(DeviceSection, 0xDB), 0), (Wash(DeviceSection, 0x9E), 0.5), (Wash(DeviceSection, 0xE6), 1));// ---- Lookup by XAML key ------------------------------------------------diff --git a/src/managed/Nota.Application/Editing/AutomationCurve.cs b/src/managed/Nota.Application/Editing/AutomationCurve.csnew file mode 100644index 00000000..d09a938d--- /dev/null+++ b/src/managed/Nota.Application/Editing/AutomationCurve.cs@@ -0,0 +1,47 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// The shape of a curved automation / envelope / controller segment (#591), mirroring native+// AutomationLane::shape. A point's Curve (−1..1) bends the segment to the next point:+// expm1(k·t)/expm1(k) with k = −Curve·Steepness — 0 is a straight line, >0 eases out, <0 eases+// in, and the two mirror each other. Both ends have a finite slope, so no curve jumps.+// The family is shift-invariant: any piece [t0, t1] of a segment is the same shape with+// Curve·(t1 − t0), so cutting a segment never moves its values.++using System;++namespace Nota.Application.Editing;++public static class AutomationCurve+{+ /// <summary>Steepness of Curve ±1. Matches native <c>AutomationLane::kCurveSteepness</c>.</summary>+ public const double Steepness = 8.0;++ /// <summary>The shaped 0..1 fraction at <paramref name="t"/> (0..1) of a segment.</summary>+ public static double Shape(double t, float curve)+ {+ double k = -curve * Steepness;+ if (Math.Abs(k) < 1e-6) return t;+ return double.ExpM1(k * t) / double.ExpM1(k);+ }++ /// <summary>The value at <paramref name="t"/> (0..1) between <paramref name="v0"/> and <paramref name="v1"/>.</summary>+ public static double Lerp(double v0, double v1, double t, float curve) => v0 + (v1 - v0) * Shape(t, curve);++ /// <summary>The curve whose segment passes the middle at <paramref name="frac"/> of the way+ /// (the bend handle): Shape(½) = 1/(e^{k/2}+1), so k = 2·ln(1/frac − 1).</summary>+ public static float FromMidpoint(double frac)+ {+ frac = Math.Clamp(frac, 1e-4, 1 - 1e-4);+ double k = 2.0 * Math.Log(1.0 / frac - 1.0);+ return (float)Math.Clamp(-k / Steepness, -1.0, 1.0);+ }++ /// <summary>The curve of a piece spanning <paramref name="fraction"/> (0..1) of a segment.+ /// Matches native <c>AutomationLane::subCurve</c>.</summary>+ public static float Sub(float curve, double fraction) => (float)(curve * Math.Clamp(fraction, 0.0, 1.0));++ /// <summary>Polyline steps for drawing a curved segment <paramref name="pixels"/> wide:+ /// about one every 3 px, so a steep end stays smooth at any zoom.</summary>+ public static int DrawSteps(double pixels) => Math.Clamp((int)Math.Ceiling(Math.Abs(pixels) / 3.0), 8, 256);+}diff --git a/src/managed/Nota.Application/Editing/ControllerStroke.cs b/src/managed/Nota.Application/Editing/ControllerStroke.csindex 778dadda..863d5fd6 100644--- a/src/managed/Nota.Application/Editing/ControllerStroke.cs+++ b/src/managed/Nota.Application/Editing/ControllerStroke.cs@@ -2,10 +2,10 @@// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.//// A drawn controller stroke replaces only the stretch it covers (specs/063). The curve on-// either side keeps the value it had: the left piece is the same power curve over a shorter-// span (that shaping is a fraction of the segment, so it needs no new exponent), and the-// right piece is refit because a new segment would otherwise start linear and straighten-// everything after the stroke.+// either side keeps the value it had: a piece of a shaped segment is the same shape with its+// curve scaled to the piece's share of the segment (AutomationCurve, #591), so the left piece+// and the right remainder are both exact — without the remainder a new segment would start+// linear and straighten everything after the stroke.using System;using System.Collections.Generic;@@ -22,8 +22,6 @@ public static class ControllerStroke/// (<c>ctlThinTolerance</c>).</summary>public const float Tolerance = 0.008f;- private const double MinPiece = 1.0 / 128.0;- private const int MaxSplits = 8;/// <summary>The engine's reading of a continuous controller curve/// (<c>ControllerCurve::valueAt</c>): held outside the first and last point.</summary>@@ -62,10 +60,22 @@ public static class ControllerStrokevar ordered = Sorted(samples);double a = ordered[0].Beat, b = ordered[^1].Beat;var outp = new List<AutomationPoint>(orig.Count + ordered.Count + 4);+ int kept = 0;foreach (var q in orig)- if (q.Beat < a - Junction) outp.Add(q);+ if (q.Beat < a - Junction) { outp.Add(q); kept++; }if (outp.Count > 0)+ {+ // The last point's segment now ends at the junction: shorten its curve so the+ // stretch before the stroke keeps its values (#591).+ if (kept < orig.Count)+ {+ var last = outp[^1];+ double span = orig[kept].Beat - last.Beat;+ if (span > 0) last.Curve = AutomationCurve.Sub(last.Curve, (a - Junction - last.Beat) / span);+ outp[^1] = last;+ }outp.Add(new AutomationPoint(a - Junction, ValueAt(orig, a - Junction)));+ }foreach (var (sb, sv) in ordered)outp.Add(new AutomationPoint(sb, sv));@@ -84,72 +94,20 @@ public static class ControllerStrokevar left = orig[next - 1];var right = orig[next];if (edge > left.Beat + 1e-9 && edge < right.Beat)- EmitRemainder(outp, left, right, edge, right.Beat, 0);+ EmitRemainder(outp, left, right, edge);}for (int i = next; i < orig.Count; i++)outp.Add(orig[i]);return CollapseBeats(outp);}- // The tail of the segment (left → right) from `from` up to `end` (the next stored point,- // not emitted here). One power curve when it stays within Tolerance; otherwise the piece- // is halved and each half is shaped on its own.- private static void EmitRemainder(- List<AutomationPoint> outp, AutomationPoint left, AutomationPoint right, double from, double end, int depth)+ // The tail of the segment (left → right) from `from` on: the same shape with the curve+ // scaled to the part that is left, which is exact (#591).+ private static void EmitRemainder(List<AutomationPoint> outp, AutomationPoint left, AutomationPoint right, double from){- float value = ValueOn(left, right, from);- if (Math.Abs(left.Curve) < 1e-6f)- {- outp.Add(new AutomationPoint(from, value, 0f));- return;- }- float curve = FitCurve(left, right, from, end, out float err);- if (err <= Tolerance || depth >= MaxSplits || end - from <= MinPiece)- {- outp.Add(new AutomationPoint(from, value, curve));- return;- }- double mid = (from + end) / 2;- EmitRemainder(outp, left, right, from, mid, depth + 1);- EmitRemainder(outp, left, right, mid, end, depth + 1);- }-- private static float FitCurve(- AutomationPoint left, AutomationPoint right, double from, double end, out float err)- {- float bestC = 0f, bestE = float.MaxValue;- for (int i = 0; i <= 40; i++)- Consider(-1f + i / 20f);- float around = bestC;- for (int i = -10; i <= 10; i++)- Consider(Math.Clamp(around + i * 0.01f, -1f, 1f));- err = bestE;- return bestC;-- void Consider(float c)- {- float e = MaxError(left, right, from, end, c);- if (e < bestE) { bestE = e; bestC = c; }- }- }-- private static float MaxError(- AutomationPoint left, AutomationPoint right, double from, double end, float curve)- {- double span = end - from;- if (span <= 0) return 0;- float v0 = ValueOn(left, right, from), v1 = ValueOn(left, right, end);- float err = 0;- for (int k = 1; k < 16; k++)- {- double beat = from + span * k / 16.0;- float target = ValueOn(left, right, beat);- double t = (beat - from) / span;- float got = (float)(v0 + (v1 - v0) * Shape(t, curve));- float d = Math.Abs(target - got);- if (d > err) err = d;- }- return err;+ double span = right.Beat - left.Beat;+ float curve = span > 0 ? AutomationCurve.Sub(left.Curve, (right.Beat - from) / span) : 0f;+ outp.Add(new AutomationPoint(from, ValueOn(left, right, from), curve));}private static float ValueOn(AutomationPoint left, AutomationPoint right, double beat)@@ -161,7 +119,7 @@ public static class ControllerStroke}private static double Shape(double t, float curve)- => curve == 0f ? t : Math.Pow(t, Math.Pow(2.0, -curve * 4.0));+ => AutomationCurve.Shape(t, curve);private static IReadOnlyList<AutomationPoint> SortedPoints(IReadOnlyList<AutomationPoint> orig){diff --git a/src/native/nota.engine/src/engine/Automation.cpp b/src/native/nota.engine/src/engine/Automation.cppindex 84589212..a3e495ee 100644--- a/src/native/nota.engine/src/engine/Automation.cpp+++ b/src/native/nota.engine/src/engine/Automation.cpp@@ -3,6 +3,8 @@#include "Automation.h"+#include <algorithm>+namespace nota {float AutomationLane::valueAt(double beat) const {@@ -22,4 +24,15 @@ float AutomationLane::valueAt(double beat) const {return p.back().value;}+float AutomationLane::pieceCurve(const std::vector<AutomationPoint>& p, double from, double to) {+ constexpr double eps = 1e-9; // a cut a hair before a point belongs to that point's segment+ const auto next = std::upper_bound(p.begin(), p.end(), from + eps,+ [](double b, const AutomationPoint& q) { return b < q.beat; });+ if (next == p.begin() || next == p.end()) return 0.0f;+ const AutomationPoint& a = *(next - 1);+ const double span = next->beat - a.beat;+ if (span <= 0.0 || a.curve == 0.0f) return 0.0f;+ return subCurve(a.curve, (std::min(to, next->beat) - std::max(from, a.beat)) / span);+}+} // namespace notadiff --git a/src/native/nota.engine/src/engine/Automation.h b/src/native/nota.engine/src/engine/Automation.hindex dd7db133..edc65e82 100644--- a/src/native/nota.engine/src/engine/Automation.h+++ b/src/native/nota.engine/src/engine/Automation.h@@ -9,6 +9,7 @@#pragma once+#include <algorithm>#include <cmath>#include <cstdint>#include <string>@@ -48,12 +49,29 @@ struct AutomationLane {// hold before the first / after the last. Caller guarantees points non-empty & sorted.float valueAt(double beat) const;- // Power-curve shaping of a 0..1 fraction. curve 0 -> linear; endpoints exact.+ // Steepness of curve ±1 (#591). Mirrored by Nota.Application.Editing.AutomationCurve.+ static constexpr double kCurveSteepness = 8.0;++ // Exponential shaping of a 0..1 fraction (#591): expm1(k·t)/expm1(k), k = −curve·K.+ // curve 0 -> linear, >0 ease-out, <0 ease-in (mirror images); endpoints exact and the+ // slope finite at both ends, so no curve jumps. The family is shift-invariant: the part+ // of a segment over [t0, t1] is the same shape with curve·(t1 − t0) (see subCurve).static double shape(double t, float curve) {- if (curve == 0.0f) return t;- const double e = std::pow(2.0, -curve * 4.0); // >0: <1 (ease-out), <0: >1 (ease-in)- return std::pow(t, e);+ const double k = -static_cast<double>(curve) * kCurveSteepness;+ if (std::fabs(k) < 1e-6) return t;+ return std::expm1(k * t) / std::expm1(k);+ }++ // The curve of a piece of a segment spanning `fraction` (0..1) of it, exact for any+ // piece: a segment cut short or a tail starting part-way keeps its values.+ static float subCurve(float curve, double fraction) {+ return static_cast<float>(curve * std::clamp(fraction, 0.0, 1.0));}++ // The curve a piece of `p` starting at `from` needs when it runs to its next point or is+ // cut at `to`, whichever comes first: the segment's curve scaled to that share of it.+ // 0 before the first / from the last point on. `p` sorted by beat.+ static float pieceCurve(const std::vector<AutomationPoint>& p, double from, double to);};// A track's own automation lane (specs/044): it may point at a device grouped into a rack.diff --git a/src/native/nota.engine/src/engine/Engine_Automation.cpp b/src/native/nota.engine/src/engine/Engine_Automation.cppindex d7522c5c..5d2408b3 100644--- a/src/native/nota.engine/src/engine/Engine_Automation.cpp+++ b/src/native/nota.engine/src/engine/Engine_Automation.cpp@@ -91,8 +91,21 @@ bool Engine::automationCurveSelfTest() {if (std::fabs(lane.valueAt(2.0) - 0.5f) > 1e-4f) return false; // linear baselinelane.points[0].curve = 1.0f; // ease-outif (lane.valueAt(2.0) < 0.6f) return false;+ // No jump at the start (#591): the old power curve was ~75 % there by 1 % of the span.+ if (lane.valueAt(0.04) > 0.1f) return false;+ const float easeOutMid = lane.valueAt(2.0);lane.points[0].curve = -1.0f; // ease-inif (lane.valueAt(2.0) > 0.4f) return false;+ // Ease-in and ease-out mirror each other.+ if (std::fabs(lane.valueAt(2.0) - (1.0f - easeOutMid)) > 1e-4f) return false;+ // A piece of a shaped segment, with subCurve, reads the same values (shift-invariance).+ {+ TrackLane cut;+ cut.target = AutomationTarget::Volume;+ cut.points = {{1.0, lane.valueAt(1.0), AutomationLane::subCurve(-1.0f, 0.5)}, {3.0, lane.valueAt(3.0), 0.0f}};+ for (double b = 1.0; b <= 3.0; b += 0.25)+ if (std::fabs(cut.valueAt(b) - lane.valueAt(b)) > 1e-4f) return false;+ }// Endpoints unaffected by curvature.if (std::fabs(lane.valueAt(0.0) - 0.0f) > 1e-4f) return false;if (std::fabs(lane.valueAt(4.0) - 1.0f) > 1e-4f) return false;@@ -1070,6 +1083,38 @@ int32_t Engine::midiCtlSelfTest() {!near(w->valueAt(7.0), 0.2f))fail = 8;}+ // 9: the same take over a curved segment (#591): the old curve keeps its shape before+ // the take and from the hand-back at beat 4 on, not a straight line.+ if (!fail) {+ for (auto& f : ctlFold_) f = CtlFold{};+ ControllerCurve was;+ was.ctl = kCtlModWheel;+ was.points = {{0.0, 0.0f, -0.8f}, {8.0, 1.0f, 0.0f}};+ MidiClip e;+ e.lengthBeats = 8.0;+ e.setController(kCtlModWheel, was.points);+ ctlBatch_ = {{kCtlModWheel, 2.0, 0.8f, 0}, {kCtlModWheel, 3.0, 0.8f, 0}};+ ctlStopPending_ = true;+ ctlStopAt_ = 4.0;+ foldRecordedCtl(e, 0.0);+ const ControllerCurve* w = e.controller(kCtlModWheel);+ if (!w) fail = 9;+ else+ for (double b : {0.5, 1.0, 1.9, 4.5, 5.0, 6.0, 7.0, 7.9})+ if (!near(w->valueAt(b), was.valueAt(b))) fail = 9;+ }+ // 10: a slice of a curved segment keeps its shape at both edges.+ if (!fail) {+ ControllerCurve c;+ c.ctl = kCtlModWheel;+ c.points = {{0.0, 0.0f, 0.7f}, {4.0, 1.0f, -0.5f}, {8.0, 0.2f, 0.0f}};+ const double from = 1.0, to = 6.0;+ ControllerCurve s;+ s.ctl = kCtlModWheel;+ s.points = sliceCtlPoints(c, from, to);+ for (double b = from; b <= to; b += 0.25)+ if (!near(s.valueAt(b - from), c.valueAt(b))) fail = 10;+ }}ctlFold_ = savedFold;ctlBatch_ = savedBatch;diff --git a/src/native/nota.engine/src/engine/Engine_Render.cpp b/src/native/nota.engine/src/engine/Engine_Render.cppindex 23b1fc9d..f7dc0297 100644--- a/src/native/nota.engine/src/engine/Engine_Render.cpp+++ b/src/native/nota.engine/src/engine/Engine_Render.cpp@@ -866,7 +866,15 @@ void Engine::commitCtlRun(MidiClip& clip, int32_t ctl, double slotLen, bool finaif (!f.hasCommitted && f.before && !f.before->points.empty() &&f.before->points.front().beat < loL - kCtlJunction) {const double j = loL - kCtlJunction;- if (!kept.empty() && f.before->valueAt(j) != kept.front().value) out.push_back({j, f.before->valueAt(j), 0.0f});+ const bool junction = !kept.empty() && f.before->valueAt(j) != kept.front().value;+ // The last point before the range now ends its segment early: shorten its curve so the+ // stretch before the range keeps its values (#591).+ for (auto it = out.rbegin(); it != out.rend(); ++it)+ if (it->beat < loL - 1e-9) {+ it->curve = ctlPieceCurve(f.before->points, it->beat, junction ? j : loL);+ break;+ }+ if (junction) out.push_back({j, f.before->valueAt(j), 0.0f});}for (const auto& p : kept) {out.push_back({local(p.beat), p.value, 0.0f});@@ -929,7 +937,11 @@ void Engine::closeCtlRange(MidiClip& clip, int32_t ctl, double atLocal, double s// Hold the range's last value up to the junction, then hand back to the old curve.if (!ctlIsSwitch(ctl) && atLocal - kCtlJunction > lastL + 1e-9 && old != f.committed.value)out.push_back({atLocal - kCtlJunction, f.committed.value, 0.0f});- out.push_back({atLocal, old, 0.0f});+ // ...and from there on the old curve plays its own shape (#591).+ const float tail = f.before && !ctlIsSwitch(ctl)+ ? ctlPieceCurve(f.before->points, atLocal, std::numeric_limits<double>::infinity())+ : 0.0f;+ out.push_back({atLocal, old, tail});}clip.setController(ctl, std::move(out));f.before.reset();diff --git a/src/native/nota.engine/src/engine/Engine_Tracks.cpp b/src/native/nota.engine/src/engine/Engine_Tracks.cppindex 8ec8334e..a6012a87 100644--- a/src/native/nota.engine/src/engine/Engine_Tracks.cpp+++ b/src/native/nota.engine/src/engine/Engine_Tracks.cpp@@ -1350,27 +1350,17 @@ float curveThrough(const AutomationLane& lane, double t) {return c;}-// Append the lane from `t` up to (not including) its next point, shifted by `shift`, stopping-// before `limit`. Cut at its end a power curve keeps its shape with the same curve (t^e-// scales), but cut at its start it is no power curve any more: that partial segment is laid-// as short straight pieces, well under 0.1 % off.+// Append the lane from `t` up to (not including) its next point, shifted by `shift`: one point+// carrying the rest of the segment through `t`, its curve scaled to end at the next point or at+// `limit`, whichever comes first — exact, as the segment shape is shift-invariant (#591).void appendLaneFrom(std::vector<AutomationPoint>& out, const AutomationLane& lane, double t, double limit, double shift) {- constexpr double eps = 1e-9;- constexpr int pieces = 32;- const auto& p = lane.points;- const auto next = std::find_if(p.begin(), p.end(), [&](const AutomationPoint& q) { return q.beat > t + eps; });- const bool before = next != p.begin(), onPoint = before && std::abs(std::prev(next)->beat - t) < eps;- const float k = before ? std::prev(next)->curve : 0.0f;- if (k == 0.0f || onPoint || next == p.end()) {- out.push_back({t + shift, lane.valueAt(t), onPoint ? k : 0.0f});- return;- }- out.push_back({t + shift, lane.valueAt(t), 0.0f});- for (int i = 1; i < pieces; ++i) {- const double b = t + (next->beat - t) * i / pieces;- if (b >= limit - eps) break;- out.push_back({b + shift, lane.valueAt(b), 0.0f});- }+ out.push_back({t + shift, lane.valueAt(t), AutomationLane::pieceCurve(lane.points, t, limit)});+}++// The last point of `out` (an original point of `src` at its own beat) now ends its segment at+// `end`: shorten its curve so the stretch before `end` keeps its values (#591).+void endSegmentAt(std::vector<AutomationPoint>& out, const std::vector<AutomationPoint>& src, double end) {+ if (!out.empty()) out.back().curve = AutomationLane::pieceCurve(src, out.back().beat, end);}// The lane over [a,b] re-based so `a` is 0, playing as it did: the value at each edge plus@@ -1383,7 +1373,7 @@ std::vector<AutomationPoint> laneSliceExact(const AutomationLane& lane, double afor (const auto& q : lane.points)if (q.beat > a + eps && q.beat < b - eps) {if (!out.empty() && q.beat - a <= out.back().beat + eps) continue;- out.push_back({q.beat - a, q.value, q.curve});+ out.push_back({q.beat - a, q.value, AutomationLane::pieceCurve(lane.points, q.beat, b)});}out.push_back({b - a, lane.valueAt(b), 0.0f});return out;@@ -2112,8 +2102,8 @@ double Engine::duplicateRange(const std::vector<int32_t>& trackIds, double start// --- insert time (Insert Silence ⌘⇧I / Duplicate Time ⌘⇧D) ----------------------namespace {-// The lane's curve over [a,b] re-based so `a` is 0 (laneSliceExact: the value at each edge,-// every point strictly inside, a curved segment cut at its start laid as short straight pieces).+// The lane's curve over [a,b] re-based so `a` is 0 (laneSliceExact: the value at each edge and+// every point strictly inside, a curved segment cut at either end keeping its shape).std::vector<AutomationPoint> laneSlice(const AutomationLane& lane, double a, double b) {return laneSliceExact(lane, a, b);}@@ -2132,15 +2122,20 @@ bool laneInsertGap(AutomationLane& lane, double at, double len, const std::vectostd::vector<AutomationPoint> out;out.reserve(p.size() + (fill ? fill->size() + 1 : 2));out.insert(out.end(), p.begin(), mid);+ if (before) endSegmentAt(out, p, at);+ // After the gap the lane resumes the segment that ran through `at`, its curve scaled to+ // what is left of it, so the tail keeps its shape (#591).+ const float tail = AutomationLane::pieceCurve(p, at, std::numeric_limits<double>::infinity());if (fill) {out.push_back({at, v, 0.0f}); // a step from the left side into the copyfor (auto q : *fill) {q.beat += at;out.push_back(q);}+ if (!fill->empty()) out.back().curve = tail;} else if (before) {out.push_back({at, v, 0.0f});- out.push_back({at + len, v, 0.0f});+ out.push_back({at + len, v, tail});}for (auto it = mid; it != p.end(); ++it) {auto q = *it;@@ -2345,6 +2340,7 @@ bool laneRemap(AutomationLane& lane, double lo, double hi, const std::vector<Timout.reserve(p.size() + 2 * rs.size() + 2);for (const auto& q : p)if (q.beat < lo - eps) out.push_back(q);+ endSegmentAt(out, p, lo);out.push_back({lo, lane.valueAt(lo), 0.0f}); // the left side ends (or holds) as it didstd::vector<const TimeRegion*> order;@@ -2390,6 +2386,7 @@ bool laneDuplicate(AutomationLane& lane, double a, double b) {out.reserve(p.size() * 2 + 4);for (const auto& q : p)if (q.beat < b - eps) out.push_back(q);+ endSegmentAt(out, p, b);out.push_back({b, lane.valueAt(b), 0.0f}); // the left side ends as it didfor (auto q : laneSliceExact(lane, a, b)) {q.beat += b;@@ -2646,11 +2643,13 @@ AutomationLane stitchEnvelopes(const std::vector<EnvSpan>& spans, double start,add(a, 1.0f);}const bool has = s.lane && !s.lane->points.empty();- add(a, has ? s.lane->valueAt(a - s.clipStart) : 1.0f);+ // Each piece keeps its curve scaled to the part of its segment inside the span (#591).+ const double la = a - s.clipStart, lb = b - s.clipStart;+ add(a, has ? s.lane->valueAt(la) : 1.0f, has ? AutomationLane::pieceCurve(s.lane->points, la, lb) : 0.0f);if (has)for (const auto& p : s.lane->points) {const double x = s.clipStart + p.beat;- if (x > a && x < b) add(x, p.value, p.curve);+ if (x > a && x < b) add(x, p.value, AutomationLane::pieceCurve(s.lane->points, p.beat, lb));}add(b, has ? s.lane->valueAt(b - s.clipStart) : 1.0f);cursor = b;diff --git a/src/native/nota.engine/src/engine/MidiController.cpp b/src/native/nota.engine/src/engine/MidiController.cppindex 0012c8b3..f8d087e3 100644--- a/src/native/nota.engine/src/engine/MidiController.cpp+++ b/src/native/nota.engine/src/engine/MidiController.cpp@@ -74,12 +74,25 @@ std::vector<AutomationPoint> thinCtlCurve(const std::vector<AutomationPoint>& p,return out;}+float ctlPieceCurve(const std::vector<AutomationPoint>& p, double from, double to) {+ return AutomationLane::pieceCurve(p, from, to);+}+std::vector<AutomationPoint> sliceCtlPoints(const ControllerCurve& c, double from, double to) {std::vector<AutomationPoint> out;- if (!c.points.empty() && from >= c.points.front().beat) out.push_back({0.0, c.valueAt(from), 0.0f});+ double lastAt = from; // the source beat of out.back()+ if (!c.points.empty() && from >= c.points.front().beat)+ out.push_back({0.0, c.valueAt(from), ctlPieceCurve(c.points, from, to)});for (const auto& p : c.points)- if (p.beat > from && p.beat < to) out.push_back({p.beat - from, p.value, p.curve});- if (to > from && !ctlIsSwitch(c.ctl) && c.movesIn(from, to)) out.push_back({to - from, c.valueAt(to), 0.0f});+ if (p.beat > from && p.beat < to) {+ out.push_back({p.beat - from, p.value, p.curve});+ lastAt = p.beat;+ }+ if (to > from && !ctlIsSwitch(c.ctl) && c.movesIn(from, to)) {+ // The last point's segment now ends at `to`: shorten its curve to match.+ if (!out.empty()) out.back().curve = ctlPieceCurve(c.points, lastAt, to);+ out.push_back({to - from, c.valueAt(to), 0.0f});+ }if (out.size() > 1 && ctlIsSwitch(c.ctl)) out = dedupeSwitch(out);// A piece that never leaves rest carries nothing.for (const auto& p : out)diff --git a/src/native/nota.engine/src/engine/MidiController.h b/src/native/nota.engine/src/engine/MidiController.hindex 1b9c4bb3..b281cb3c 100644--- a/src/native/nota.engine/src/engine/MidiController.h+++ b/src/native/nota.engine/src/engine/MidiController.h@@ -77,6 +77,10 @@ inline std::vector<AutomationPoint> dedupeSwitch(const std::vector<AutomationPoi// Ramer–Douglas–Peucker over breakpoints (first and last always kept): the fewest points that// stay within `tol` of a block-rate recording — the shape the gesture had.+// The curve of the piece [from, min(to, next point)] of the segment of `p` that holds `from`:+// exact, as the segment shape is shift-invariant (#591). 0 before the first / past the last point.+float ctlPieceCurve(const std::vector<AutomationPoint>& p, double from, double to);+std::vector<AutomationPoint> thinCtlCurve(const std::vector<AutomationPoint>& p, float tol);// Recording tolerances: about one 7-bit step for a CC, ~1% of the wheel's travel — the capturediff --git a/tests/Nota.SmokeTest/ControllerStrokeTests.cs b/tests/Nota.SmokeTest/ControllerStrokeTests.csindex 85fdbe9f..5060222a 100644--- a/tests/Nota.SmokeTest/ControllerStrokeTests.cs+++ b/tests/Nota.SmokeTest/ControllerStrokeTests.cs@@ -2,8 +2,9 @@// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.//// Drawing a controller stroke replaces only that stretch (specs/063). Playback on either-// side stays put: the shortened left piece keeps its shaping, and the right piece is refit-// so it does not fall back to a straight line. Also runnable alone:+// side stays put: the shortened left piece and the right remainder are the same shape with+// the curve scaled to their share of the segment (#591), so they do not fall back to a+// straight line. Also checks the segment shape itself (no jump, mirrored ease-in/out). Also runnable alone:// `dotnet run --project tests/Nota.SmokeTest -- --controller-stroke`.using Nota.Application.Editing;@@ -25,7 +26,8 @@ internal static class ControllerStrokeTestsdouble span = b.Beat - a.Beat;if (span <= 0) return b.Value;double t = (beat - a.Beat) / span;- double shaped = a.Curve == 0f ? t : Math.Pow(t, Math.Pow(2.0, -a.Curve * 4.0));+ double k = -a.Curve * 8.0; // native AutomationLane::shape, K = 8+ double shaped = Math.Abs(k) < 1e-6 ? t : (Math.Exp(k * t) - 1) / (Math.Exp(k) - 1);return (float)(a.Value + (b.Value - a.Value) * shaped);}@@ -47,14 +49,14 @@ internal static class ControllerStrokeTestsvar stroke = new (double Beat, float Value)[] { (1, 0.4f), (2, 0.6f) };var merged = ControllerStroke.Apply(shaped, stroke);- yield return (merged.Count > 0 && merged[0].Beat == 0 && merged[0].Curve == -1f,- "the point before the stroke keeps its curve");+ yield return (merged.Count > 0 && merged[0].Beat == 0 && merged[0].Curve < 0f && merged[0].Curve > -1f,+ "the point before the stroke keeps a shortened ease-in");yield return (Worst(shaped, merged, 0, 1 - 0.05) < 1e-4f,"shortening the left of a shaped segment does not move its values");float right = Worst(shaped, merged, 2 + 0.01, 4);- yield return (right <= ControllerStroke.Tolerance + 0.001f,- $"the curve after the stroke stays within one step (off by {right:0.0000})");+ yield return (right < 1e-4f,+ $"the curve after the stroke keeps its values (off by {right:0.0000})");bool straightTail = true;foreach (var p in merged)@@ -64,8 +66,25 @@ internal static class ControllerStrokeTestsvar easeOut = new AutomationPoint[] { new(0, 0f, 1f), new(4, 1f, 0f) };var eased = ControllerStroke.Apply(easeOut, stroke);float outErr = Math.Max(Worst(easeOut, eased, 0, 0.95), Worst(easeOut, eased, 2.01, 4));- yield return (outErr <= ControllerStroke.Tolerance + 0.001f,- "an ease-out keeps both sides");+ yield return (outErr < 1e-4f,+ $"an ease-out keeps both sides (off by {outErr:0.0000})");++ // The segment shape (#591): no jump at either end, ease-in mirrors ease-out, the bend+ // handle round-trips, and the shared helper is the engine formula.+ yield return (AutomationCurve.Shape(0.01, 1f) < 0.1 && AutomationCurve.Shape(0.99, -1f) > 0.9,+ "a full ease-out / ease-in does not jump at its steep end");+ yield return (Math.Abs(AutomationCurve.Shape(0.3, 1f) - (1 - AutomationCurve.Shape(0.7, -1f))) < 1e-9,+ "ease-in mirrors ease-out");+ bool trips = true, matches = true;+ foreach (float c in new[] { -1f, -0.6f, -0.1f, 0.25f, 0.8f })+ {+ if (Math.Abs(AutomationCurve.FromMidpoint(AutomationCurve.Shape(0.5, c)) - c) > 1e-4f) trips = false;+ var seg = new AutomationPoint[] { new(0, 0f, c), new(1, 1f, 0f) };+ for (int i = 0; i <= 10; i++)+ if (Math.Abs(ControllerStroke.ValueAt(seg, i / 10.0) - Oracle(seg, i / 10.0)) > 1e-5f) matches = false;+ }+ yield return (trips, "the bend handle's curve round-trips through the midpoint");+ yield return (matches, "the shared shape matches the engine formula");var linear = new AutomationPoint[] { new(0, 0f, 0f), new(4, 1f, 0f) };var lin = ControllerStroke.Apply(linear, stroke);diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.csindex a1e701f7..f69b8542 100644--- a/tests/Nota.SmokeTest/Program.cs+++ b/tests/Nota.SmokeTest/Program.cs@@ -13363,6 +13363,40 @@ Console.WriteLine("-- insert time --");"duplicate: automation ramp copied into the gap, the rest holds");Check(!e.InsertTime(1.0, 2.0, duplicate: true), "duplicate with a range before 0 is rejected");}++ // A curved segment cut by Insert Silence / Duplicate Time keeps its shape on both sides+ // (#591): before the cut, and after the gap where the tail resumes.+ foreach (bool dup in new[] { false, true })+ {+ using var e = new NotaEngine();+ int a = e.AddInstrumentTrack();+ e.AddMidiClip(a, 0.0, 12.0);+ int lane = e.AddAutomationLane(a, AutomationTarget.Volume, -1, -1);+ var orig = new[] { new Nota.Application.AutomationPoint(0, 0.0f, -1f), new Nota.Application.AutomationPoint(8, 1.0f, 0f) };+ e.SetAutomationPoints(a, lane, orig);+ e.InsertTime(4.0, 2.0, duplicate: dup);+ var pts = e.GetAutomationPoints(a, lane);+ static float Read(Nota.Application.AutomationPoint[] p, double beat)+ {+ if (beat <= p[0].Beat) return p[0].Value;+ for (int i = 1; i < p.Length; i++)+ if (beat < p[i].Beat)+ {+ double span = p[i].Beat - p[i - 1].Beat;+ if (span <= 0) return p[i].Value;+ return (float)(p[i - 1].Value + (p[i].Value - p[i - 1].Value)+ * Nota.Application.Editing.AutomationCurve.Shape((beat - p[i - 1].Beat) / span, p[i - 1].Curve));+ }+ return p[^1].Value;+ }+ float worst = 0;+ foreach (double b in new[] { 1.0, 2.5, 3.9, 6.1, 7.0, 8.5, 9.9 })+ {+ double was = b < 4 ? b : b - 2;+ worst = Math.Max(worst, Math.Abs(Read(pts, b) - Read(orig, was)));+ }+ Check(worst < 1e-4f, $"{(dup ? "duplicate time" : "insert silence")}: a curved segment keeps its shape on both sides of the gap (off by {worst:0.0000})");+ }}// ============ track/clip names + colour + track clipboard ==================diff --git a/tests/Nota.SmokeTest/SectionRearrangeTests.cs b/tests/Nota.SmokeTest/SectionRearrangeTests.csindex a3213caf..8482e594 100644--- a/tests/Nota.SmokeTest/SectionRearrangeTests.cs+++ b/tests/Nota.SmokeTest/SectionRearrangeTests.cs@@ -69,7 +69,7 @@ internal static class SectionRearrangeTests}// The lane's value at `beat` as the engine plays it: each segment shaped by its start point's- // curve (t^e, e = 2^(−4·curve)); at a step, the later point wins.+ // curve (AutomationCurve.Shape, #591); at a step, the later point wins.private static float At(AutomationPoint[] pts, double beat){if (pts.Length == 0) return 0;@@ -78,7 +78,7 @@ internal static class SectionRearrangeTestsif (beat < pts[i].Beat){double t = (beat - pts[i - 1].Beat) / (pts[i].Beat - pts[i - 1].Beat);- double shaped = pts[i - 1].Curve == 0 ? t : Math.Pow(t, Math.Pow(2, -pts[i - 1].Curve * 4));+ double shaped = Nota.Application.Editing.AutomationCurve.Shape(t, pts[i - 1].Curve);return (float)(pts[i - 1].Value + (pts[i].Value - pts[i - 1].Value) * shaped);}return pts[^1].Value;@@ -117,13 +117,13 @@ internal static class SectionRearrangeTests}// A curved automation segment cut by a move keeps its shape on both sides (a 0 → 1 ramp- // over [0,16) with curve −0.25 is (b/16)²), and a cut clip keeps its deactivation and+ // over [0,16) with curve −0.25 is AutomationCurve.Shape(b/16, −0.25)), and a cut clip keeps its deactivation and// its envelopes, re-based to each piece.{var s = Build();using var e = s.E;e.SetAutomationPoints(s.B, s.Lane, new[] { new AutomationPoint(0, 0f, -0.25f), new AutomationPoint(16, 1f) });- float Sq(double b) => (float)Math.Pow(Math.Clamp(b, 0, 16) / 16.0, 2);+ float Sq(double b) => (float)Nota.Application.Editing.AutomationCurve.Shape(Math.Clamp(b, 0, 16) / 16.0, -0.25f);e.SetClipActive(s.A, 0, false);e.SetMidiClipEnvelope(s.A, 0, MidiClipEnvelope.Volume, new[] { P(0, 0f), P(12, 1f) });string wav = Path.Combine(Path.GetTempPath(), "nota_smoke_sections_env.wav");@@ -145,13 +145,13 @@ internal static class SectionRearrangeTests"section move: a cut audio clip's envelope is re-based to each piece");}- // Duplicate with content keeps a curved lane's shape around the copy too: the quadratic- // ramp reads at beat 16 what it read at 12 (0.5625), the copy plays B's curve.+ // Duplicate with content keeps a curved lane's shape around the copy too: the eased-in+ // ramp reads at beat 16 what it read at 12, the copy plays B's curve.{var s = Build();using var e = s.E;e.SetAutomationPoints(s.B, s.Lane, new[] { new AutomationPoint(0, 0f, -0.25f), new AutomationPoint(16, 1f) });- float Sq(double b) => (float)Math.Pow(Math.Clamp(b, 0, 16) / 16.0, 2);+ float Sq(double b) => (float)Nota.Application.Editing.AutomationCurve.Shape(Math.Clamp(b, 0, 16) / 16.0, -0.25f);bool dup = e.DuplicateSectionWithContent(1); // B [4,8): copy at 8, the rest +4yield return (dup && LaneFollows(e.GetAutomationPoints(s.B, s.Lane), Sq, (3, 3), (6, 6), (9, 5), (11.5, 7.5), (13, 9), (16, 12), (19, 15), (21, 17)),"section duplicate: curved automation keeps its shape before, in and after the copy");