Skip to content

Commit

Permalink
Merge pull request #881 from lennyservant/fix-notebend-entanglement
Browse files Browse the repository at this point in the history
fix note bend entanglement when changing portamento in note properties
  • Loading branch information
stakira authored Oct 10, 2023
2 parents 658ac98 + 81603a7 commit 0895b44
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
29 changes: 24 additions & 5 deletions OpenUtau.Core/Commands/ExpCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,35 @@ public ResetPitchPointsCommand(UVoicePart part, UNote note) : base(part) {
}

public class SetPitchPointsCommand : PitchExpCommand {
UPitch oldPitch;
UPitch[] oldPitch;
UNote[] Notes;
UPitch newPitch;
public SetPitchPointsCommand(UVoicePart part, UNote note, UPitch pitch) : base(part) {
Note = note;
oldPitch = note.pitch;
Notes = new UNote[] { note };
oldPitch = Notes.Select(note => note.pitch).ToArray();
newPitch = pitch;
}

public SetPitchPointsCommand(UVoicePart part, IEnumerable<UNote> notes, UPitch pitch) : base(part) {
Notes = notes.ToArray();
oldPitch = Notes.Select(note => note.pitch).ToArray();
newPitch = pitch;
}
public override string ToString() => "Set pitch points";
public override void Execute() => Note.pitch = newPitch;
public override void Unexecute() => Note.pitch = oldPitch;
public override void Execute(){
lock (Part) {
for (var i=0; i<Notes.Length; i++) {
Notes[i].pitch = newPitch.Clone();
}
}
}
public override void Unexecute() {
lock (Part) {
for (var i = 0; i < Notes.Length; i++) {
Notes[i].pitch = oldPitch[i];
}
}
}
}

public class SetCurveCommand : ExpCommand {
Expand Down
8 changes: 2 additions & 6 deletions OpenUtau/ViewModels/NotePropertiesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,7 @@ private void SetValueChanges() {
var pitch = new UPitch() { snapFirst = true };
pitch.AddPoint(new PitchPoint(PortamentoStart, 0));
pitch.AddPoint(new PitchPoint(PortamentoStart + PortamentoLength, 0));
foreach (UNote note in selectedNotes) {
DocManager.Inst.ExecuteCmd(new SetPitchPointsCommand(Part, note, pitch));
}
DocManager.Inst.ExecuteCmd(new SetPitchPointsCommand(Part, selectedNotes, pitch));
}
}
});
Expand All @@ -280,9 +278,7 @@ private void SetValueChanges() {
var pitch = new UPitch() { snapFirst = true };
pitch.AddPoint(new PitchPoint(PortamentoStart, 0));
pitch.AddPoint(new PitchPoint(PortamentoStart + PortamentoLength, 0));
foreach (UNote note in selectedNotes) {
DocManager.Inst.ExecuteCmd(new SetPitchPointsCommand(Part, note, pitch));
}
DocManager.Inst.ExecuteCmd(new SetPitchPointsCommand(Part, selectedNotes, pitch));
}
}
});
Expand Down

0 comments on commit 0895b44

Please sign in to comment.