Bug fixes for envelopes, including crashes#2214
Open
maiko3tattun wants to merge 4 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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); |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.