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.
125 126 127 |
# File 'lib/midi-jruby/api.rb', line 125 def initialize @buffer = [] end |
Instance Attribute Details
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
123 124 125 |
# File 'lib/midi-jruby/api.rb', line 123 def stream @stream end |
Instance Method Details
#close ⇒ Object
152 153 |
# File 'lib/midi-jruby/api.rb', line 152 def close end |
#read ⇒ Array<Array<Fixnum>>
Pluck messages from the buffer
131 132 133 134 135 |
# File 'lib/midi-jruby/api.rb', line 131 def read = @buffer.dup @buffer.clear end |
#send(message, timestamp = -1)) ⇒ Array<Array<Fixnum>>
Add a new message to the buffer
141 142 143 144 145 146 147 148 149 150 |
# File 'lib/midi-jruby/api.rb', line 141 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 |