Module: MIDIJRuby::Device

Included in:
Input, Output
Defined in:
lib/midi-jruby/device.rb

Overview

Common methods used by both input and output devices

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#descriptionObject (readonly)

has the device been initialized?



6
7
8
# File 'lib/midi-jruby/device.rb', line 6

def description
  @description
end

#enabledObject (readonly) Also known as: enabled?

has the device been initialized?



6
7
8
# File 'lib/midi-jruby/device.rb', line 6

def enabled
  @enabled
end

#idObject (readonly)

has the device been initialized?



6
7
8
# File 'lib/midi-jruby/device.rb', line 6

def id
  @id
end

#nameObject (readonly)

has the device been initialized?



6
7
8
# File 'lib/midi-jruby/device.rb', line 6

def name
  @name
end

#typeObject (readonly)

has the device been initialized?



6
7
8
# File 'lib/midi-jruby/device.rb', line 6

def type
  @type
end

#vendorObject (readonly)

has the device been initialized?



6
7
8
# File 'lib/midi-jruby/device.rb', line 6

def vendor
  @vendor
end

Class Method Details

.allArray<Input, Output>

All devices of both directions

Returns:



57
58
59
# File 'lib/midi-jruby/device.rb', line 57

def self.all
  all_by_type.values.flatten
end

.all_by_typeHash

A hash of :input and :output devices

Returns:

  • (Hash)


48
49
50
51
52
53
# 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) ⇒ Input, Output

Select the first device of the given direction

Parameters:

  • direction (Symbol)

Returns:



35
36
37
# File 'lib/midi-jruby/device.rb', line 35

def self.first(direction)
  all_by_type[direction].first
end

.last(direction) ⇒ Input, Output

Select the last device of the given direction

Parameters:

  • direction (Symbol)

Returns:



42
43
44
# File 'lib/midi-jruby/device.rb', line 42

def self.last(direction)
  all_by_type[direction].last
end

Instance Method Details

#initialize(id, device, options = {}) ⇒ Object

Parameters:

  • The (Fixnum)

    uuid for the given device

  • device (Java::ComSunMediaSound::MidiInDevice, Java::ComSunMediaSound::MidiOutDevice)

    The underlying Java device object

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :description (String)
  • :name (String)
  • :vendor (String)


21
22
23
24
25
26
27
28
29
30
# 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