Class: CoreMIDI::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/coremidi.rb

Class Method Summary collapse

Class Method Details

.register(client_name, port_name, source) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/coremidi.rb', line 50

def self.register(client_name, port_name, source)
  raise "name must be a String!" unless client_name.class == String

  client = API.create_client(client_name) 
  port = API.create_input_port(client, port_name)
  API.connect_source_to_port(API.get_sources.index(source), port)

  while true
    data = API.check_for_new_data
    if data && !data.empty?
      data.each do |packet|
        yield(Packet.parse(packet.data))
      end
    end
    sleep 0.001
  end
end