Class: Patch::IO::MIDI::Output

Inherits:
Object
  • Object
show all
Defined in:
lib/patch/io/midi/output.rb

Overview

MIDI Output functions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, device, options = {}) ⇒ Output

Returns a new instance of Output.

Parameters:

  • id (Fixnum)
  • device (String, UniMIDI::Output)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :log (Debug)


16
17
18
19
20
# File 'lib/patch/io/midi/output.rb', line 16

def initialize(id, device, options = {})
  @log = options[:log]
  @id = id
  @device = get_output(device)
end

Instance Attribute Details

#deviceObject (readonly)

Returns the value of attribute device.



10
11
12
# File 'lib/patch/io/midi/output.rb', line 10

def device
  @device
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'lib/patch/io/midi/output.rb', line 10

def id
  @id
end

Instance Method Details

#puts(patch, patch_messages) ⇒ Array<MIDIMessage>

Convert Patch::Message objects to MIDI and send

Parameters:

Returns:

  • (Array<MIDIMessage>)


26
27
28
29
30
31
# 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)
  @device.puts(messages) unless messages.empty?
  messages
end