class UniMIDI::Output
A MIDI output device
Public Class Methods
All MIDI output devices – used to populate the class @return [Array<Output>]
# File lib/unimidi/output.rb, line 11 def self.all Loader.devices(:direction => :output) end
Public Instance Methods
Sends a message to the output.
The message format can be:
-
Numeric bytes eg output.puts(0x90, 0x40, 0x40)
-
An array of numeric bytes [0x90, 0x40, 0x40]
-
A string of bytes eg “904040”
-
An array of strings [“904040”, “804040”]
@param [*Array<Integer>, *Array<String>, *Integer, *String] messages @return [Array<Integer>, Array<String>]
# File lib/unimidi/output.rb, line 26 def puts(*messages) message = messages.first case message when Array then messages.each { |array| puts(*array.flatten) } when Integer then puts_bytes(*messages) when String then puts_s(*messages) else if message.respond_to?(:to_bytes) puts_bytes(*message.to_bytes.flatten) elsif message.respond_to?(:to_a) puts_bytes(*message.to_a.flatten) end end end
Sends a message to the output in a form of bytes eg output.puts_bytes(0x90, 0x40, 0x40). This method does not do type checking. @param [*Array<Integer>] messages @return [Array<Integer>, Array<Array<Integer>>]
# File lib/unimidi/output.rb, line 56 def puts_bytes(*messages) @device.puts_bytes(*messages) messages.count < 2 ? messages[0] : messages end
Sends a message to the output in a form of a string eg “904040”. This method does not do type checking @param [*String] messages @return [Array<String>, Array<Array<String>>]
# File lib/unimidi/output.rb, line 45 def puts_s(*messages) @device.puts_s(*messages) messages.count < 2 ? messages[0] : messages end