Class: AlsaRawMIDI::Soundcard
- Inherits:
-
Object
- Object
- AlsaRawMIDI::Soundcard
- Defined in:
- lib/alsa-rawmidi/soundcard.rb
Instance Attribute Summary collapse
-
#subdevices ⇒ Object
readonly
Returns the value of attribute subdevices.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(card_num) ⇒ Soundcard
constructor
A new instance of Soundcard.
Constructor Details
#initialize(card_num) ⇒ Soundcard
Returns a new instance of Soundcard.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/alsa-rawmidi/soundcard.rb', line 9 def initialize(card_num) @subdevices = { :input => [], :output => [] } name = "hw:#{card_num}" handle_ptr = FFI::MemoryPointer.new(FFI.type_size(:int)) #snd_ctl = Map::SndCtl.new #snd_ctl_pointer = FFI::MemoryPointer.new(:pointer).write_pointer(snd_ctl.pointer) Map.snd_ctl_open(handle_ptr, name, 0) handle = handle_ptr.read_int 32.times do |i| devnum = FFI::MemoryPointer.new(:int).write_int(i) if (err = Map.snd_ctl_rawmidi_next_device(handle, devnum)) < 0 break # fix this end @subdevices.keys.each do |type| populate_subdevices(type, handle, card_num, i) end end end |
Instance Attribute Details
#subdevices ⇒ Object (readonly)
Returns the value of attribute subdevices.
7 8 9 |
# File 'lib/alsa-rawmidi/soundcard.rb', line 7 def subdevices @subdevices end |