Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions OpenUtau.Core/Commands/NoteCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ public PhonemePreutterCommand(UVoicePart part, UNote note, int index, UPhoneme p
}
max = Math.Max(0, max);
double min = -phoneme.autoPreutter;
newDelta = (float)Math.Clamp(delta, min, max);
newDelta = (float)Math.Max(Math.Min(delta, max), min);
}
public override void Execute() {
var o = note.GetPhonemeOverride(index);
Expand Down Expand Up @@ -574,7 +574,7 @@ public PhonemeOverlapCommand(UVoicePart part, UNote note, int index, UPhoneme ph
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);
}
public override void Execute() {
var o = note.GetPhonemeOverride(index);
Expand Down Expand Up @@ -605,7 +605,7 @@ public PhonemeAttackTimeCommand(UVoicePart part, UNote note, int index, UPhoneme

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);
}
public override void Execute() {
var o = note.GetPhonemeOverride(index);
Expand Down Expand Up @@ -637,7 +637,7 @@ public PhonemeReleaseTimeCommand(UVoicePart part, UNote note, int index, UPhonem
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);
}
public override void Execute() {
var o = note.GetPhonemeOverride(index);
Expand All @@ -652,7 +652,7 @@ public override void Unexecute() {

public class ClearPhonemeTimingCommand : NoteCommand {
readonly UNote note;
readonly Tuple<int, int?, float?, float?>[] oldValues;
readonly Tuple<int, int?, float?, float?, float?, float?>[] oldValues;
public override ValidateOptions ValidateOptions => new ValidateOptions {
SkipTiming = true,
Part = Part,
Expand All @@ -661,7 +661,7 @@ public class ClearPhonemeTimingCommand : NoteCommand {
public ClearPhonemeTimingCommand(UVoicePart part, UNote note) : base(part, note) {
this.note = note;
oldValues = note.phonemeOverrides
.Select(o => Tuple.Create(o.index, o.offset, o.preutterDelta, o.overlapDelta))
.Select(o => Tuple.Create(o.index, o.offset, o.preutterDelta, o.overlapDelta, o.attackTimeDelta, o.releaseTimeDelta))
.ToArray();
}

Expand All @@ -670,6 +670,8 @@ public override void Execute() {
o.offset = null;
o.preutterDelta = null;
o.overlapDelta = null;
o.attackTimeDelta = null;
o.releaseTimeDelta = null;
}
}
public override void Unexecute() {
Expand All @@ -678,6 +680,8 @@ public override void Unexecute() {
o.offset = t.Item2;
o.preutterDelta = t.Item3;
o.overlapDelta = t.Item4;
o.attackTimeDelta = t.Item5;
o.releaseTimeDelta = t.Item6;
}
}
public override string ToString() => "Clear phoneme timing";
Expand Down
11 changes: 7 additions & 4 deletions OpenUtau.Core/Editing/NoteBatchEdits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,13 @@ public void Run(UProject project, UVoicePart part, List<UNote> selectedNotes, Do
foreach (var note in notes) {
foreach (UPhoneme phoneme in part.phonemes) {
if (phoneme.Parent == note && phoneme.Prev != null && phoneme.PositionMs == phoneme.Prev.EndMs) {
docManager.ExecuteCmd(new PhonemePreutterCommand(part, note, phoneme.index, phoneme, (float)phoneme.maxOtoPreutter));
var overlap = phoneme.preutter * ratio;
if (overlap > phoneme.autoOverlap) {
docManager.ExecuteCmd(new PhonemeOverlapCommand(part, note, phoneme.index, phoneme, (float)(overlap - phoneme.autoOverlap)));
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)));
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions OpenUtau/Controls/PianoRoll.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,8 +1258,7 @@ public void PhonemeCanvasPointerMoved(object sender, PointerEventArgs args) {
return;
}
var hitInfo = ViewModel.NotesViewModel.HitTest.HitTestPhoneme(point.Position);
var adjacent = hitInfo.phoneme != null && hitInfo.phoneme.Next != null && hitInfo.phoneme.Next.adjacent;
if (hitInfo.hitPosition || hitInfo.hitPreutter || (hitInfo.hitOverlap && adjacent) || hitInfo.hitAttackTime || hitInfo.hitReleaseTime) {
if (hitInfo.hitPosition || hitInfo.hitPreutter || hitInfo.hitOverlap || hitInfo.hitAttackTime || hitInfo.hitReleaseTime) {
Cursor = ViewConstants.cursorSizeWE;
ViewModel.MouseoverPhoneme(null);
return;
Expand Down
2 changes: 1 addition & 1 deletion OpenUtau/Strings/Strings.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ Warning: this option removes custom presets.</system:String>
<system:String x:Key="pianoroll.menu.notes.reset.all">Reset notes to default</system:String>
<system:String x:Key="pianoroll.menu.notes.reset.allparameters">Reset all parameters</system:String>
<system:String x:Key="pianoroll.menu.notes.reset.exps">Reset all expressions</system:String>
<system:String x:Key="pianoroll.menu.notes.reset.phonemetimings">Reset phoneme timings</system:String>
<system:String x:Key="pianoroll.menu.notes.reset.phonemetimings">Reset phoneme timings and envelopes</system:String>
<system:String x:Key="pianoroll.menu.notes.reset.pitchbends">Reset pitch bends</system:String>
<system:String x:Key="pianoroll.menu.notes.reset.vibratos">Reset vibratos</system:String>
<system:String x:Key="pianoroll.menu.part">Part</system:String>
Expand Down
1 change: 1 addition & 0 deletions OpenUtau/ViewModels/NotesViewModelHitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ public PhonemeHitInfo HitTestPhoneme(Point mousePos) {
return result;
}
// p4 Overlap
if (phoneme.Next == null || phoneme.Next.position != phoneme.End) continue;
int p4Tick = timeAxis.MsPosToTickPos(phoneme.PositionMs + phoneme.envelope.data[4].X) - viewModel.Part.position;
double p4x = viewModel.TickToneToPoint(p4Tick, 0).X;
point = new Point(p4x, 60 - phoneme.envelope.data[4].Y * 0.24 - 1);
Expand Down
Loading