fix: piano roll spectrogram is not being zoomed correctly; switching from MIDI region to audio region with piano roll open might cause residual notes.

This commit is contained in:
Xiaohan-Tian
2026-05-01 23:56:12 -07:00
parent 811b3a0936
commit 5890a6d0b9
4 changed files with 42 additions and 16 deletions
@@ -34,6 +34,7 @@ interface PianoRollContentProps {
bpm?: number;
spectrogramThresholdDb?: number;
spectrogramPower?: number;
pianoRollZoom?: number;
}
const PianoRollContent: React.FC<PianoRollContentProps> = ({
@@ -56,6 +57,7 @@ const PianoRollContent: React.FC<PianoRollContentProps> = ({
bpm = 120,
spectrogramThresholdDb = -25,
spectrogramPower = 0.5,
pianoRollZoom = 1,
}) => {
const isSpectrogram = mode === 'spectrogram';
// Get KGCore instance
@@ -234,7 +236,7 @@ const PianoRollContent: React.FC<PianoRollContentProps> = ({
/>
);
});
}, [activeRegion, noteUpdateCounter, resizingNoteId, draggingNoteId, tempNoteStyles, selectedNoteIds, selectionBoxRender, tracks]);
}, [mode, activeRegion, noteUpdateCounter, resizingNoteId, draggingNoteId, tempNoteStyles, selectedNoteIds, selectionBoxRender, tracks]);
const recordingNoteOverlays = useMemo(() => {
if (!isRecording || !activeRegion || recordingNotes.length === 0) return null;
@@ -281,6 +283,7 @@ const PianoRollContent: React.FC<PianoRollContentProps> = ({
bpm={bpm}
spectrogramThresholdDb={spectrogramThresholdDb}
spectrogramPower={spectrogramPower}
pianoRollZoom={pianoRollZoom}
>
{memoizedNotes}
{!isSpectrogram && recordingNoteOverlays}