Class: MicroMIDI::Instructions::Output

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/micromidi/instructions/output.rb,
lib/micromidi/instructions/shorthand.rb

Overview

Commands that deal with MIDI output

Instance Method Summary collapse

Constructor Details

#initialize(state) ⇒ Output

Returns a new instance of Output.

Parameters:


14
15
16
# File 'lib/micromidi/instructions/output.rb', line 14

def initialize(state)
  @state = state
end

Instance Method Details

#output(message) ⇒ MIDIMessage Also known as: out

Output a message or toggle the auto output mode

Parameters:

  • message (MIDIMessage, Boolean)

    A MIDI message to output, or a boolean to toggle auto-output mode

Returns:

  • (MIDIMessage)

21
22
23
24
25
26
27
# File 'lib/micromidi/instructions/output.rb', line 21

def output(message)
  set_auto_output(message) if !!message === message # check for boolean
  unless message.nil?
    @state.outputs.each { |output| output.puts(message) }
  end
  message
end

#set_auto_output(is_on) ⇒ Boolean

Set mode where messages are automatically outputted

Parameters:

  • is_on (Boolean)

    Whether to set the auto output mode to ON

Returns:

  • (Boolean)

32
33
34
# File 'lib/micromidi/instructions/output.rb', line 32

def set_auto_output(is_on)
  @state.auto_output = is_on
end