Ask Your Question

How to define a custom OSC message

asked 2016-12-27 18:51:15 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >1 is welcome to improve it.

It is possible to define your own OSC message for sending to things other than SuperDirt. It's got a bit fiddly, you first have to define something like this (evaluate in your tidal file with ctrl-enter):

let myShape = Shape {
      -- Define the parameters. The first bit is the type - S for
      -- string, F for float, I for integer. The second part is the
      -- name of the parameter. The third is the default value for the
      -- parameter (only used if 'namedParams' defined below is set to
      -- 'False', so set to Nothing here).
      params = [ S "thing" Nothing,
                 F "num1" Nothing,
                 F "num2" Nothing,
                 I "num3" Nothing
      -- Whether to add the current cycles per second to the message
      cpsStamp = True,
      -- How far ahead of time to send the message 
      latency = 0
    mySlang = OscSlang {
      -- the OSC 'path'
      path = "/note",
      -- Whether to timestamp the message with
      -- its logical time - can be 'BundleStamp'
      -- (put in a timestamped bundle),
      -- 'MessageStamp' (put in the message
      -- parameters), or 'NoStamp' (don't timestamp)
      timestamp = NoStamp,
      -- Whether to interleave the parameter
      -- names in the message. If this isn't
      -- set, all parameters will be sent, using
      -- defaults set above if they're not
      -- given in a tidal pattern
      namedParams = True,
      -- Parameters to stick on the beginning of
      -- a message
      preamble = []
    -- a function to start your OSC stream, where "" is the
    -- target host and 8010 the port number
    myStream = do
      s <- makeConnection "" 8010 mySlang
      stream (Backend s $ (\_ _ _ -> return ())) myShape
    -- pattern parameter functions, where makeS is for string, makeF for floats, and so on.
    -- Many parameter functions are already defined and don't need re-defining, see here:
    thing      = makeS myShape "thing"
    num1       = makeF myShape "num1"
    num2       = makeF myShape "num2"
    num3       = makeI myShape "num3"

You can then start one or more osc streams like this:

s1 <- myStream

Which you can then use like this:

s1 $ thing "hello" # num1 sine1 # num2 sine1 # num3 "1 2 3"
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-12-27 19:24:16 -0500

yaxu gravatar image

Actually the params bit is ignored completely if you have namedParams set to True, so can be an empty list (params = [])

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-12-27 18:51:15 -0500

Seen: 328 times

Last updated: Dec 27 '16