メインコンテンツまでスキップ

midi/input

Interfaces

MIDIInputInstance

Defined in: dom/src/midi/input.ts:49

Properties

destroy
destroy: () => void;

Defined in: dom/src/midi/input.ts:52

Returns

void

update
update: (handlers) => void;

Defined in: dom/src/midi/input.ts:51

Replace the handlers, keeping the listeners in place.

Parameters
ParameterType
handlersMIDIInputHandlers
Returns

void

Type Aliases

MIDIInputHandlers

type MIDIInputHandlers = object;

Defined in: dom/src/midi/input.ts:26

Every handler is given the channel last, as 0-15. MIDI channels are written 1-16 on hardware, so add one before showing it to anyone.

Properties

onAftertouchEvent?
optional onAftertouchEvent?: (note, pressure, channel) => void;

Defined in: dom/src/midi/input.ts:44

Pressure for one held note (polyphonic aftertouch).

Parameters
ParameterType
notenumber
pressurenumber
channelnumber
Returns

void

onChannelPressureEvent?
optional onChannelPressureEvent?: (pressure, channel) => void;

Defined in: dom/src/midi/input.ts:46

Pressure for the whole channel, sent by keyboards with one sensor.

Parameters
ParameterType
pressurenumber
channelnumber
Returns

void

onControlChangeEvent?
optional onControlChangeEvent?: (controller, value, channel) => void;

Defined in: dom/src/midi/input.ts:37

controller is the CC number, value is 0-127.

Parameters
ParameterType
controllernumber
valuenumber
channelnumber
Returns

void

onNoteOffEvent?
optional onNoteOffEvent?: (note, channel) => void;

Defined in: dom/src/midi/input.ts:28

Parameters
ParameterType
notenumber
channelnumber
Returns

void

onNoteOnEvent?
optional onNoteOnEvent?: (note, velocity, channel) => void;

Defined in: dom/src/midi/input.ts:27

Parameters
ParameterType
notenumber
velocitynumber
channelnumber
Returns

void

onPitchBendEvent?
optional onPitchBendEvent?: (value, channel) => void;

Defined in: dom/src/midi/input.ts:35

The 14-bit bend, 0-16383, centred at PITCH_BEND_CENTER.

The two data bytes are little-endian — the first carries the low 7 bits — which is the other way round from every other message.

Parameters
ParameterType
valuenumber
channelnumber
Returns

void

onProgramChangeEvent?
optional onProgramChangeEvent?: (program, channel) => void;

Defined in: dom/src/midi/input.ts:42

Parameters
ParameterType
programnumber
channelnumber
Returns

void

Variables

PITCH_BEND_CENTER

const PITCH_BEND_CENTER: 8192 = 8192;

Defined in: dom/src/midi/input.ts:20

Centre of the 14-bit pitch bend range: no bend.

The range is not symmetric — 0 is 8192 below centre and 16383 is 8191 above — so a wheel at rest reports exactly this rather than half of the maximum.

Functions

createMIDIInput()

function createMIDIInput(midiAccess, handlers): MIDIInputInstance;

Defined in: dom/src/midi/input.ts:63

Handle the channel voice messages of every connected input. To be used with createMIDIAccess. Internally uses createMIDIMessage, so devices plugged in later are picked up.

System messages (clock, sysex, and the rest of 0xf0-0xff) are not decoded here; reach for createMIDIMessage for those.

Parameters

ParameterType
midiAccessMIDIAccess | null
handlersMIDIInputHandlers

Returns

MIDIInputInstance