Skip to main content

MIDI state

Every time a handler is called, it will get passed a midi state that includes the source event and adds multiple attributes.

MIDI Shared State

StateDescription
fadingTrue if the target is being faded.
notingTrue if the target is being noted.
turningTrue if the target is being turned.
targetTrue when the Midi is active.
messagingTrue if the target is being messaged.
requestedTrue when user grant permission to access MIDI devices.
supportedTrue when Web MIDI API is supported by the browser.
allowedTrue when user gave permission to access MIDI devices.

MIDI Generic State

StateDescription
eventRaw Midi Event Object.
targetRaw Event Target Object.
typeRaw Midi Event type.
activeTrue when the Midi is active.
blockedTrue when theM idi is blocked.
enabledTrue when the Midi is enabled.
firstTrue when its the first event.
lastTrue when its the last event.
startTimeThe start time of the current event.
deltaTimeThe delta between current and previous event.
timeStampThe timestamp of the current event.
elapsedTimeElapsed tie of the current Midi.
initRaw values when the Midi started.
dataCurrent raw values of the Midi.
prevPrevious raw values of the Midi.
deltaBetween current raw Midi values and previous values.
signDirection of the delta values.
valueThe number of Midi velocity number if recieved.
delayThe number of delay time stamp when send.
commandThe number of recieved Midi command code.
channelThe number of recieved Midi channel number.
noteThe number of Midi note number if recieved.
argsThe arguments when you bind.

MIDI state attributes

With the exception of xy and vxvy, all attributes bellow are common to all accesses.

const bind = useNote(state => {
const { data } = state
})

Note state attributes

The note midi state adds a few attributes whih can help you understand the user intent.

const bind = useXXX(state => {})