Erlang OSC Dispatcher

Erlang OSC Dispatcher

About

OSC uses UDP-Messages. To send messages from one Program to another simply open a UDP port in one app and send the messages to this port from the other app.

+-----------+                    +-----------+
|   App1    | ---- osc msg ----> |   App2    | 
+-----------+                    +-----------+

it gets a bit more complicated if more than 2 apps are involved, because every app that sends messages has to know all other urls and ports of the receiving apps.

This is where the OSCDispatcher comes to rescue :-)

the progam opens a socket and redirects all osc messages it receives to ports defined by some dispatching rules.

+-----------+                    +--------------------+                 +-----------+
|   App1    | ---- osc msg ----> |   OSCDispatcher    | ------------->  |   App3    |
+-----------+                    +--------------------+                 +-----------+
                                           |
                                           V
                                     +------------+
                                     |    App2    |
                                     +------------+

Download

oscdispatch-0.1.zip

Documentation

to run the server simply define the dispachting rules in an erl file (see demo.erl for an example) and run the server with

./run.sh [filename]

use -c to terminate the program

Examples

The following code shows how to define the dispatching rules.
all "/color" messages get send to localhost:1234 and to localhost:1235 all "/osc/midi" get send to localhost:4001

-module(demo).
-export([start/0, dispatch/2]).

start() ->
    S = oscdispatch:new(demo),
    S:start_server().

%% define where to send the messages
dispatch( "/color" ++ _, Bin ) ->
    util:send( "localhost", 1234, Bin),
    util:send( "localhost", 1235, Bin);


dispatch( "/osc/midi" ++ _, Bin ) ->
    util:send( "localhost", 4002, Bin);

dispatch( _, _ ) ->
    io:format( "UNKNOWN ~n" ).

Archive

The very first proof of a concept erl script Source: test1.erl