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:
Yotam Mann 2017-02-14 14:45:03 -05:00
parent 5602b1ac88
commit dd1bee2c3c

View File

@ -47,10 +47,18 @@ class Midi extends events.EventEmitter{
}
})
inputDevice.addListener('noteon', 'all', (event) => {
this.emit('keyDown', event.note.number)
try {
this.emit('keyDown', event.note.number)
} catch(e){
console.warn(e)
}
})
inputDevice.addListener('noteoff', 'all', (event) => {
this.emit('keyUp', event.note.number)
try {
this.emit('keyUp', event.note.number)
} catch(e){
console.warn(e)
}
})
}
}