Skip to content

Bug fixes for envelopes, including crashes#2214

Open
maiko3tattun wants to merge 4 commits into
openutau:masterfrom
maiko3tattun:260618_FixEnvelopeCrash
Open

Bug fixes for envelopes, including crashes#2214
maiko3tattun wants to merge 4 commits into
openutau:masterfrom
maiko3tattun:260618_FixEnvelopeCrash

Conversation

@maiko3tattun

@maiko3tattun maiko3tattun commented Jun 18, 2026

Copy link
Copy Markdown
Contributor
  • Fixed an edge case where the editor would crash if unexpected values were present in the envelope parameters (such as when using an older version of ustx) and the user performed an invalid operation.
  • Added attack/release time delta to the scope of the phoneme reset menu in case the envelope knobs overlap and the values cannot be reset.
  • Fixed a minor bug in the “Lengthen Crossfades” feature and improved the logic
  • Improved the hit-test logic for overlap points

@maiko3tattun maiko3tattun marked this pull request as ready for review June 18, 2026 14:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves envelope/phoneme editing robustness in the piano roll by preventing overlap hit-tests in invalid scenarios, expanding “reset phoneme timings” to include envelope timing deltas, and refining crossfade-lengthening logic to avoid incorrect adjustments.

Changes:

  • Refines phoneme overlap hit-testing and cursor behavior to better match actionable overlap points.
  • Expands phoneme timing reset to also clear envelope timing deltas (attack/release), and updates the UI string accordingly.
  • Adjusts “Lengthen Crossfades” to compute a safer preutter cap and only apply overlap edits when applicable.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
OpenUtau/ViewModels/NotesViewModelHitTest.cs Adds a guard so overlap points are only hit-testable when a valid “next phoneme” boundary exists.
OpenUtau/Strings/Strings.axaml Updates menu text to reflect that reset now affects envelopes as well.
OpenUtau/Controls/PianoRoll.axaml.cs Simplifies cursor selection logic by relying on improved hit-testing for overlap points.
OpenUtau.Core/Editing/NoteBatchEdits.cs Refines “Lengthen Crossfades” calculations for preutter/overlap edits.
OpenUtau.Core/Commands/NoteCommands.cs Replaces Math.Clamp usages to avoid crashes on inverted bounds; extends reset command to clear attack/release deltas.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +316 to 323
var max = Math.Min(phoneme.maxOtoPreutter, phoneme.Prev.DurationMs - 5);
docManager.ExecuteCmd(new PhonemePreutterCommand(part, note, phoneme.index, phoneme, (float)(max - phoneme.autoPreutter)));
if (phoneme.autoOverlap > 0) {
var overlap = max * ratio;
if (overlap > phoneme.autoOverlap) {
docManager.ExecuteCmd(new PhonemeOverlapCommand(part, note, phoneme.index, phoneme, (float)(overlap - phoneme.autoOverlap)));
}
}
Comment on lines 574 to +577
double overlap = phoneme.preutter - phoneme.autoOverlap;
double max = phoneme.envelope.data[3].X + overlap;
double min = -phoneme.Prev?.DurationMs + 5 + overlap ?? 0;
newDelta = (float)Math.Clamp(delta, min, max);
newDelta = (float)Math.Max(Math.Min(delta, max), min);
Comment on lines 606 to +608
double max = phoneme.autoPreutter - phoneme.GetFadeIn() + phoneme.envelope.data[3].X;
double min = -phoneme.GetFadeIn() + 5;
newDelta = (float)Math.Clamp(delta, min, max);
newDelta = (float)Math.Max(Math.Min(delta, max), min);
Comment on lines 637 to +640
var p3x = phoneme.envelope.data[4].X - phoneme.GetFadeOut();
double max = p3x - phoneme.envelope.data[2].X;
double min = -phoneme.GetFadeOut() + 5;
newDelta = (float)Math.Clamp(delta, min, max);
newDelta = (float)Math.Max(Math.Min(delta, max), min);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants