def create_device!(devices, device_type, opts)
      logger.debug "creating #{device_type} with #{opts.inspect}, choosing from portmidi devices #{devices.inspect}"
      id = opts[:id]
      if id.nil?
        name = opts[:name] || 'Launchpad'
        device = devices.select {|device| device.name == name}.first
        id = device.device_id unless device.nil?
      end
      if id.nil?
        message = "MIDI device #{opts[:id] || opts[:name]} doesn't exist"
        logger.fatal message
        raise NoSuchDeviceError.new(message)
      end
      device_type.new(id)
    rescue RuntimeError => e
      logger.fatal "error creating #{device_type}: #{e.inspect}"
      raise DeviceBusyError.new(e)
    end
def create_device!(devices, device_type, opts)
      logger.debug "creating #{device_type} with #{opts.inspect}, choosing from portmidi devices #{devices.inspect}"
      id = opts[:id]
      if id.nil?
        name = opts[:name] || 'Launchpad'
        device = devices.select {|device| device.name == name}.first
        id = device.device_id unless device.nil?
      end
      if id.nil?
        message = "MIDI device #{opts[:id] || opts[:name]} doesn't exist"
        logger.fatal message
        raise NoSuchDeviceError.new(message)
      end
      device_type.new(id)
    rescue RuntimeError => e
      logger.fatal "error creating #{device_type}: #{e.inspect}"
      raise DeviceBusyError.new(e)
    end
Creates input/output devices.

 Parameters:

 [+devices+]     array of portmidi devices
 [+device_type]  class to instantiate (<tt>Portmidi::Input/Portmidi::Output</tt>)

 Options hash:

 [<tt>:id</tt>]    id of the MIDI device to use
 [<tt>:name</tt>]  name of the MIDI device to use,
                   only used when <tt>:id</tt> is not specified,
                   defaults to "Launchpad"

 Returns:

 newly created device

 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