From 669ac77c417df79ea197f296587d4a8a9347137e Mon Sep 17 00:00:00 2001 From: rokujyushi Date: Thu, 25 Jun 2026 22:12:00 +0900 Subject: [PATCH] Added pitch point support for portamento presets. The functionality to hold pitch points has been added to PortamentoPreset, allowing for the creation of portamento presets based on List. A "PortamentoPoints" tag has been added to the SetNoteParams method, enabling the setting of pitch points for selected notes. The SavePortamentoPreset method has been modified to include a process for saving presets based on the pitch points of the notes. --- OpenUtau.Core/Util/NotePresets.cs | 11 ++++++++ .../ViewModels/NotePropertiesViewModel.cs | 25 ++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/OpenUtau.Core/Util/NotePresets.cs b/OpenUtau.Core/Util/NotePresets.cs index ddf3c73b8..9265156dc 100644 --- a/OpenUtau.Core/Util/NotePresets.cs +++ b/OpenUtau.Core/Util/NotePresets.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; using Newtonsoft.Json; using OpenUtau.Core.Ustx; @@ -73,12 +74,22 @@ public class PortamentoPreset { public string Name = "Default"; public int PortamentoLength = 80; public int PortamentoStart = -40; + public List PitchPoints = new List(); + public PortamentoPreset() { } public PortamentoPreset (string name, int length, int start) { Name = name; PortamentoLength = length; PortamentoStart = start; } + public PortamentoPreset(string name, Listpoints) { + Name = name; + var start = points.FirstOrDefault()?.X ?? 0; + var end = points.LastOrDefault()?.X ?? 0; + PortamentoLength = (int)(end - start); + PortamentoStart = (int)(start); + PitchPoints = points; + } public override string ToString() => Name; } diff --git a/OpenUtau/ViewModels/NotePropertiesViewModel.cs b/OpenUtau/ViewModels/NotePropertiesViewModel.cs index f50b19ab1..3ab6c29f1 100644 --- a/OpenUtau/ViewModels/NotePropertiesViewModel.cs +++ b/OpenUtau/ViewModels/NotePropertiesViewModel.cs @@ -101,6 +101,7 @@ public NotePropertiesViewModel() { PanelControlPressed = true; SetNoteParams("PortamentoLength", portamentoPreset.PortamentoLength); SetNoteParams("PortamentoStart", portamentoPreset.PortamentoStart); + SetNoteParams("PortamentoPoints", portamentoPreset.PitchPoints); PanelControlPressed = false; DocManager.Inst.EndUndoGroup(); } @@ -474,11 +475,11 @@ public void SetNoteParams(string tag, object? obj) { if (string.IsNullOrEmpty(newOverride)) { newOverride = null; } - + DocManager.Inst.StartUndoGroup("command.property.edit"); foreach (UNote note in selectedNotes) { if (note.PhonemizerOverride != newOverride) { - DocManager.Inst.ExecuteCmd(new ChangeNotePhonemizerCommand(Part, note, newOverride)); + DocManager.Inst.ExecuteCmd(new ChangeNotePhonemizerCommand(Part, note, newOverride)); } } DocManager.Inst.EndUndoGroup(); @@ -548,6 +549,15 @@ public void SetNoteParams(string tag, object? obj) { } } } + } else if (tag == "PortamentoPoints") { + foreach (var note in selectedNotes) { + if (obj is List list) { + if (list.Count < 2) { + return; + } + DocManager.Inst.ExecuteCmd(new SetPitchPointsCommand(Part, note, new UPitch() { data = list })); + } + } } else if (tag == "PitchCurveShape") { if (obj != null && (obj is int value || int.TryParse(obj.ToString(), out value)) && Enum.IsDefined(typeof(PitchPointShape), value)) { DocManager.Inst.ExecuteCmd(new SetPitchPointShapeCommand(Part, selectedNotes, (PitchPointShape)value)); @@ -699,7 +709,16 @@ public void SavePortamentoPreset(string name) { if (string.IsNullOrEmpty(name)) { return; } - NotePresets.Default.PortamentoPresets.Add(new NotePresets.PortamentoPreset(name, (int)PortamentoLength, (int)PortamentoStart)); + var note = selectedNotes.FirstOrDefault(); + if (note != null) { + if (note.pitch.data.Count > 2) { + NotePresets.Default.PortamentoPresets.Add(new NotePresets.PortamentoPreset(name, note.pitch.data)); + } else { + NotePresets.Default.PortamentoPresets.Add(new NotePresets.PortamentoPreset(name, (int)PortamentoLength, (int)PortamentoStart)); + } + } else { + NotePresets.Default.PortamentoPresets.Add(new NotePresets.PortamentoPreset(name, (int)PortamentoLength, (int)PortamentoStart)); + } NotePresets.Save(); PortamentoPresets = new ObservableCollection(NotePresets.Default.PortamentoPresets); }