Module: RawMIDI::Device
Instance Attribute Summary collapse
-
#card ⇒ Object
readonly
Returns the value of attribute card.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
- #handle_name ⇒ Object
- #initialize(card_or_id, id, **info) ⇒ Object
- #inspect ⇒ Object
- #open ⇒ Object
- #open? ⇒ Boolean
Instance Attribute Details
#card ⇒ Object (readonly)
Returns the value of attribute card.
3 4 5 |
# File 'lib/rawmidi/device.rb', line 3 def card @card end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/rawmidi/device.rb', line 3 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/rawmidi/device.rb', line 3 def name @name end |
Instance Method Details
#close ⇒ Object
29 30 31 32 33 34 |
# File 'lib/rawmidi/device.rb', line 29 def close return if closed? API::Device.close(@midi_p) @midi_p = nil true end |
#closed? ⇒ Boolean
40 41 42 |
# File 'lib/rawmidi/device.rb', line 40 def closed? !open? end |
#handle_name ⇒ Object
15 16 17 |
# File 'lib/rawmidi/device.rb', line 15 def handle_name "#{@card.handle_name},#{@id},0" end |
#initialize(card_or_id, id, **info) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/rawmidi/device.rb', line 5 def initialize(card_or_id, id, **info) @card = card_or_id.is_a?(Card) ? card_or_id : Card.new(card_or_id) @id = id info = get_subdevice_info if info.empty? @name = info[:name] @input = info[:input] @output = info[:output] end |
#inspect ⇒ Object
19 20 21 |
# File 'lib/rawmidi/device.rb', line 19 def inspect "#<#{self.class.name}:#{"0x%014x" % object_id} #{handle_name} #{@name.inspect} #{open? ? 'open' : 'closed'}>" end |
#open ⇒ Object
23 24 25 26 27 |
# File 'lib/rawmidi/device.rb', line 23 def open fail 'already open' if @midi_p @midi_p = API::Device.open(handle_name, direction, :sync) true end |
#open? ⇒ Boolean
36 37 38 |
# File 'lib/rawmidi/device.rb', line 36 def open? !!@midi_p end |