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

akai-apc-mini-mk2

v0.2.0

Published

Web-midi wrapper for AKAI APC Mini Mk2

Downloads

2

Readme

Web-MIDI wrapper for AKAI APC Mini Mk2

This package makes it simple to access your AKAI APC Mini Mk2's state in browser, using the web-midi API. In essence:

  1. Get your hands on an AKAI APC Mini Mk2
  2. Plug it in your device through USB (works on smartphones too!)
  3. Open up a web browser running your website with the library's code (note: chromium on linux currently broken - use firefox instead)
  4. Profit!

WIP Disclaimer - unstable API

This package is still very much work in progress, and the API is bound to change.

Install

npm install akai-apc-mini-mk2

Initialization

let mk2 = new APCMiniMk2();
mk2.connect({sysex: true}).then(() => {
    // run some commands right on startup (e.g. turning on the LEDs)
    console.log("Midi connected!");

    // set pad at cordinates [3,3] to blueish (you can use hex)
    mk2.pad33.color = "#123456";

    // set pad at coordinates [1,1] to white and pulse
    mk2.pad11.color = "#ff0000";
    mk2.pad11.pulse();

    // set button color and blink rates using AKAI's values
    mk2.buttons[7].color = [3, 15];

    // light up the volume button
    mk2.volumeButton.toggled = true;

    // access fader values via `.fader[0-8]`
    console.log("Current value of the lef-most fader:", mk2.fader0.value);
});

// the events will be broadcast globally, bubbling from the currently focused element - just like
// they
document.addEventListener("cc", evt => {
    console.log(evt.key, "changed to", evt.value, evt);
});

document.addEventListener("noteon", evt => {
    console.log("Button press", evt);
});

document.addEventListener("noteoff", evt => {
    console.log("Button release", evt);
});

Cleanup

Call .disconnect() in your cleanup routines - it will remove all system-level event listeners as well as any listeners you might have attached. Also, don't forget to call document.removeEventListener on any MIDI events

Events

Use document's addEventListener(eventType, callback) and removeEventListener(eventType, callback) to subscribe to the events. Events:

  • cc - fired on slider/dial turn. Extra data in the event: {note, key, val, prevVal, button}
  • noteon / noteoff - fired when any of the buttons are pressed and released. Extra data in the event: {note, key, button}
  • sysex - when the device sends a sysex message. Generally won't be useful to you, but you can trigger a sysex message by pressing Shift+Drum on the APC Mk2.