capacitor-midi
v0.0.16
Published
Grants access to midi devices via native libraries or WebMIDI.
Readme
🎹 capacitor-midi
Grants access to midi devices via native libraries or WebMIDI.
❗Currently NO iOS support. Because I don't have access to a Mac. Contributors Welcome❗
🔌 Install
npm install capacitor-midi
npx cap sync🎼 Usage
Open device and subscribe to MidiMessages
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 changes
await MIDI.initConnectionListener();
MIDI.addListener('MIDI_CON_EVENT', (devices: { value: string[] }) => {
console.log(devices.value);
});🎛 API
listMIDIDevices()
listMIDIDevices() => Promise<{ value: string[]; }>Returns: Promise<{ value: {}; }>
openDevice(...)
openDevice(options: DeviceOptions) => Promise<void>| Param | Type |
| ------------- | ------------------------------------------------------- |
| options | DeviceOptions |
initConnectionListener()
initConnectionListener() => Promise<void>addListener(...)
addListener(eventName: 'MIDI_MSG_EVENT', listenerFunc: (message: MidiMessage) => void) => Promise<PluginListenerHandle>| Param | Type |
| ------------------ | ------------------------------------------------------------------------- |
| eventName | "MIDI_MSG_EVENT" |
| listenerFunc | (message: MidiMessage) => void |
Returns: Promise<PluginListenerHandle>
addListener(...)
addListener(eventName: 'MIDI_CON_EVENT', listenerFunc: (devices: { value: string[]; }) => void) => Promise<PluginListenerHandle>| Param | Type |
| ------------------ | ------------------------------------------------- |
| eventName | "MIDI_CON_EVENT" |
| listenerFunc | (devices: { value: {}; }) => void |
Returns: Promise<PluginListenerHandle>
Interfaces
DeviceOptions
| Prop | Type |
| ------------------ | ------------------- |
| deviceNumber | number |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
MidiMessage
| Prop | Type |
| -------------- | ------------------- |
| type | string |
| note | number |
| velocity | number |
