Module: AlsaRawMIDI::API::Output
Overview
Wrapper for ALSA methods dealing with output
Instance Method Summary collapse
-
#open(id) ⇒ Fixnum
Open the output with the given ID.
-
#puts(handle, data) ⇒ Boolean
Send the given MIDI data to the output with the given handle.
Instance Method Details
#open(id) ⇒ Fixnum
Open the output with the given ID
291 292 293 294 295 |
# File 'lib/alsa-rawmidi/api.rb', line 291 def open(id) API::Device.open(id) do |pointer| API.snd_rawmidi_open(nil, pointer, id, 0) end end |
#puts(handle, data) ⇒ Boolean
Send the given MIDI data to the output with the given handle
278 279 280 281 282 283 284 285 286 |
# File 'lib/alsa-rawmidi/api.rb', line 278 def puts(handle, data) format = "C" * data.size pointer = FFI::MemoryPointer.new(data.size) bytes = pointer.put_bytes(0, data.pack(format)) API.snd_rawmidi_write(handle, bytes.to_i, data.size) API.snd_rawmidi_drain(handle) true end |