iConnectivity JS
View the Live Demo |
NPM
This library allows you to communicate with
iConnectivity devices using JS and the
Web MIDI API.
It is still in very early development, but the basics already work.
The library's goal is to provide an abstraction layer that allows access to all
methods described in the
Common System Exclusive Commands
document.
Getting Started
If you want to check out a demo project, head over to the demo
package.
The easiest way to get started is using the DeviceManager
. Here's an example:
import {
DeviceManager,
getAllInfo,
getAutomaticFailoverState,
} from "iconnectivity-js";
const example = async () => {
const midiAccess = await navigator.requestMIDIAccess({ sysex: true });
const manager = new DeviceManager(midiAccess);
const devices = await manager.waitForDevices();
const device = devices[0];
console.log({
input: device.input.name,
output: device.output.name,
info: device.info,
extendedInfo: await getAllInfo({ device }),
});
const failoverState = await getAutomaticFailoverState({ device });
console.log({ failoverState });
};
example();
API Usage
You can use wrapper functions for supported commands, with more coming in the
future. A list of supported commands can be found below. For
example, to fetch the current failover state:
import { getAutomaticFailoverState } from "iconnectivity-js";
const state = await getAutomaticFailoverState({ device });
The device
property doesn't necessarily need to be a device that the
DeviceManager
outputs. You could also set it to a custom Connection
object:
import { getAutomaticFailoverState } from "iconnectivity-js";
const access = await navigator.requestMIDIAccess({ sysex: true });
const input = access.inputs.values()[0];
const output = access.outputs.values()[0];
const state = await getAutomaticFailoverState({
device: new Connection(input, output),
});
Sending Raw Commands
Even if a given command isn't wrapped by this library yet, you can still call it
and parse the response yourself by using the sendCommand
function. This
function allows you to For example:
import { CommandOptions, mergeNumber, sendCommand } from "iconnectivity-js";
const getMidiPortCount = async (options: CommandOptions) => {
const result = await sendCommand({
...options,
command: MidiCommand.GetMIDIInfo,
});
return mergeNumber(result.slice(19, 21));
};
console.log("Port count:", await getMidiPortCount({ device }));
Supported Devices
- mio10
- mio
- iConnectMIDI1
- iConnectMIDI2+
- iConnectMIDI4+
- iConnectAUDIO4+
- iConnectAUDIO2+
- mio2
- mio4
- PlayAUDIO12
- ConnectAUDIO2
- ConnectAUDIO4
Commands
This list contains all commands currently documented by iConnectivity. The ones
that already have a wrapper function are checked. If you want to contribute to
this list by writing wrapper functions for more commands, feel free to open a
PR.
Device Commands
MIDI Commands
Audio Commands (V2)
Audio Mixer Commands
Automation Control Commands
Advanced MIDI Processor (AMP) Commands
Snapshot Commands
getActiveScene
setActiveScene
Hardware Interface Commands
getAutomaticFailoverState
setAutomaticFailoverState