npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pirate-midi-usb

v3.2.0

Published

Easily interact with Pirate Midi devices over USB from JavaScript

Downloads

55

Readme

pirate-midi-usb

npm package Build Status Downloads Issues Code Coverage Commitizen Friendly Semantic Release

Easily interact with Pirate Midi devices over USB from JavaScript

[!WARNING]
The device API was overhauled in Bridge OS 2.x - Use [email protected] to interact with devices on Bridge OS 1.x (or just upgrade, it's great)

Install

npm install pirate-midi-usb

Usage

import { getDevices } from 'pirate-midi-usb';

const devices = await getDevices();

await device[0].goToBank(2);

API

This package implements the Pirate Midi Device API to interact with Bridge4 and Bridge6 devices, see the API documentation for the underlying details.

Use getDevices to retrieve available devices

Scans USB devices and returns a promise with an array of PirateMidiDevice instances (one per device) to interact with.

Note In the browser a dialog will be triggered for the user to select and give access to a single device. Currently only a single device will be returned.

import { getDevices } from 'pirate-midi-usb';

const devices = await getDevices();

const bridge6 = device.find(device => device.deviceName === 'Bridge6');

Each instance of a device is returned with the deviceInfo prefetched. This information could be used to select a specific device when multiple are connected. When no devices are found an empty array will be returned

Use PirateMidiDevice methods to interact with the device

Check PirateMidiDevice.ts to see all implemented methods.

Managing the connection

Devices may be plugged out while your app/script is running. When a device it returned it is ready to use but you should monitor the connection and respond accordingly to avoid interacting with an unavailable device:

const [device] = await getDevices();

// Activate UI

device.on('disconnect', () => {
  // Deactivate UI
});

// When the same device is plugged in again the instance will auto-reconnect and fire a "connect" event.
device.on('connect', () => {
  // Activate UI
});

Note This behaviour is only implemented for browsers at the moment.

Mock device

To aid in testing or running a demo, a mock device can be created using getMockDevice:

// Provide device data to the mock
const device = await getMockDevice({
  deviceInfo,
  globalSettings,
  bankSettings,
});

// Methods will behave as if a real device is connected BUT it's state will never change from the data given.
device.getGlobalSettings()

The mock device is static, set.. and control methods will respond as usual but have no actual effect.

Debugging

Debugging is enabled via a debug-like logger.

In Node, use environment variables to enable logging. The logs can be filtered by prefix and wildcards.

  • DEBUG=pmu:* - high level logs
  • DEBUG=pmu-verbose:* - verbose (large output!) logs
  • DEBUG=pmu:runCommand - a specific feature
  • DEBUG=pmu:runCommand,pmu:sendReceive - multiple features
  • DEBUG=pmu* - all logs from this library
  • DEBUG=* - all debug logs (note this may include other libraries in your app)

In the browser, set the same values to localStorage.debug.

Examples

See the examples folder, check out the intro example to get started!

Run examples by their filename:

npm run examples:intro

Thanks

Thanks to Pirate Midi for the awesome devices and the openness.

This repo was started with typescript-npm-package-template