Grants access to midi devices via native libraries or WebMIDI.
npm install capacitor-midiGrants access to midi devices via native libraries or WebMIDI.
❗Currently NO iOS support. Because I don't have access to a Mac. Contributors Welcome❗
``bash`
npm install capacitor-midi
npx cap sync
#### Open device and subscribe to MidiMessages
`typescript
const options: DeviceOptions = {
deviceNumber: 0 // Choose device from listMIDIDevices()
}
this.devices = await MIDI.listMIDIDevices();
MIDI.addListener('MIDI_MSG_EVENT', (message: MidiMessage) => {
console.log(message);
});
``
#### Subscribe to device connection changestypescript
await MIDI.initConnectionListener();
MIDI.addListener('MIDI_CON_EVENT', (devices: { value: string[] }) => {
console.log(devices.value);
});
`
* listMIDIDevices()
* openDevice(...)
* initConnectionListener()
* addListener(...)
* addListener(...)
* Interfaces
`typescript`
listMIDIDevices() => Promise<{ value: string[]; }>
Returns: Promise<{ value: {}; }>
--------------------
`typescript`
openDevice(options: DeviceOptions) => Promise
| Param | Type |
| ------------- | ------------------------------------------------------- |
| options | DeviceOptions |
--------------------
`typescript`
initConnectionListener() => Promise
--------------------
`typescript`
addListener(eventName: 'MIDI_MSG_EVENT', listenerFunc: (message: MidiMessage) => void) => Promise
| Param | Type |
| ------------------ | ------------------------------------------------------------------------- |
| eventName | "MIDI_MSG_EVENT" |
| listenerFunc | (message: MidiMessage) => void |
Returns: Promise<PluginListenerHandle>
--------------------
`typescript`
addListener(eventName: 'MIDI_CON_EVENT', listenerFunc: (devices: { value: string[]; }) => void) => Promise
| Param | Type |
| ------------------ | ------------------------------------------------- |
| eventName | "MIDI_CON_EVENT" |
| listenerFunc | (devices: { value: {}; }) => void |
Returns: Promise<PluginListenerHandle>
--------------------
#### DeviceOptions
| Prop | Type |
| ------------------ | ------------------- |
| deviceNumber | number |
#### PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
#### MidiMessage
| Prop | Type |
| -------------- | ------------------- |
| type | string |
| note | number |
| velocity` | number |