Git Product home page Git Product logo

osc-access's Introduction

OSC Access

A simple way to bind OSC directly to Ruby classes and objects.

Features

  • Works with MRI 1.9 and JRuby (in 1.9 mode)

  • Binding OSC events can be done by class or by instance

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

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

  • Make OSC-accessible objects discoverable on a network using Zeroconf

Requirements

Requires eventmachine and osc-ruby. These should install automatically with the gem

For Zeroconf support, dnssd is required.

Installation

gem install osc-access

Usage

require "osc-access"

In this example when OSC messages for /1/fader1 are received, velocity= is called and another message is outputted confirming that the first message was received

class Instrument

  include OSCAccessible

  osc_receive("/1/fader1", :translate => { :remote => 0..1, :local => 0..127 }) do |instance, val|
    instance.velocity = val
    instance.osc_send("/receipt", "val set to #{val}")
  end

  def velocity=(val)
    puts "setting velocity to #{val}"
  end

end

i = Instrument.new
i.osc_start(:input_port => 8000, :output => { :host => "192.168.1.8", :port => 9000}).join

The :translate option means that the first OSC argument will be translated from a number between 0 to 1 to the analogous value between 0 and 127 before being passed to the code block.

Or, here is an example that produces the same object, but it’s created by passing a Hash map to the instance:

map = {
  "/1/fader1" => { 
    :translate => { :remote => 0..1, :local => 0..127 }
    :action => Proc.new do |instance, val| 
      instance.pitch = val
      instance.osc_send("/receipt", "val set to #{val}")
    end
  }
}

class Instrument

  include OSCAccessible

  def pitch=(val)
    p "setting pitch to #{val}"
    ...
  end

end

i = Instrument.new
i.osc_start(:map => map, :input_port => 8000, :output => { :host => "192.168.1.8", :port => 9000}).join

Here’s a blog post that explains these examples in further depth and much more.

Other Documentation

License

Licensed under Apache 2.0, See the file LICENSE

Copyright ©2011 Ari Russo

osc-access's People

Contributors

arirusso avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.