Class: Fluent::MIDIInput

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/in_midi.rb

Instance Method Summary collapse

Constructor Details

#initializeMIDIInput

Returns a new instance of MIDIInput.



8
9
10
11
# File 'lib/fluent/plugin/in_midi.rb', line 8

def initialize
  super
  require 'rtmidi'
end

Instance Method Details

#configure(conf) ⇒ Object



13
14
15
# File 'lib/fluent/plugin/in_midi.rb', line 13

def configure(conf)
  super
end

#shutdownObject



31
32
33
# File 'lib/fluent/plugin/in_midi.rb', line 31

def shutdown
  @input.close_port
end

#startObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fluent/plugin/in_midi.rb', line 17

def start
  super
  @input = RtMidi::In.new
  @input.receive_channel_message do |byte1, byte2, byte3|
    record = {
      'status'   => byte1,
      'note'     => byte2,
      'velocity' => byte3,
    }
    Engine.emit(@tag, Engine.now, record)
  end
  @input.open_port(@port)
end