Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/env ruby
require 'osc-ruby'
include OSC
listen_on_port = 8000
last_msg = nil
warn "If you pass an arg it will be used as the port number instead of #{listen_on_port}"
if !ARGV.empty?
listen_on_port = ARGV.shift.to_i
end
warn "Listening on #{listen_on_port}"
server = Server.new listen_on_port
server.add_method /.*/ do |msg|
delta = if !last_msg
last_msg = Time.now
0
else
_ = Time.now - last_msg
last_msg = Time.now
_
end
puts delta
puts "#{msg.address.inspect} #{msg.to_a.join ', ' }"
end
server.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment