Module: Diamond::MIDI::Output

Included in:
Node
Defined in:
lib/diamond/midi.rb

Overview

Methods dealing with MIDI output

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/diamond/midi.rb', line 94

def self.included(base)
  base.send(:extend, Forwardable)
  base.send(:def_delegators, :@midi,
            :mute,
            :mute=,
            :output,
            :outputs,
            :toggle_mute,
            :tx_channel, 
            :transmit_channel,
            :tx_channel=,
            :transmit_channel=)
end

Instance Method Details

#enable_output(arpeggiator) ⇒ Boolean

Initialize MIDI output, enabling the sequencer to emit notes

Parameters:

Returns:

  • (Boolean)


111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/diamond/midi.rb', line 111

def enable_output(arpeggiator)
  arpeggiator.sequencer.event.perform << proc do |bucket|
    unless bucket.empty?
      if @debug
        bucket.each do |message|
          puts "[DEBUG] MIDI: output #{message.name} channel: #{message.channel}"
        end
      end
      @midi.output.puts(bucket)
    end
  end
  arpeggiator.sequencer.event.stop << proc { emit_pending_note_offs(arpeggiator) }
  true
end