Skip to content

Commit

Permalink
try
Browse files Browse the repository at this point in the history
  • Loading branch information
YeonV committed Oct 5, 2024
1 parent b5f67c4 commit 13fb777
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/components/Midi/MidiListener.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ const MIDIListener = () => {
if (!input || input.name !== midiInput) return

if (input) {
input.removeListener('noteon')
input.removeListener('noteoff')
input.removeListener('controlchange')
input?.removeListener('noteon')
input?.removeListener('noteoff')
input?.removeListener('controlchange')
}

input.addListener('noteon', (event: any) => {
Expand Down Expand Up @@ -218,15 +218,17 @@ const MIDIListener = () => {
if (value.command && value.command !== 'scene' && value.command !== 'none') {
if (output) {
try {
output.send([0x90, buttonNumber, parseInt(value.colorCommand || commandColor, 16) || 99])
// output.send([0x90, buttonNumber, parseInt(value.colorCommand || commandColor, 16) || 99])
output.send([parseInt(`0x${midiMapping[0][buttonNumber]?.typeCommand}`) || 0x90, buttonNumber, parseInt(midiMapping[0][buttonNumber]?.colorCommand || commandColor || '3C', 16)])
} catch (error) {
console.error('Error sending MIDI message:', error)
}
}
} else if (value.command === 'scene') {
if (output) {
try {
output.send([0x90, buttonNumber, parseInt(value.colorSceneInactive, 16) || 60])
// output.send([0x90, buttonNumber, parseInt(value.colorSceneInactive, 16) || 60])
output.send([parseInt(`0x${midiMapping[0][buttonNumber]?.typeSceneInactive}`) || 0x90, buttonNumber, parseInt(midiMapping[0][buttonNumber]?.colorSceneInactive || midiSceneInactiveColor || '3C', 16)])
} catch (error) {
console.error('Error sending MIDI message:', error)
}
Expand Down Expand Up @@ -290,11 +292,11 @@ const MIDIListener = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [scenes, sceneDialogOpen, midiInitialized])

useEffect(() => {
return () => {
WebMidi.disable()
}
}, [])
// useEffect(() => {
// return () => {
// WebMidi.disable()
// }
// }, [])

// init midiMapping from scenes
useEffect(() => {
Expand Down

0 comments on commit 13fb777

Please sign in to comment.