A node library for interacting with the Novation Launchpad.
You can install Launchpadder via npm:
$ npm install launchpadder
I tried to make usage as straightforward as possible:
var launchpadder = require("./launchpadder").Launchpad;
var launchpadColor = require("./launchpadder").Color;
// The 0 represents the MIDI port to connect with
// The 1 represents the MIDI output-port to connect with
// Both arguments are optional and default to 0
var pad = new launchpadder(0, 1);
pad.on("press", function(button) {
button.light(launchpadColor.RED);
console.log(button + " was pressed");
});
pad.on("release", function(button) {
button.dark();
console.log(button + " was released");
});
Launchpadder was made because I felt that such a simple piece of hardware should also have a simple API behind it. If you feel that any part of the software doesn't follow this philosphy, feel free to open an issue and I'll look into it. So without further adieu, the Launchpadder API:
Represents the launchpad as a whole.
Constructor. To create a new instance of the Launchpad class you may include a midi port to connect to (probably 0, unless you have a much cooler MIDI setup than I do). Both of these values are optional, however.
Gets the button at coordinate x, y. If y is undefined, the method assumes you are providing it with a Launchpad-specific MIDI note and will attempt to convert it into x, y coordinates.
Sets all of the LEDs to dark. This method works by sending the reset command to the Launchpad (not sending Color.OFF to each button).
Returns the X-coordinate for a Launchpad-specific MIDI note.
Returns the Y-coordinate for a Launchpad-specific MIDI note.
This class also inherits methods frome Node's event.EventEmitter. Possible events to listen for are:
press
release
Both events emit the button object as an argument. Eg:
launchpad.on("press", function(button) {
// Do something awesome...
})
Represents each individual button on the launchpad. Only obtainable through the Launchpad
class.
Returns the X-coordinate of the button.
Returns the Y-coordinate of the button.
Turns on the button's LED with the specified color (see Color
object for color constants). If no color is provided, it defaults to amber.
Turns off the button's LED.
Returns true when the Button is lit up. Optionally: specify "color" to validate against a certain color.
Gets the button's current state, returns a MIDI representation of the color. See Color
class below.
Toggles the button's state between two colors. The first color defaults to amber if unspecified, the second to off. If the current color is neither of the two values, the second value is used.
Starts blinking the button in the specified color (defaults to amber). The timeout is set at 500ms.
Stops blinking the button.
Returns true or false depending if the button is blinking or not.
Returns a string representation of the button's coordinates in (x, y)
format.
Converts the x, y coordinates of the button into the Launchpad-specific MIDI representation. See the Launchpad
class to get the x and y values back.
This class also inherits methods frome Node's event.EventEmitter. Possible events to listen for are:
press
release
Both events emit the button object as an argument (much like the Launchpad class).
Represents a Launchpad-specific MIDI color.
Returns the MIDI color representing your red and green light values (values can be 0 up to a maximum of 3). Both values default to 0, and therefore getColor()
will return value 12 (which is off; see static colors below).
Returns the green value (0 to 3) of the specified MIDI note.
Returns the red value (0 to 3) of the specified MIDI note.
Launchpadder comes with several static values stored in the Color
class which can be used to light up buttons.
#OFF
: 12#LOW_RED
: 13#RED
: 15#LOW_AMBER
: 29#AMBER
: 63#LOW_GREEN
: 28#GREEN
: 60#YELLOW
: 62