Skip to content

Instantly share code, notes, and snippets.

@moxuse

moxuse/UnityOsc.hs

Created Jan 6, 2017
Embed
What would you like to do?
UnityOsc.hs
-- custom osc send to unity
module UnityOsc where
import Sound.Tidal.Stream
import Sound.Tidal.Pattern
import Sound.Tidal.Parse
import Sound.Tidal.OscStream
port = 5000
testShape = Shape {
params = [
S "thing" Nothing,
F "x" (Just 0),
F "y" (Just 0),
F "z" (Just 0),
F "duration" (Just 0.5)
],
cpsStamp = True,
latency = 0.02
}
testSlang = OscSlang {
path = "/unity_osc",
timestamp = NoStamp,
namedParams = False,
preamble = []
}
testStream = do
s <- makeConnection "127.0.0.1" port testSlang
stream (Backend s $ (\_ _ _ -> return ())) testShape
thing = makeS testShape "thing"
x = makeF testShape "x"
y = makeF testShape "y"
z = makeF testShape "z"
duration = makeF testShape "duration"
@moxuse

This comment has been minimized.

Copy link
Owner Author

@moxuse moxuse commented Jan 6, 2017

then when boot tidal,

:load UnityOsc

v1 <- testStream
@moxuse

This comment has been minimized.

Copy link
Owner Author

@moxuse moxuse commented Jan 7, 2017

Using with other connections,
I don't know this is the correct way, but import Sound.Tidal.Context
after other import lines, it will work.

module UnityOsc where
import Sound.Tidal.Stream
import Sound.Tidal.Pattern
import Sound.Tidal.Parse
import Sound.Tidal.OscStream
import Sound.Tidal.Context

then when boot tidal

:load UnityOsc

v1 <- testStream

and ghci

d1 ...

v1 ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment