module AlsaRawMIDI::API::Input
Wrapper for ALSA methods dealing with input
Constants
- BUFFER_SIZE
Public Instance Methods
open(id)
click to toggle source
Open the output with the given ID @param [Integer] id @return [Integer]
# File lib/alsa-rawmidi/api.rb, line 246 def open(id) API::Device.open(id) do |pointer| API.snd_rawmidi_open(pointer, nil, id, API::CONSTANTS[:SND_RAWMIDI_NONBLOCK]) end end
poll(handle)
click to toggle source
Get the next bytes from the buffer @return [String]
# File lib/alsa-rawmidi/api.rb, line 254 def poll(handle) buffer = FFI::MemoryPointer.new(:uint8, BUFFER_SIZE) if (err = API.snd_rawmidi_read(handle, buffer, BUFFER_SIZE)) < 0 raise "Can't read MIDI input: #{API.snd_strerror(err)}" unless err.eql?(-11) end # Upon success, err is positive and equal to the number of bytes read # into the buffer. if err > 0 bytes = buffer.get_bytes(0,err).unpack("a*").first.unpack("H*") bytes.first.upcase end end