class Patch::IO::MIDI::Output
Attributes
device[R]
id[R]
Public Class Methods
new(id, device, options = {})
click to toggle source
@param [Fixnum] id @param [String, UniMIDI::Output] device @param [Hash] options @option options [Debug] :log
# File lib/patch/io/midi/output.rb, line 16 def initialize(id, device, options = {}) @log = options[:log] @id = id @device = get_output(device) end
Public Instance Methods
puts(patch, patch_messages)
click to toggle source
Convert Patch::Message
objects to MIDI
and send @param [Patch::Patch] patch Context @param [Array<Patch::Message>, Patch::Message
] messages Message(s) to send via MIDI
@return [Array<MIDIMessage>]
# File lib/patch/io/midi/output.rb, line 26 def puts(patch, patch_messages) patch_messages = [patch_messages].flatten messages = ::Patch::IO::MIDI::Message.to_midi_messages(patch, patch_messages) unless messages.empty? bytes = messages.map(&:to_a).flatten @device.puts(*bytes) end messages end
Private Instance Methods
get_output(device)
click to toggle source
Initialize the output device given a name or device object. If the name of the device is the string “choose”, the user is prompted to select an availble MIDI
output. @param [String, UniMIDI::Output, nil] device @return [UniMIDI::Output]
# File lib/patch/io/midi/output.rb, line 42 def get_output(device) if device.kind_of?(String) if device == "choose" UniMIDI::Output.gets else UniMIDI::Output.find_by_name(device) end elsif device.respond_to?(:puts) device.open if device.kind_of?(UniMIDI::Output) device end end