Module: AlsaRawMIDI::Device
Overview
Module containing methods used by both input and output devices when using the ALSA driver interface
Instance Attribute Summary collapse
-
#enabled ⇒ Object
(also: #enabled?)
readonly
has the device been initialized?.
-
#id ⇒ Object
readonly
has the device been initialized?.
-
#name ⇒ Object
readonly
has the device been initialized?.
-
#subname ⇒ Object
readonly
has the device been initialized?.
-
#system_id ⇒ Object
readonly
has the device been initialized?.
-
#type ⇒ Object
readonly
has the device been initialized?.
Class Method Summary collapse
-
.all ⇒ Object
all devices of both types.
-
.all_by_type ⇒ Object
a Hash of :input and :output devices.
-
.first(type) ⇒ Object
select the first device of type type.
-
.last(type) ⇒ Object
select the last device of type type.
Instance Method Summary collapse
Instance Attribute Details
#enabled ⇒ Object (readonly) Also known as: enabled?
has the device been initialized?
12 13 14 |
# File 'lib/alsa-rawmidi/device.rb', line 12 def enabled @enabled end |
#id ⇒ Object
has the device been initialized?
12 13 14 |
# File 'lib/alsa-rawmidi/device.rb', line 12 def id @id end |
#name ⇒ Object (readonly)
has the device been initialized?
12 13 14 |
# File 'lib/alsa-rawmidi/device.rb', line 12 def name @name end |
#subname ⇒ Object (readonly)
has the device been initialized?
12 13 14 |
# File 'lib/alsa-rawmidi/device.rb', line 12 def subname @subname end |
#system_id ⇒ Object (readonly)
has the device been initialized?
12 13 14 |
# File 'lib/alsa-rawmidi/device.rb', line 12 def system_id @system_id end |
#type ⇒ Object (readonly)
has the device been initialized?
12 13 14 |
# File 'lib/alsa-rawmidi/device.rb', line 12 def type @type end |
Class Method Details
.all ⇒ Object
all devices of both types
67 68 69 |
# File 'lib/alsa-rawmidi/device.rb', line 67 def self.all all_by_type.values.flatten end |
.all_by_type ⇒ Object
a Hash of :input and :output devices
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/alsa-rawmidi/device.rb', line 47 def self.all_by_type available_devices = { :input => [], :output => [] } device_count = 0 32.times do |i| card = Soundcard.find(i) unless card.nil? available_devices.keys.each do |type| devices = card.subdevices[type] devices.each do |dev| dev.send(:id=, device_count) device_count += 1 end available_devices[type] += devices end end end available_devices end |
.first(type) ⇒ Object
select the first device of type type
37 38 39 |
# File 'lib/alsa-rawmidi/device.rb', line 37 def self.first(type) all_by_type[type].first end |
.last(type) ⇒ Object
select the last device of type type
42 43 44 |
# File 'lib/alsa-rawmidi/device.rb', line 42 def self.last(type) all_by_type[type].last end |
Instance Method Details
#initialize(options = {}, &block) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/alsa-rawmidi/device.rb', line 24 def initialize( = {}, &block) @id = [:id] @name = [:name] @subname = [:subname] @system_id = [:system_id] # cache the type name so that inspecting the class isn't necessary each time @type = self.class.name.split('::').last.downcase.to_sym @enabled = false end |