module MIDIJRuby::Device

Common methods used by both input and output devices

Attributes

description[R]
enabled[R]
enabled?[R]
id[R]
name[R]
type[R]
vendor[R]

Public Class Methods

all() click to toggle source

All devices of both directions @return [Array<Input, Output>]

# File lib/midi-jruby/device.rb, line 57
def self.all
  all_by_type.values.flatten
end
all_by_type() click to toggle source

A hash of :input and :output devices @return [Hash]

# File lib/midi-jruby/device.rb, line 48
def self.all_by_type
  @devices ||= {
    :input => API.get_inputs,
    :output => API.get_outputs
  }
end
first(direction) click to toggle source

Select the first device of the given direction @param [Symbol] direction @return [Input, Output]

# File lib/midi-jruby/device.rb, line 35
def self.first(direction)
  all_by_type[direction].first
end
last(direction) click to toggle source

Select the last device of the given direction @param [Symbol] direction @return [Input, Output]

# File lib/midi-jruby/device.rb, line 42
def self.last(direction)
  all_by_type[direction].last
end
new(id, device, options = {}) click to toggle source

@param [Fixnum] The uuid for the given device @param [Java::ComSunMediaSound::MidiInDevice, Java::ComSunMediaSound::MidiOutDevice] device The underlying Java device object @param [Hash] options @option options [String] :description @option options [String] :name @option options [String] :vendor

# File lib/midi-jruby/device.rb, line 21
def initialize(id, device, options = {})
  @name = options[:name]
  @description = options[:description]
  @vendor = options[:vendor]
  @id = id
  @device = device

  @type = get_type
  @enabled = false
end

Private Instance Methods

get_type() click to toggle source

@return [String]

# File lib/midi-jruby/device.rb, line 64
def get_type
  self.class.name.split("::").last.downcase.to_sym
end