Class: UniMIDI::CongruousApiInput
- Inherits:
-
Object
- Object
- UniMIDI::CongruousApiInput
- Extended by:
- Forwardable, UniMIDI::CongruousApiAdapter::Device::ClassMethods
- Includes:
- UniMIDI::CongruousApiAdapter::Device
- Defined in:
- lib/unimidi/congruous_api_adapter.rb
Direct Known Subclasses
AlsaRawMIDIAdapter::Input, UniMIDI::CoreMIDIAdapter::Input, MIDIJRubyAdapter::Input, MIDIWinMMAdapter::Input
Class Method Summary collapse
-
.all ⇒ Object
returns all inputs.
Instance Method Summary collapse
-
#clear_buffer ⇒ Object
clears the buffer.
-
#gets(*a) ⇒ Object
returns an array of MIDI event hashes as such: [ { :data => [144, 60, 100], :timestamp => 1024 }, { :data => [128, 60, 100], :timestamp => 1100 }, { :data => [144, 40, 120], :timestamp => 1200 } ].
-
#gets_buffer(*a) ⇒ Object
gets any messages in the buffer in the same format as CongruousApiInput#gets.
-
#gets_buffer_data(*a) ⇒ Object
gets any messages in the buffer in the same format as CongruousApiInput#gets_data.
-
#gets_buffer_s(*a) ⇒ Object
gets any messages in the buffer in the same format as CongruousApiInput#gets_s.
-
#gets_data(*a) ⇒ Object
returns an array of data bytes such as [144, 60, 100, 128, 60, 100, 144, 40, 120].
-
#gets_data_s(*a) ⇒ Object
(also: #gets_data_bytestr, #gets_data_hex)
returns a string of data such as “90406080406090447F”.
-
#gets_s(*a) ⇒ Object
(also: #gets_bytestr, #gets_hex)
same as gets but returns message data as string of hex digits as such: [ { :data => “904060”, :timestamp => 904 }, { :data => “804060”, :timestamp => 1150 }, { :data => “90447F”, :timestamp => 1300 } ].
Methods included from UniMIDI::CongruousApiAdapter::Device::ClassMethods
[], all, all_by_type, defer_to, device_class, each, find_by_name, first, input_class, last, list, output_class, populate, use
Methods included from UniMIDI::CongruousApiAdapter::Device
#close, #enabled?, included, #initialize, #open, #pretty_name
Class Method Details
.all ⇒ Object
returns all inputs
263 264 265 |
# File 'lib/unimidi/congruous_api_adapter.rb', line 263 def self.all UniMIDI::Device.all_by_type[:input] end |
Instance Method Details
#clear_buffer ⇒ Object
clears the buffer
243 244 245 |
# File 'lib/unimidi/congruous_api_adapter.rb', line 243 def clear_buffer @device.buffer.clear end |
#gets(*a) ⇒ Object
returns an array of MIDI event hashes as such:
[
{ :data => [144, 60, 100], :timestamp => 1024 },
{ :data => [128, 60, 100], :timestamp => 1100 },
{ :data => [144, 40, 120], :timestamp => 1200 }
]
the data is an array of Numeric bytes the timestamp is the number of millis since this input was enabled
200 201 202 203 204 |
# File 'lib/unimidi/congruous_api_adapter.rb', line 200 def gets(*a) @device.gets(*a) rescue SystemExit, Interrupt exit end |
#gets_buffer(*a) ⇒ Object
gets any messages in the buffer in the same format as CongruousApiInput#gets
248 249 250 |
# File 'lib/unimidi/congruous_api_adapter.rb', line 248 def gets_buffer(*a) @device.buffer end |
#gets_buffer_data(*a) ⇒ Object
gets any messages in the buffer in the same format as CongruousApiInput#gets_data
258 259 260 |
# File 'lib/unimidi/congruous_api_adapter.rb', line 258 def gets_buffer_data(*a) @device.buffer.map { |msg| msg[:data] } end |
#gets_buffer_s(*a) ⇒ Object
gets any messages in the buffer in the same format as CongruousApiInput#gets_s
253 254 255 |
# File 'lib/unimidi/congruous_api_adapter.rb', line 253 def gets_buffer_s(*a) @device.buffer.map { |msg| msg[:data] = TypeConversion.numeric_byte_array_to_hex_string(msg[:data]); msg } end |
#gets_data(*a) ⇒ Object
returns an array of data bytes such as
[144, 60, 100, 128, 60, 100, 144, 40, 120]
226 227 228 229 |
# File 'lib/unimidi/congruous_api_adapter.rb', line 226 def gets_data(*a) arr = gets arr.map { |msg| msg[:data] }.inject(:+) end |
#gets_data_s(*a) ⇒ Object Also known as: gets_data_bytestr, gets_data_hex
returns a string of data such as
"90406080406090447F"
235 236 237 238 |
# File 'lib/unimidi/congruous_api_adapter.rb', line 235 def gets_data_s(*a) arr = gets_bytestr arr.map { |msg| msg[:data] }.join end |
#gets_s(*a) ⇒ Object Also known as: gets_bytestr, gets_hex
same as gets but returns message data as string of hex digits as such:
[
{ :data => "904060", :timestamp => 904 },
{ :data => "804060", :timestamp => 1150 },
{ :data => "90447F", :timestamp => 1300 }
]
214 215 216 217 218 |
# File 'lib/unimidi/congruous_api_adapter.rb', line 214 def gets_s(*a) @device.gets_s(*a) rescue SystemExit, Interrupt exit end |