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

xonek2

v0.1.3

Published

Node api for the awesome XONE:K2 MIDI controller by Allen & Heath

Downloads

3

Readme

Allen & Heath XONE:K2 Node.js api

This module wraps the MIDI interface to communicate with the XONE:K2 in a sane api for Node.

Install

npm install xonek2

Setup

Plug in the controller ( ͡° ͜ʖ ͡°)

var xonek2 = require('xonek2');
var controller = xonek2.create();

if (!controller.connect())
  throw new Error("Can't connect to device");

Layout

The controller has 4 channels

// Access the third channel
var channel = controller.channels[2];

Each channel has an endless knob at the top, 3 standard knobs, a fader and 4 buttons

channel.endless_knob
channel.knobs[1] // The second knob
channel.fader
channel.buttons[3] // The last button

Standard knobs have a button beneath them, endless knobs are buttons themselves (on push).

channel.knobs[0].button
channel.endless_knob.button

Buttons and knobs have leds attached

channel.endless_knob.led
channel.knobs[2].button.led
channel.buttons[0].led

The two big buttons and the central endless knobs at the bottom can be accessed through controller.utils

controller.utils.buttons[1] // The "EXIT SETUP" button
controller.utils.endless_knobs[0]

Usage

All the components (except for leds) emit events.
The original midi message is sent along, in case you want to route it to a virtual midi device or something.

Buttons
var button = controller.channels[0].buttons[1]; // The "E" button

button.on('press', function() {
  console.log('Button pressed');
});

button.on('release', function() {
  console.log('Button released');
});
Knobs
var knob = controller.channels[3].knobs[1]; // The second knob on the last channel

knob.on('update', function(value, midi_msg) {
  console.log('Knob twisted: the value is (0-1): ' + value);
});
Faders
var fader = controller.channels[1].fader; // The fader on the second channel

fader.on('update', function(value, midi_msg) {
  console.log('Fader moved: the value is (0-1): ' + value);
});
Endless knobs
var endless_knob = controller.channels[0].endless_knob; // The endless knob on the first channel

endless_knob.on('update', function(value) {
  if (value == 1)
    console.log('Turnin right');

  if (value == -1)
    console.log('Turnin left');
});
Leds

Leds can be lit up in three different colors: red (default), orange and green.

var led = controller.channels[2].knobs[0].button.led;
led.turn_on()

var led2 = controller.channels[0].endless_knob.led;
led2.turn_on(xonek2.COLOR_ORANGE);

var led3 = controller.channels[1].buttons[2].led;
led3.turn_on(xonek2.COLOR_GREEN);

Turn off a led

led.turn_off();

Turn off all leds

controller.reset_leds();

Testing

Testing is done with a virtual midi device (so you don't need to connect the controller).

npm test

License

Copyright (c) 2015, Marco Sampellegrini [email protected]

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.