Class: UniMIDI::Output
- Inherits:
-
Object
- Object
- UniMIDI::Output
- Extended by:
- Device::ClassMethods
- Includes:
- Device::InstanceMethods
- Defined in:
- lib/unimidi/output.rb
Overview
A MIDI output device
Class Method Summary collapse
-
.all ⇒ Array<Output>
All MIDI output devices – used to populate the class.
Instance Method Summary collapse
-
#puts(*messages) ⇒ Array<Integer>, Array<String>
Sends a message to the output.
-
#puts_bytes(*messages) ⇒ Array<Integer>+
Sends a message to the output in a form of bytes eg output.puts_bytes(0x90, 0x40, 0x40).
-
#puts_s(*messages) ⇒ Array<String>+
(also: #puts_bytestr, #puts_hex)
Sends a message to the output in a form of a string eg “904040”.
Methods included from Device::ClassMethods
at, each, find_by_name, first, gets, last, list, use
Methods included from Device::InstanceMethods
#close, #closed?, included, #initialize, #open, #pretty_name
Class Method Details
Instance Method Details
#puts(*messages) ⇒ Array<Integer>, Array<String>
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”]
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/unimidi/output.rb', line 26 def puts(*) = .first case when Array then .each { |array| puts(*array.flatten) } when Integer then puts_bytes(*) when String then puts_s(*) else if .respond_to?(:to_bytes) puts_bytes(*.to_bytes.flatten) elsif .respond_to?(:to_a) puts_bytes(*.to_a.flatten) end end end |
#puts_bytes(*messages) ⇒ Array<Integer>+
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.
56 57 58 59 |
# File 'lib/unimidi/output.rb', line 56 def puts_bytes(*) @device.puts_bytes(*) .count < 2 ? [0] : end |
#puts_s(*messages) ⇒ Array<String>+ Also known as: puts_bytestr, puts_hex
Sends a message to the output in a form of a string eg “904040”. This method does not do type checking
45 46 47 48 |
# File 'lib/unimidi/output.rb', line 45 def puts_s(*) @device.puts_s(*) .count < 2 ? [0] : end |