Class: MIDIJRuby::API::InputReceiver
- Inherits:
-
Object
- Object
- MIDIJRuby::API::InputReceiver
- Defined in:
- lib/midi-jruby/api.rb
Overview
Input event handler class
Instance Attribute Summary collapse
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize ⇒ InputReceiver
constructor
A new instance of InputReceiver.
-
#read ⇒ Array<Array<Fixnum>>
Pluck messages from the buffer.
-
#send(message, _timestamp = -1)) ⇒ Array<Array<Fixnum>>
Add a new message to the buffer.
Constructor Details
#initialize ⇒ InputReceiver
Returns a new instance of InputReceiver.
136 137 138 |
# File 'lib/midi-jruby/api.rb', line 136 def initialize @buffer = [] end |
Instance Attribute Details
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
134 135 136 |
# File 'lib/midi-jruby/api.rb', line 134 def stream @stream end |
Instance Method Details
#close ⇒ Object
163 |
# File 'lib/midi-jruby/api.rb', line 163 def close; end |
#read ⇒ Array<Array<Fixnum>>
Pluck messages from the buffer
142 143 144 145 146 |
# File 'lib/midi-jruby/api.rb', line 142 def read = @buffer.dup @buffer.clear end |
#send(message, _timestamp = -1)) ⇒ Array<Array<Fixnum>>
Add a new message to the buffer
152 153 154 155 156 157 158 159 160 161 |
# File 'lib/midi-jruby/api.rb', line 152 def send(, = -1) bytes = if .respond_to?(:get_packed_message) packed = . unpack(packed) else string = String.from_java_bytes(.) string.unpack('C' * string.length) end @buffer << bytes end |