Module: MIDIWinMM::Device
Overview
Module containing methods used by both input and output devices when using the WinMM driver interface
Constant Summary collapse
- WinmmCallbackFlag =
we plan to use a callback to collect events
0x30000
Instance Attribute Summary collapse
-
#enabled ⇒ Object
(also: #enabled?)
readonly
Returns the value of attribute enabled.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
- .all ⇒ Object
- .all_by_type ⇒ Object
-
.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?
Returns the value of attribute enabled.
10 11 12 |
# File 'lib/midi-winmm/device.rb', line 10 def enabled @enabled end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/midi-winmm/device.rb', line 10 def id @id end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
10 11 12 |
# File 'lib/midi-winmm/device.rb', line 10 def info @info end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/midi-winmm/device.rb', line 10 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/midi-winmm/device.rb', line 10 def type @type end |
Class Method Details
.all ⇒ Object
21 22 23 |
# File 'lib/midi-winmm/device.rb', line 21 def self.all all_by_type.values.flatten end |
.all_by_type ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/midi-winmm/device.rb', line 25 def self.all_by_type types = { :input => Input, :output => Output } available_devices = { :input => [], :output => [] } count = 0 types.each do |type, klass| (0..(Map::cfunc(type, :getNumDevs)-1)).each do |i| data = Map::DeviceInfo[type].new Map::cfunc(type, :getDevCapsA, i, data.to_ptr, Map::DeviceInfo[type].size) name = data[:szPname].to_s dev = klass.new(i, name, :info => data) available_devices[type] << dev end end available_devices end |
.first(type) ⇒ Object
select the first device of type type
43 44 45 |
# File 'lib/midi-winmm/device.rb', line 43 def self.first(type) all_by_type[type].first end |
.last(type) ⇒ Object
select the last device of type type
48 49 50 |
# File 'lib/midi-winmm/device.rb', line 48 def self.last(type) all_by_type[type].last end |
Instance Method Details
#initialize(id, name, options = {}, &block) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/midi-winmm/device.rb', line 14 def initialize(id, name, = {}, &block) @id = id @info = [:info] @type = self.class.name.split('::').last.downcase.to_sym @name = name end |