feat: implemented the logic to automatically create a chord when a suitable guide chord is highlighted.

This commit is contained in:
Xiaohan-Tian
2025-12-15 21:59:56 -08:00
parent fbd13eef9f
commit 54b227c1be
3 changed files with 100 additions and 16 deletions
+12
View File
@@ -167,6 +167,18 @@ const PianoGrid: React.FC<PianoGridProps> = ({
return highlights;
}, [cursorPosition, matchingChords, selectedChordIndex]);
const cursorPitch = cursorPosition?.pitch ?? null;
useEffect(() => {
const pianoRollState = KGPianoRollState.instance();
pianoRollState.setCurrentMatchingChords(matchingChords);
pianoRollState.setCurrentChordCursorPitch(cursorPitch);
}, [matchingChords, cursorPitch]);
useEffect(() => {
KGPianoRollState.instance().setCurrentSelectedChordIndex(selectedChordIndex);
}, [selectedChordIndex]);
const lastEditedNoteLength = KGPianoRollState.instance().getLastEditedNoteLength();
// Reset selected chord index when cursor moves to a different pitch or beat