Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
YeonV committed Oct 5, 2024
1 parent cb30fe2 commit ba882e1
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions src/components/Midi/MidiListener.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,28 +215,7 @@ const MIDIListener = () => {
handleMidiInput(input)
})
}
if (output) {
Object.entries(midiMapping[0]).forEach(([key, value]) => {
const buttonNumber = value.buttonNumber
if (value.command !== 'scene' && value.command && value.command !== 'none' && buttonNumber !== -1) {
if (output) {
try {
output.send([parseInt(`0x${value.typeCommand}`) || 0x90, buttonNumber, parseInt(value.colorCommand || commandColor, 16) || 99])
} catch (error) {
console.error('Error sending MIDI message:', error)
}
}
} else if (value.command === 'scene') {
if (output && buttonNumber !== -1) {
try {
output.send([parseInt(`0x${value.typeSceneInactive}`) || 0x90, buttonNumber, parseInt(value.colorSceneInactive || midiSceneInactiveColor, 16) || 60])
} catch (error) {
console.error('Error sending MIDI message:', error)
}
}
}
})
}

}
}
})
Expand All @@ -249,6 +228,28 @@ const MIDIListener = () => {

const handleWebsockets = (event: any) => {
const output = WebMidi.getOutputByName(midiOutput)
if (output) {
Object.entries(midiMapping[0]).forEach(([key, value]) => {
const buttonNumber = value.buttonNumber
if (value.command !== 'scene' && value.command && value.command !== 'none' && buttonNumber !== -1) {
if (output) {
try {
output.send([parseInt(`0x${value.typeCommand}`) || 0x90, buttonNumber, parseInt(value.colorCommand || commandColor, 16) || 99])
} catch (error) {
console.error('Error sending MIDI message:', error)
}
}
} else if (value.command === 'scene') {
if (output && buttonNumber !== -1) {
try {
output.send([parseInt(`0x${value.typeSceneInactive}`) || 0x90, buttonNumber, parseInt(value.colorSceneInactive || midiSceneInactiveColor, 16) || 60])
} catch (error) {
console.error('Error sending MIDI message:', error)
}
}
}
})
}
try {
if (event.type === 'scene_activated') {
const { scene_id } = event.detail
Expand Down

0 comments on commit ba882e1

Please sign in to comment.