Skip to content

Commit

Permalink
reinit MIDI after sceneEdit. Realtime update on device
Browse files Browse the repository at this point in the history
  • Loading branch information
YeonV committed Oct 5, 2024
1 parent dfa3008 commit 5b62817
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/Dialogs/SceneDialogs/EditSceneDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,9 @@ const EditSceneDialog = () => {
newMapping[0][item] = { buttonNumber: currentBtnNumber };
console.log('mapping after', newMapping);
setMidiMapping(newMapping);
initMidi();
setTimeout(() => {
initMidi();
}, 100);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/Midi/MidiListener.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const MIDIListener = () => {
const setMidiOutputs = useStore((state) => state.setMidiOutputs)
const setMidiInput = useStore((state) => state.setMidiInput)
const setMidiOutput = useStore((state) => state.setMidiOutput)
const recentScenes = useStore((state) => state.recentScenes)
const midiInput = useStore((state) => state.midiInput)
const midiOutput = useStore((state) => state.midiOutput)
const midiMapping = useStore((state) => state.midiMapping)
Expand Down Expand Up @@ -105,7 +106,7 @@ const MIDIListener = () => {
} else if (value.command === 'scene') {
if (output && buttonNumber !== -1) {
try {
output.send([parseInt(`0x${value.typeSceneInactive}`) || 0x90, buttonNumber, parseInt(value.colorSceneInactive || midiSceneInactiveColor, 16) || 60])
output.send([parseInt(`0x${value.typeSceneInactive}`) || 0x90, buttonNumber, parseInt(value.payload?.scene === recentScenes[0] ? (value.colorSceneActive || midiSceneActiveColor) : (value.colorSceneInactive || midiSceneInactiveColor), 16) || 60])
} catch (error) {
console.error('Error sending MIDI message:', error)
}
Expand Down

0 comments on commit 5b62817

Please sign in to comment.