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