Skip to content
Merged
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
7 changes: 5 additions & 2 deletions OpenUtau/ViewModels/NotesViewModelHitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,18 @@ public PitchPointHitInfo HitTestPitchPoint(Point point) {
return null;
}
double tick = viewModel.PointToTick(point);
var phrase = viewModel.Part.renderPhrases.FirstOrDefault(p => p.end >= tick);
double absTick = tick + viewModel.Part.position;

var phrase = viewModel.Part.renderPhrases.FirstOrDefault(p => p.end >= absTick);
if (phrase == null) {
phrase = viewModel.Part.renderPhrases.Last();
}
if (phrase == null || phrase.pitchesBeforeDeviation.Length == 0) {
return null;
}
var curve = phrase.pitchesBeforeDeviation;
var pitchIndex = (int)Math.Round((tick - phrase.position + phrase.leading) / 5);
int phraseStartRel = phrase.position - viewModel.Part.position;
var pitchIndex = (int)Math.Round((tick - phraseStartRel + phrase.leading) / 5.0);
pitchIndex = Math.Clamp(pitchIndex, 0, curve.Length - 1);
return curve[pitchIndex];
}
Expand Down
Loading