MicroOSC

A Ruby DSL for OSC

Features

  • Works with MRI and JRuby

  • Network resources are invisible to the user even when shared or multiplexed

  • Includes shortcuts for common tasks associated with OSC such as translating numeric values from one range to another

  • Network discoverable using Zeroconf

Requirements

Ruby (MRI) 1.9.2+ or JRuby (in 1.9 mode)

eventmachine (version 0.12.8 recommended for MRI)

osc-access

osc-ruby

(These should install automatically with the gem)

For Zeroconf support, dnssd is required.

Installation

gem install micro-osc

Usage

The following are two MicroOSC programs; the first will receive OSC messages and the second will send one. Run them in two separate windows and they will talk to each other.

Here's the receiver…

require "osc"

OSC.using(:input_port => 8000) do

  receive("/greeting") { |val| p "received #{val}" }

  p "Ready to receive OSC messages on port(s) #{input_ports.join(', ')}..."

  wait_for_input

end

When you run this, You should see confirmation that the program is running “Ready to receive OSC…” in your Ruby console.

Next, in another window run this next client program.

require "osc"

o = OSC.using(:output => { :host => "localhost", :port => 8000 })
o.out "/greeting", "hullo!"

After running it, flip back to the first receiver program and see “received hullo!”, confirming that these two programs could reach each other.

Notice that I didn't use a Ruby block in the second program. There's no particular reason for that other than to demonstrate both styles

A single MicroOSC block can act as a client and receiver, both sending and receiving OSC (see here…)

These examples and more are available here

Other Documentation

License

Licensed under Apache 2.0, See the file LICENSE

Copyright © 2011-2012 Ari Russo