class UniMIDI::Output

A MIDI output device

Public Class Methods

all() click to toggle source

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

puts(*messages) click to toggle source

Sends a message to the output.

The message format can be:

  1. Numeric bytes eg output.puts(0x90, 0x40, 0x40)

  2. An array of numeric bytes [0x90, 0x40, 0x40]

  3. A string of bytes eg “904040”

  4. 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
puts_bytes(*messages) click to toggle source

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
puts_bytestr(*messages)
Alias for: puts_s
puts_hex(*messages)
Alias for: puts_s
puts_s(*messages) click to toggle source

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
Also aliased as: puts_bytestr, puts_hex