Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Internal native API

Moti Zilberman edited this page Jun 29, 2016 · 3 revisions

Internal native API

This native interface expresses the Web MIDI API surface on top of React Native's JavaScript bridge machinery. It is then consumed by JavaScript code which implements the actual Web MIDI API.

EVENT_MIDIACCESS_ONSTATECHANGE

// Java/Android:
private static final String EVENT_MIDIACCESS_ONSTATECHANGE = "com.motiz88.rctmidi.webmidi.MIDIAccess#statechange";

statechange events from the MIDIAccess singleton are emitted with this event name.

EVENT_MIDIPORT_ONSTATECHANGE

// Java/Android:
private static final String EVENT_MIDIPORT_ONSTATECHANGE = "com.motiz88.rctmidi.webmidi.MIDIPort#statechange&id=";

statechange events from a MIDIPort are emitted with this event name, followed directly by the port's ID.

EVENT_MIDIINPUT_ONMIDIMESSAGE

// Java/Android:
private static final String EVENT_MIDIINPUT_ONMIDIMESSAGE = "com.motiz88.rctmidi.webmidi.MIDIInput#midimessage&id=";

midimessage events from a MIDIInput are emitted with this event name, followed directly by the port's ID.

requestMIDIAccess()

// Java/Android:
@ReactMethod public void requestMIDIAccess(ReadableMap options, Promise promise)

Initializes the MIDIAccess singleton and asynchronously returns its data fields as a WritableMap to the JS thread, where it is expected they will be merged into the existing object instance.

MIDIAccess_get_data()

// Java/Android:
@ReactMethod public void MIDIAccess_get_data(Promise promise)

Asynchronously returns the MIDIAccess singleton's data fields as a WritableMap to the JS thread, where it is expected they will be merged into the existing object instance.

MIDIAccess_setOnStateChange()

// Java/Android:
@ReactMethod public void MIDIAccess_setOnStateChange(final boolean attach, Promise promise)

Start or stop sending statechange events to the JS thread from the MIDIAccess singleton.

MIDIPort_open()

// Java/Android:
@ReactMethod public void MIDIPort_open(String id, Promise promise)

Opens a MIDIPort and asynchronously returns its data fields as a WritableMap to the JS thread, where it is expected they will be merged into the existing object instance.

MIDIPort_close()

// Java/Android:
@ReactMethod public void MIDIPort_close(String id, Promise promise)

Closes a MIDIPort and asynchronously returns its data fields as a WritableMap to the JS thread, where it is expected they will be merged into the existing object instance.

MIDIPort_setOnStateChange()

// Java/Android:
@ReactMethod public void MIDIPort_setOnStateChange(String id, final boolean attach, Promise promise)

Start or stop sending statechange events to the JS thread from a MIDIPort specified by ID.

MIDIInput_setOnMidiMessage()

// Java/Android:
@ReactMethod public void MIDIInput_setOnMidiMessage(String id, final boolean attach, Promise promise)

Start or stop sending midimessage events to the JS thread from a MIDIInput specified by ID.

MIDIOutput_send()

// Java/Android:
@ReactMethod public void MIDIOutput_send(String id, ReadableArray data, double timestamp, Promise promise)

Send the specified MIDI message to a MIDIOutput specified by ID.