From 6dff012567c9536a7c161ca65abb0a5b433251af Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 28 Jan 2022 14:10:49 +0000 Subject: [PATCH 1/6] broadcast on --- src/Sound/Tidal/Stream.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Sound/Tidal/Stream.hs b/src/Sound/Tidal/Stream.hs index beae614d3..65d189ce6 100644 --- a/src/Sound/Tidal/Stream.hs +++ b/src/Sound/Tidal/Stream.hs @@ -630,6 +630,7 @@ openListener c | otherwise = return Nothing where run = do sock <- O.udpServer (cCtrlAddr c) (cCtrlPort c) + N.setSocketOption (O.udpSocket sock) N.Broadcast 1 return $ Just sock catchAny :: IO a -> (E.SomeException -> IO a) -> IO a catchAny = E.catch From f70cc26ff1bb19d22d3d632cff268a74121b059e Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 28 Jan 2022 17:38:55 +0000 Subject: [PATCH 2/6] allow sending to broadcast --- src/Sound/Tidal/Stream.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Sound/Tidal/Stream.hs b/src/Sound/Tidal/Stream.hs index 65d189ce6..1248854b1 100644 --- a/src/Sound/Tidal/Stream.hs +++ b/src/Sound/Tidal/Stream.hs @@ -202,7 +202,10 @@ startStream config oscmap remote_bus_addr <- if isJust $ oBusPort target then Just <$> resolve (oAddress target) (show $ fromJust $ oBusPort target) else return Nothing - u <- O.openUDP (oAddress target) (oPort target) + --u <- O.openUDP (oAddress target) (oPort target) + u <- O.udp_socket (\sock sockaddr -> do N.setSocketOption sock N.Broadcast 1 + N.connect sock sockaddr + ) (oAddress target) (oPort target) return $ Cx {cxUDP = u, cxAddr = remote_addr, cxBusAddr = remote_bus_addr, cxTarget = target, cxOSCs = os} ) oscmap let stream = Stream {sConfig = config, From e7f7633fd5ae2d9b31a745e3ee7e5dc89b17002a Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 28 Jan 2022 17:39:19 +0000 Subject: [PATCH 3/6] broadcast ctrlTarget --- BootTidal.hs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/BootTidal.hs b/BootTidal.hs index f2d3026eb..57f74e1a2 100644 --- a/BootTidal.hs +++ b/BootTidal.hs @@ -6,8 +6,32 @@ import Sound.Tidal.Context import System.IO (hSetEncoding, stdout, utf8) hSetEncoding stdout utf8 +:{ +ctrlTarget :: Target +ctrlTarget = Target {oName = "Ctrl", + oAddress = "192.168.0.255", + oPort = 6010, + oBusPort = Nothing, + oLatency = 0, + oWindow = Nothing, + oSchedule = Live, + oHandshake = False + } +:} + +:{ +ctrlShape :: OSC +ctrlShape = OSC "/ctrl" $ ArgList [("name", required), + ("val", sDefault "") + ] +:} + -- total latency = oLatency + cFrameTimespan -tidal <- startTidal (superdirtTarget {oLatency = 0.1, oAddress = "127.0.0.1", oPort = 57120}) (defaultConfig {cVerbose = True, cFrameTimespan = 1/20}) +--tidal <- startTidal (superdirtTarget {oLatency = 0.1, oAddress = "127.0.0.1", oPort = 57120}) (default) + +c = defaultConfig {cCtrlAddr = "0.0.0.0",cVerbose = True, cFrameTimespan = 1/20} +sd = superdirtTarget {oLatency = 0.1, oAddress = "127.0.0.1", oPort = 57120} +tidal <- startStream c [(sd, [superdirtShape]), (ctrlTarget, [ctrlShape])] :{ let only = (hush >>) From d50d8159c5a28d4de755622f44fd1f61c7724a91 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 9 Feb 2022 14:38:53 +0000 Subject: [PATCH 4/6] Undo customisations --- BootTidal.hs | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/BootTidal.hs b/BootTidal.hs index 57f74e1a2..b01b7f551 100644 --- a/BootTidal.hs +++ b/BootTidal.hs @@ -6,32 +6,8 @@ import Sound.Tidal.Context import System.IO (hSetEncoding, stdout, utf8) hSetEncoding stdout utf8 -:{ -ctrlTarget :: Target -ctrlTarget = Target {oName = "Ctrl", - oAddress = "192.168.0.255", - oPort = 6010, - oBusPort = Nothing, - oLatency = 0, - oWindow = Nothing, - oSchedule = Live, - oHandshake = False - } -:} - -:{ -ctrlShape :: OSC -ctrlShape = OSC "/ctrl" $ ArgList [("name", required), - ("val", sDefault "") - ] -:} - -- total latency = oLatency + cFrameTimespan ---tidal <- startTidal (superdirtTarget {oLatency = 0.1, oAddress = "127.0.0.1", oPort = 57120}) (default) - -c = defaultConfig {cCtrlAddr = "0.0.0.0",cVerbose = True, cFrameTimespan = 1/20} -sd = superdirtTarget {oLatency = 0.1, oAddress = "127.0.0.1", oPort = 57120} -tidal <- startStream c [(sd, [superdirtShape]), (ctrlTarget, [ctrlShape])] +tidal <- startTidal (superdirtTarget {oLatency = 0.1, oAddress = "127.0.0.1", oPort = 57120}) (default) :{ let only = (hush >>) From 95ff606be3d866d0dcebac3e63041ff346dee37e Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 9 Feb 2022 14:39:39 +0000 Subject: [PATCH 5/6] oops --- BootTidal.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BootTidal.hs b/BootTidal.hs index b01b7f551..f2d3026eb 100644 --- a/BootTidal.hs +++ b/BootTidal.hs @@ -7,7 +7,7 @@ import System.IO (hSetEncoding, stdout, utf8) hSetEncoding stdout utf8 -- total latency = oLatency + cFrameTimespan -tidal <- startTidal (superdirtTarget {oLatency = 0.1, oAddress = "127.0.0.1", oPort = 57120}) (default) +tidal <- startTidal (superdirtTarget {oLatency = 0.1, oAddress = "127.0.0.1", oPort = 57120}) (defaultConfig {cVerbose = True, cFrameTimespan = 1/20}) :{ let only = (hush >>) From a05892257b5be001d1161b9b0849395f11cf5ef7 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 9 Feb 2022 14:46:44 +0000 Subject: [PATCH 6/6] Make accepting/sending broadcast control messages optional --- src/Sound/Tidal/Config.hs | 2 ++ src/Sound/Tidal/Stream.hs | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Sound/Tidal/Config.hs b/src/Sound/Tidal/Config.hs index 300f6dce3..9f468d421 100644 --- a/src/Sound/Tidal/Config.hs +++ b/src/Sound/Tidal/Config.hs @@ -21,6 +21,7 @@ module Sound.Tidal.Config where data Config = Config {cCtrlListen :: Bool, cCtrlAddr :: String, cCtrlPort :: Int, + cCtrlBroadcast :: Bool, cFrameTimespan :: Double, cTempoAddr :: String, cTempoPort :: Int, @@ -33,6 +34,7 @@ defaultConfig :: Config defaultConfig = Config {cCtrlListen = True, cCtrlAddr ="127.0.0.1", cCtrlPort = 6010, + cCtrlBroadcast = False, cFrameTimespan = 1/20, cTempoAddr = "127.0.0.1", cTempoPort = 9160, diff --git a/src/Sound/Tidal/Stream.hs b/src/Sound/Tidal/Stream.hs index 1248854b1..95ac40279 100644 --- a/src/Sound/Tidal/Stream.hs +++ b/src/Sound/Tidal/Stream.hs @@ -202,8 +202,8 @@ startStream config oscmap remote_bus_addr <- if isJust $ oBusPort target then Just <$> resolve (oAddress target) (show $ fromJust $ oBusPort target) else return Nothing - --u <- O.openUDP (oAddress target) (oPort target) - u <- O.udp_socket (\sock sockaddr -> do N.setSocketOption sock N.Broadcast 1 + let broadcast = if cCtrlBroadcast config then 1 else 0 + u <- O.udp_socket (\sock sockaddr -> do N.setSocketOption sock N.Broadcast broadcast N.connect sock sockaddr ) (oAddress target) (oPort target) return $ Cx {cxUDP = u, cxAddr = remote_addr, cxBusAddr = remote_bus_addr, cxTarget = target, cxOSCs = os} @@ -633,7 +633,7 @@ openListener c | otherwise = return Nothing where run = do sock <- O.udpServer (cCtrlAddr c) (cCtrlPort c) - N.setSocketOption (O.udpSocket sock) N.Broadcast 1 + when (cCtrlBroadcast c) $ N.setSocketOption (O.udpSocket sock) N.Broadcast 1 return $ Just sock catchAny :: IO a -> (E.SomeException -> IO a) -> IO a catchAny = E.catch