Home Reference Source Repository
import Launchpad from 'launchpad-mk2'
public class | source

Launchpad

Extends:

EventEmitter → Launchpad

A Launchpad instance.

This class will emit two events:

  • press - Emitted when a button is pressed. Example usage:
myLaunchpad.on("press", pressInfo => {
  console.log(pressInfo.button, pressInfo.velocity)
})
  • release - Emitted when a button is released. Example usage:
myLaunchpad.on("release", button => {
  console.log(button)
})

Constructor Summary

Public Constructor
public

constructor(params: Object)

Creates an instance of Launchpad.

Member Summary

Public Members
public

All the buttons on this Launchpad.

Method Summary

Public Methods
public

Convenience method to darken all buttons on the Launchpad.

public

Get a button on this Launchpad

public

lightAll(color: Number)

Convenience method to light up all the buttons on the Launchpad a certain color.

public

Convenience method to light up all the buttons on the Launchpad a certain color with RGB values.

public

scrollText(text: String, color: Number, loop: Boolean, speed: Number)

Scroll text across the Launchpad.

public

sendSysEx(bytes: Number[])

Convenience method to add the system-exclusive message header to a message and then send it to the Launchpad.

public

toLayout(layout: String)

Set the Launchpad's layout.

Public Constructors

public constructor(params: Object) source

Creates an instance of Launchpad.

Params:

NameTypeAttributeDescription
params Object

The paramaters to instantiate the Launchpad.

params.in Number

The input port of the Launchpad.

params.out Number

The output port of the Launchpad.

Example:

let myLaunchpad = new Launchpad({
  in: 1,
  out: 1
})

Public Members

public buttons: Button[] source

All the buttons on this Launchpad. Get one by using getButton.

Public Methods

public darkAll() source

Convenience method to darken all buttons on the Launchpad.

Example:

myLaunchpad.darkAll()

public getButton(x: Number, y: Number): Button source

Get a button on this Launchpad

Params:

NameTypeAttributeDescription
x Number

The x-coordinate of the button.

y Number

The y-coordinate of the button.

Return:

Button

Example:

let button = myLaunchpad.getButton(1, 2)

// do whatever with the button
button.setRgbColor(10, 30, 10)

public lightAll(color: Number) source

Convenience method to light up all the buttons on the Launchpad a certain color.

Params:

NameTypeAttributeDescription
color Number

Note representation of the color.

Example:

myLaunchpad.lightAll(23)

public lightAllRgb(r: Number, g: Number, b: Number) source

Convenience method to light up all the buttons on the Launchpad a certain color with RGB values.

Params:

NameTypeAttributeDescription
r Number

Red value. 0-63

g Number

Green value. 0-63

b Number

Blue value. 0-63

Example:

myLaunchpad.lightAllRgb(10, 30, 10)

public scrollText(text: String, color: Number, loop: Boolean, speed: Number) source

Scroll text across the Launchpad.

Params:

NameTypeAttributeDescription
text String

The text to scroll.

color Number

Note representation of the text color.

loop Boolean

If true, will loop the text scrolling until another text scroll message is sent.

speed Number

The speed of the text scrolling. 1-7

Example:

myLaunchpad.scrollText("Hello node!", 23, true, 5)

public sendSysEx(bytes: Number[]) source

Convenience method to add the system-exclusive message header to a message and then send it to the Launchpad.

Params:

NameTypeAttributeDescription
bytes Number[]

The bytes of the SysEx message to send. Header is automatically included.

Example:

myLaunchpad.sendSysEx([0, 1, 2, 3])

public toLayout(layout: String) source

Set the Launchpad's layout.

Params:

NameTypeAttributeDescription
layout String

The layout you want to switch to. Can be one of NOTE, DRUM, FADER, PROGRAMMER.

Example:

myLaunchpad.toLayout("PROGRAMMER")