launchpad

<img src=“https://travis-ci.org/andeemarks/launchpad.png?branch=master” alt=“Build Status” />

This gem provides a Ruby interface to access the Novation Launchpad MK2 programmatically. The code started life as a clone of Thomas Jachman’s gem and was subsequently updated to handle the MK2 version of the Launchpad. The mapping of buttons and specification of colours completely changed when the MK2 was released, so lots of the original code in these areas has been re-written, but the interaction code is still largely intact.

More Info

  • Novation’s Launchpad MK2 MIDI programmer’s reference here was the sole source for helping me understand how to interact with the Launchpad.

  • Due to limitations in the Portmidi gem, it’s not possible to specify which channel is used to send MIDI messages. As such, all interaction with the Launchpad are done over the default channel 1. This means some workarounds have been needed to access functionality like flash and pulse, which usually require channel 2 messages. All of these workarounds have been implemented via sending System Exclusive messages as per the above reference guide.

Requirements

Compatibility

The gem is known to be compatible with the following ruby versions:

  • MRI 2.3.1

Installation

The gem is hosted on RubyGems, so in order to use it, you’re gonna gem install it:

gem install launchpad

Usage

There are two main entry points:

  • require 'launchpad/device', providing Launchpad::Device, which handles all the basic input/output stuff

  • require 'launchpad/interaction' or just ‘launchpad’, additionally providing Launchpad::Interaction, which lets you respond to actions (button presses/releases)

This is a simple example (only requiring the device for output) that resets the launchpad and then lights the grid button at position 4/4 (from bottom left of 0/0).

require 'launchpad/device'

device = Launchpad::Device.new
sleep 1
device.reset_all
sleep 1
device.change :grid, :x => 4, :y => 4, :color => 72

This is an interaction example lighting all grid buttons in red when pressed and keeping them lit.

require 'launchpad'

interaction = Launchpad::Interaction.new
interaction.response_to(:grid, :down) do |interaction, action|
  interaction.device.change(:grid, action.merge(:color => 72))
end
interaction.response_to(:mixer, :down) do |interaction, action|
  interaction.stop
end

interaction.start

For more details, see the examples. examples/color_picker.rb is the most complex example with interaction.

To Do

  • Rename gem to avoid name clashes with original version

  • Ensure all examples are working

  • Update examples in README

Copyright © 2017 Andy Marks. See LICENSE for details.