Module: AlsaRawMIDI::API::Device
- Defined in:
- lib/alsa-rawmidi/api.rb
Overview
Wrapper for ALSA methods dealing with devices
Class Method Summary collapse
-
.close(handle) ⇒ Boolean
Close the device with the given handle.
- .get_info(id, direction) ⇒ SndCtlCardInfo
-
.open(_id) {|handle_pointer| ... } ⇒ Integer
Open the device with the given id.
Class Method Details
.close(handle) ⇒ Boolean
Close the device with the given handle
318 319 320 321 322 |
# File 'lib/alsa-rawmidi/api.rb', line 318 def close(handle) API.snd_rawmidi_drain(handle) API.snd_rawmidi_close(handle) true end |
.get_info(id, direction) ⇒ SndCtlCardInfo
303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/alsa-rawmidi/api.rb', line 303 def get_info(id, direction) stream_key = case direction when :input then :SND_RAWMIDI_STREAM_INPUT when :output then :SND_RAWMIDI_STREAM_OUTPUT end stream = API::CONSTANTS[stream_key] info = API::SndRawMIDIInfo.new API.snd_rawmidi_info_set_device(info.pointer, id) API.snd_rawmidi_info_set_stream(info.pointer, stream) info end |
.open(_id) {|handle_pointer| ... } ⇒ Integer
Open the device with the given id
328 329 330 331 332 |
# File 'lib/alsa-rawmidi/api.rb', line 328 def open(_id) handle_pointer = FFI::MemoryPointer.new(FFI.type_size(:int)) yield(handle_pointer) handle_pointer.read_int end |