Created
June 14, 2014 21:16
-
-
Save Neurogami/953cab1f5eabaa10119b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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