Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
iconnectivity-midi-js
Advanced tools
[View the Live Demo](https://icjs.leolabs.org) | [NPM](https://npmjs.com/package/iconnectivity-midi-js)
This library allows you to communicate with newer 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.
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,
getDeviceName,
getFailoverState,
} from "iconnectivity-midi-js";
const example = async () => {
// Request access to MIDI devices.
// It's important to request SysEx access as well.
const midiAccess = await navigator.requestMIDIAccess({ sysex: true });
// Initialize the device manager.
// This will automatically trigger a search for devices.
const manager = new DeviceManager(midiAccess);
// Wait for the first device(s) to be found.
const devices = await manager.waitForDevices();
// At this point, we can be sure that at least one device was found.
const device = devices[0];
// Log some information about the device and its state.
console.log({
input: device.input.name,
output: device.output.name,
name: await getDeviceName({ device }),
});
// If the device is a PlayAUDIO1U,
// we can get the current failover state.
const failoverState = await getFailoverState({ device });
console.log({ failoverState });
};
example();
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 { getFailoverState } from "iconnectivity-midi-js";
// The device passed to this function could be
// one of the devices found by the DeviceManager.
const state = await getFailoverState({ 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 { getFailoverState } from "iconnectivity-midi-js";
const access = await navigator.requestMIDIAccess({ sysex: true });
// Get the first available MIDI input and output.
const input = access.inputs.values()[0];
const output = access.outputs.values()[0];
// We now send the request to the first MIDI output
// and listen to a response on the first MIDI input.
const state = await getFailoverState({
device: new Connection(input, output),
});
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 sendMessage
function. This
function allows you to For example:
import {
DataClassType,
DeviceInfo,
GetParmVal,
getResponseBody,
MessageOptions,
mergeNumber,
RetParmVal,
sendMessage,
} from "iconnectivity-midi-js";
/** Returns the number of MIDI ports the given device offers. */
const getPortCounts = async (options: MessageOptions) => {
const result = await sendMessage({
...options,
message: new GetParmVal(DataClassType.DeviceInfo, undefined, [
new ParmList([
DeviceInfo.DINInPortCount,
DeviceInfo.DINOutPortCount,
DeviceInfo.USBDPortCount,
DeviceInfo.USBHPortCount,
DeviceInfo.EthPortCount,
DeviceInfo.CtrlPortCount,
]),
]),
});
const body = getResponseBody(result);
const values = RetParmVal.fromData(body);
return {
midiIn: values.parmVals[0].values[0].data[0],
midiOut: values.parmVals[0].values[1].data[0],
usbDevice: values.parmVals[0].values[2].data[0],
usbHost: values.parmVals[0].values[3].data[0],
ethernet: values.parmVals[0].values[4].data[0],
control: values.parmVals[0].values[5].data[0],
};
};
console.log("Port count:", await getPortCount({ device }));
FAQs
[View the Live Demo](https://icjs.leolabs.org) | [NPM](https://npmjs.com/package/iconnectivity-midi-js)
The npm package iconnectivity-midi-js receives a total of 6 weekly downloads. As such, iconnectivity-midi-js popularity was classified as not popular.
We found that iconnectivity-midi-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.