Skip to content

Instantly share code, notes, and snippets.

@Neurogami
Created June 14, 2014 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neurogami/953cab1f5eabaa10119b to your computer and use it in GitHub Desktop.
Save Neurogami/953cab1f5eabaa10119b to your computer and use it in GitHub Desktop.
#!/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