Method: Launchpad::Device#initialize

Defined in:
lib/launchpad/device.rb

#initialize(opts = nil) ⇒ Device

Initializes the launchpad device. When output capabilities are requested, the launchpad will be reset.

Optional options hash:

[:input] whether to use MIDI input for user interaction, true/false, optional, defaults to true [:output] whether to use MIDI output for data display, true/false, optional, defaults to true [:input_device_id] ID of the MIDI input device to use, optional, :device_name will be used if omitted [:output_device_id] ID of the MIDI output device to use, optional, :device_name will be used if omitted [:device_name] Name of the MIDI device to use, optional, defaults to "Launchpad"

Errors raised:

[Launchpad::NoSuchDeviceError] when device with ID or name specified does not exist [Launchpad::DeviceBusyError] when device with ID or name specified is busy



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/launchpad/device.rb', line 47

def initialize(opts = nil)
  opts = {
    :input        => true,
    :output       => true
  }.merge(opts || {})
  
  Portmidi.start
  
  @input = device(Portmidi.input_devices, Portmidi::Input, :id => opts[:input_device_id], :name => opts[:device_name]) if opts[:input]
  @output = device(Portmidi.output_devices, Portmidi::Output, :id => opts[:output_device_id], :name => opts[:device_name]) if opts[:output]
  reset if output_enabled?
end