# OSC out of Tidal, ghc network error

**URL:** <https://uzu.lurk.org/t/osc-out-of-tidal-ghc-network-error/4143>\
**Category:** TidalCycles\
**Tags:** questions\
**Created:** [12 July 2022 00:23 UTC](https://uzu.lurk.org/t/osc-out-of-tidal-ghc-network-error/4143 "2022-07-12T00:23:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![beckstrom](https://uzu.lurk.org/user_avatar/uzu.lurk.org/beckstrom/32/1514_2.png) [@beckstrom](https://uzu.lurk.org/u/beckstrom)\
**Post date:** [12 July 2022 00:23 UTC](https://uzu.lurk.org/t/osc-out-of-tidal-ghc-network-error/4143/1 "2022-07-12T00:23:42Z")

</div>

I feel like I'm really close to getting Tidal to send OSC to SuperDirt AND a target on my local network (an iPad running TouchOSC)

I followed the tutorial [here](http://tidalcycles.org/docs/configuration/MIDIOSC/osc/) and looked through a number of threads here to get going.

I have an additional target set up and it's working fine - running `oscdrump` on the same computer Tidal is running on shows me I'm getting messages. But sending only works if the value of `oAddress` is set to "127.0.0.1," "" and "0.0.0.0".

But if I set the `oAddress` to anything else, like the IP of my iPad (10.0.0.243) I get this error when evaluating Tidal code in Emacs:

```haskell
ghc: Network.Socket.sendBufTo: invalid argument (Invalid argument) 

```

I hope that makes some sense!  
I figure I'm either 1) grossly misunderstanding this, 2) missing something here

Has anybody successfully sent OSC from Tidal to another computer on the local network?

---

<div class="post-metadata">

**Author:** ![yaxu](https://uzu.lurk.org/user_avatar/uzu.lurk.org/yaxu/32/2_2.png) [@yaxu](https://uzu.lurk.org/u/yaxu)\
**Post date:** [12 July 2022 21:19 UTC](https://uzu.lurk.org/t/osc-out-of-tidal-ghc-network-error/4143/2 "2022-07-12T21:19:56Z")

</div>

Ah yes there is a complication where tidal sends out OSC messages on the same address that it receives them. The easiest fix is to do set `cCtrlAddr` to 0.0.0.0, so it can receive and send OSC on any network. So when you start tidal pass in a config like:

```haskell
(defaultConfig {cCtrlAddr = "0.0.0.0"})

```

---

<div class="post-metadata">

**Author:** ![yaxu](https://uzu.lurk.org/user_avatar/uzu.lurk.org/yaxu/32/2_2.png) [@yaxu](https://uzu.lurk.org/u/yaxu)\
**Post date:** [13 July 2022 07:02 UTC](https://uzu.lurk.org/t/osc-out-of-tidal-ghc-network-error/4143/3 "2022-07-13T07:02:54Z")

</div>

I've made an issue about it here: [Sending to another computer needs a cCtrlAddr setting · Issue #926 · tidalcycles/Tidal · GitHub](https://github.com/tidalcycles/Tidal/issues/926)

---

<div class="post-metadata">

**Author:** ![beckstrom](https://uzu.lurk.org/user_avatar/uzu.lurk.org/beckstrom/32/1514_2.png) [@beckstrom](https://uzu.lurk.org/u/beckstrom)\
**Post date:** [13 July 2022 12:33 UTC](https://uzu.lurk.org/t/osc-out-of-tidal-ghc-network-error/4143/4 "2022-07-13T12:33:59Z")

</div>

ah thanks Alex! awesome, I'll give that a try

---

<div class="post-metadata">

**Author:** ![kaosbeat](https://uzu.lurk.org/user_avatar/uzu.lurk.org/kaosbeat/32/2343_2.png) [@kaosbeat](https://uzu.lurk.org/u/kaosbeat)\
**Post date:** [26 September 2022 22:57 UTC](https://uzu.lurk.org/t/osc-out-of-tidal-ghc-network-error/4143/5 "2022-09-26T22:57:58Z")

</div>

I tried to implement this to send OSC to a remote RPi but I keep getting errors. I added this to my `BootTidal.hs`

```haskell
:{
pivizTarget :: Target
pivizTarget = Target {oName = "piviz",
                       oAddress = "192.168.1.142",
                       oPort = 8007,
                       oBusPort = Nothing,
                       oLatency = 0.02,
                       oWindow = Nothing,
                       oSchedule = Live,
                       oHandshake = False
                      }
               
pivizShape :: OSC
pivizShape = OSC "/piviz" $ ArgList [("vizscene", required),
                                       ("vizcommand", sDefault "next"),
                                       ("vizsize", fDefault 32),
                                       ("vizspeed", fDefault 150)
                                      ]
:}

:{
let vizscene = pS "vizscene"
    vizcommand = pS "vizcommand"
    vizsize = pF "vizsize"
    vizspeed = pF "vizspeed"
:}

:{
  tidal <- startStream defaultConfig [
                                      (espeakTarget, [espeakShape]),
                                      (pivizTarget, [pivizShape]),
                                      (superdirtTarget {oLatency = 0.05, oAddress = "127.0.0.1", oPort = 57120}, [superdirtShape])
                                   ]
:}

-- tidal <- startTidal (superdirtTarget {oLatency = 0.05, oAddress = "127.0.0.1", oPort = 57120}) (defaultConfig {cVerbose = True, cFrameTimespan = 1/20})
tidal <- startTidal (superdirtTarget {oLatency = 0.05, oAddress = "127.0.0.1", oPort = 57120}) (defaultConfig {cVerbose = True, cFrameTimespan = 1/20, cCtrlAddr = "0.0.0.0"})

```

This will boot the server but still not let me connect to the RPi I want to send OSC data to.  
it outputs:

```haskell
Listening for external controls on 127.0.0.1:6010
Connected to SuperDirt.
[TidalCycles version 1.9.2]
Installed in /home/kaos/.cabal/share/x86_64-linux-ghc-9.0.2/tidal-1.9.2
Listening for external controls on 0.0.0.0:6010
That port isn't available, perhaps another Tidal instance is already listening on that port?
Can't handshake with SuperCollider without control port.

```

I tried fitting the `cCtrlAddr` in the `tidal <- startStream defaultConfig ` part but nomatter what I tried I would not boot... (syntax problems)

The espeak part works by the way, I started there and tried to adapt it to remote OSC, but no go...,

---

<div class="post-metadata">

**Author:** ![ndr\_brt](https://uzu.lurk.org/user_avatar/uzu.lurk.org/ndr_brt/32/396_2.png) [@ndr\_brt](https://uzu.lurk.org/u/ndr_brt)\
**Post date:** [27 September 2022 16:56 UTC](https://uzu.lurk.org/t/osc-out-of-tidal-ghc-network-error/4143/6 "2022-09-27T16:56:46Z")

</div>

Try to comment the last line as well, as here you are starting two tidalcycles

---

<div class="post-metadata">

**Author:** ![yaxu](https://uzu.lurk.org/user_avatar/uzu.lurk.org/yaxu/32/2_2.png) [@yaxu](https://uzu.lurk.org/u/yaxu)\
**Post date:** [28 September 2022 07:09 UTC](https://uzu.lurk.org/t/osc-out-of-tidal-ghc-network-error/4143/7 "2022-09-28T07:09:54Z")

</div>

Yes `startStream` should replace `startTidal` here.

The first instance (from startStream) starts saying `Listening for external controls on 127.0.0.1:6010`. This is not only the port it's listening to, but also the one it's sending OSC _from_. So it's trying to send OSC from the localhost network to the external network, which will fail. So yep you need to add that `cCtrlAddr` part to the `startStream` call.

Try solving the syntax error with parenthesis, link:  
`startStream (defaultConfig {cCtrlAddr = "0.0.0.0"}) [ `

---

<div class="post-metadata">

**Author:** ![kaosbeat](https://uzu.lurk.org/user_avatar/uzu.lurk.org/kaosbeat/32/2343_2.png) [@kaosbeat](https://uzu.lurk.org/u/kaosbeat)\
**Post date:** [28 September 2022 11:31 UTC](https://uzu.lurk.org/t/osc-out-of-tidal-ghc-network-error/4143/8 "2022-09-28T11:31:27Z")

</div>

that indeed solves it. I had no Idea how to expand the `defaultConfig` parameter.  
I copied in the `cVerbose = True, cFrameTimespan = 1/20` attributes as well, as I did not know what would happen if they are left out.  
final `startStream` call looks like this:

```haskell
:{
  tidal <- startStream (defaultConfig {cVerbose = True, cFrameTimespan = 1/20, cCtrlAddr = "0.0.0.0"}) [
                                      (espeakTarget, [espeakShape]),
                                      (pivizTarget, [pivizShape]),
                                      (superdirtTarget {oLatency = 0.05, oAddress = "127.0.0.1", oPort = 57120}, [superdirtShape])
                                   ]
:}

```

Sending data also works now!

---

<div class="post-metadata">

**Author:** ![yaxu](https://uzu.lurk.org/user_avatar/uzu.lurk.org/yaxu/32/2_2.png) [@yaxu](https://uzu.lurk.org/u/yaxu)\
**Post date:** [29 September 2022 15:00 UTC](https://uzu.lurk.org/t/osc-out-of-tidal-ghc-network-error/4143/9 "2022-09-29T15:00:21Z")

</div>

Great! I've [made a note](https://github.com/tidalcycles/Tidal/issues/954) to update the default BootTidal.hs so it uses the newer/more flexible `startStream` function rather than `startTidal`, and generally make it easier to edit..

I think `cVerbose = True, cFrameTimespan = 1/20` are the default value but of course it does no harm to define them.
