try/catch on midi events
when a device was plugged in it sometimes emitted a noteoff without a noteon which caused an error
This commit is contained in:
parent
5602b1ac88
commit
dd1bee2c3c
@ -47,10 +47,18 @@ class Midi extends events.EventEmitter{
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
inputDevice.addListener('noteon', 'all', (event) => {
|
inputDevice.addListener('noteon', 'all', (event) => {
|
||||||
|
try {
|
||||||
this.emit('keyDown', event.note.number)
|
this.emit('keyDown', event.note.number)
|
||||||
|
} catch(e){
|
||||||
|
console.warn(e)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
inputDevice.addListener('noteoff', 'all', (event) => {
|
inputDevice.addListener('noteoff', 'all', (event) => {
|
||||||
|
try {
|
||||||
this.emit('keyUp', event.note.number)
|
this.emit('keyUp', event.note.number)
|
||||||
|
} catch(e){
|
||||||
|
console.warn(e)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user