public NoteHitInfo HitTestNote(Point mousePos) { NoteHitInfo result = default; int tick = (int)(midiVM.CanvasToQuarter(mousePos.X) * Project.Resolution); foreach (UNote note in midiVM.Part.Notes) { if (note.PosTick <= tick && note.EndTick >= tick) { result.note = note; result.hitX = true; var noteNum = midiVM.CanvasToNoteNum(mousePos.Y); if (noteNum == note.NoteNum) { result.hitVibrato = false; result.hitBody = true; double x = midiVM.QuarterToCanvas((double)note.EndTick / Project.Resolution); result.hitResizeArea = mousePos.X <= x && mousePos.X > x - UIConstants.ResizeMargin; break; } else if (noteNum == note.NoteNum - 1) { result.hitVibrato = true; } } } return(result); }
public NoteHitInfo HitTestExp(Point mousePos) { NoteHitInfo result = default; int tick = (int)(midiVM.CanvasToQuarter(mousePos.X) * Project.resolution); foreach (UNote note in midiVM.Part.notes) { foreach (var phoneme in note.phonemes) { int left = note.position + phoneme.position; int right = note.position + phoneme.position + phoneme.Duration; if (left <= tick && tick <= right) { result.note = note; result.phoneme = phoneme; result.hitX = true; return(result); } } } return(result); }