diff --git a/src/Sound/Tidal/Stream.hs b/src/Sound/Tidal/Stream.hs index 78949c47c..2397ee3d3 100644 --- a/src/Sound/Tidal/Stream.hs +++ b/src/Sound/Tidal/Stream.hs @@ -34,7 +34,8 @@ import Foreign import Foreign.C.Types import System.IO (hPutStrLn, stderr) -import qualified Sound.OSC.FD as O +import qualified Sound.Osc.Fd as O +import qualified Sound.Osc.Time.Timeout as O import qualified Network.Socket as N import Sound.Tidal.Config @@ -45,7 +46,6 @@ import Sound.Tidal.Params (pS) import Sound.Tidal.Pattern import qualified Sound.Tidal.Tempo as T import Sound.Tidal.Utils ((!!!)) --- import qualified Sound.OSC.Datum as O import Data.List (sortOn) import System.Random (getStdRandom, randomR) import Sound.Tidal.Show () @@ -59,7 +59,7 @@ data Stream = Stream {sConfig :: Config, sStateMV :: MVar ValueMap, -- sOutput :: MVar ControlPattern, sLink :: Link.AbletonLink, - sListen :: Maybe O.UDP, + sListen :: Maybe O.Udp, sPMapMV :: MVar PlayMap, sActionsMV :: MVar [T.TempoAction], sGlobalFMV :: MVar (ControlPattern -> ControlPattern), @@ -67,7 +67,7 @@ data Stream = Stream {sConfig :: Config, } data Cx = Cx {cxTarget :: Target, - cxUDP :: O.UDP, + cxUDP :: O.Udp, cxOSCs :: [OSC], cxAddr :: N.AddrInfo, cxBusAddr :: Maybe N.AddrInfo @@ -256,13 +256,13 @@ sendHandshakes stream = mapM_ sendHandshake $ filter (oHandshake . cxTarget) (sC else hPutStrLn stderr "Can't handshake with SuperCollider without control port." -sendO :: Bool -> (Maybe O.UDP) -> Cx -> O.Message -> IO () +sendO :: Bool -> (Maybe O.Udp) -> Cx -> O.Message -> IO () sendO isBusMsg (Just listen) cx msg = O.sendTo listen (O.Packet_Message msg) (N.addrAddress addr) where addr | isBusMsg && isJust (cxBusAddr cx) = fromJust $ cxBusAddr cx | otherwise = cxAddr cx sendO _ Nothing cx msg = O.sendMessage (cxUDP cx) msg -sendBndl :: Bool -> (Maybe O.UDP) -> Cx -> O.Bundle -> IO () +sendBndl :: Bool -> (Maybe O.Udp) -> Cx -> O.Bundle -> IO () sendBndl isBusMsg (Just listen) cx bndl = O.sendTo listen (O.Packet_Bundle bndl) (N.addrAddress addr) where addr | isBusMsg && isJust (cxBusAddr cx) = fromJust $ cxBusAddr cx | otherwise = cxAddr cx @@ -546,7 +546,7 @@ setPreviousPatternOrSilence stream = -- Send events early using timestamp in the OSC bundle - used by Superdirt -- Send events early by adding timestamp to the OSC message - used by Dirt -- Send events live by delaying the thread -send :: Maybe O.UDP -> Cx -> Double -> Double -> (Double, Bool, O.Message) -> IO () +send :: Maybe O.Udp -> Cx -> Double -> Double -> (Double, Bool, O.Message) -> IO () send listen cx latency extraLatency (time, isBusMsg, m) | oSchedule target == Pre BundleStamp = sendBndl isBusMsg listen cx $ O.Bundle timeWithLatency [m] | oSchedule target == Pre MessageStamp = sendO isBusMsg listen cx $ addtime m @@ -555,7 +555,7 @@ send listen cx latency extraLatency (time, isBusMsg, m) sendO isBusMsg listen cx m return () where addtime (O.Message mpath params) = O.Message mpath ((O.int32 sec):((O.int32 usec):params)) - ut = O.ntpr_to_ut timeWithLatency + ut = O.ntpr_to_posix timeWithLatency sec :: Int sec = floor ut usec :: Int @@ -659,7 +659,7 @@ streamSetB = streamSet streamSetR :: Stream -> String -> Pattern Rational -> IO () streamSetR = streamSet -openListener :: Config -> IO (Maybe O.UDP) +openListener :: Config -> IO (Maybe O.Udp) openListener c | cCtrlListen c = catchAny run (\_ -> do verbose c "That port isn't available, perhaps another Tidal instance is already listening on that port?" return Nothing @@ -693,16 +693,16 @@ ctrlResponder waits c (stream@(Stream {sListen = Just sock})) return () where bufferIndices [] = [] - bufferIndices (x:xs') | x == (O.ASCII_String $ O.ascii "&controlBusIndices") = catMaybes $ takeWhile isJust $ map O.datum_integral xs' + bufferIndices (x:xs') | x == (O.AsciiString $ O.ascii "&controlBusIndices") = catMaybes $ takeWhile isJust $ map O.datum_integral xs' | otherwise = bufferIndices xs' -- External controller commands act (O.Message "/ctrl" (O.Int32 k:v:[])) = act (O.Message "/ctrl" [O.string $ show k,v]) - act (O.Message "/ctrl" (O.ASCII_String k:v@(O.Float _):[])) + act (O.Message "/ctrl" (O.AsciiString k:v@(O.Float _):[])) = add (O.ascii_to_string k) (VF (fromJust $ O.datum_floating v)) - act (O.Message "/ctrl" (O.ASCII_String k:O.ASCII_String v:[])) + act (O.Message "/ctrl" (O.AsciiString k:O.AsciiString v:[])) = add (O.ascii_to_string k) (VS (O.ascii_to_string v)) - act (O.Message "/ctrl" (O.ASCII_String k:O.Int32 v:[])) + act (O.Message "/ctrl" (O.AsciiString k:O.Int32 v:[])) = add (O.ascii_to_string k) (VI (fromIntegral v)) -- Stream playback commands act (O.Message "/mute" (k:[])) @@ -729,7 +729,7 @@ ctrlResponder waits c (stream@(Stream {sListen = Just sock})) putMVar (sStateMV stream) $ Map.insert k v sMap return () withID :: O.Datum -> (ID -> IO ()) -> IO () - withID (O.ASCII_String k) func = func $ (ID . O.ascii_to_string) k + withID (O.AsciiString k) func = func $ (ID . O.ascii_to_string) k withID (O.Int32 k) func = func $ (ID . show) k withID _ _ = return () ctrlResponder _ _ _ = return () diff --git a/src/Sound/Tidal/Tempo.hs b/src/Sound/Tidal/Tempo.hs index 4820e6737..3b505158a 100644 --- a/src/Sound/Tidal/Tempo.hs +++ b/src/Sound/Tidal/Tempo.hs @@ -6,7 +6,7 @@ module Sound.Tidal.Tempo where import Control.Concurrent.MVar import qualified Sound.Tidal.Pattern as P -import qualified Sound.OSC.FD as O +import qualified Sound.Osc.Fd as O import Control.Concurrent (forkIO, ThreadId, threadDelay) import Control.Monad (when) import qualified Data.Map.Strict as Map @@ -39,7 +39,7 @@ import Sound.Tidal.StreamTypes along with this library. If not, see . -} -instance Show O.UDP where +instance Show O.Udp where show _ = "-unshowable-" type TransitionMapper = P.Time -> [P.ControlPattern] -> P.ControlPattern diff --git a/test/Sound/Tidal/StreamTest.hs b/test/Sound/Tidal/StreamTest.hs index 8241990ee..06dd610b9 100644 --- a/test/Sound/Tidal/StreamTest.hs +++ b/test/Sound/Tidal/StreamTest.hs @@ -5,7 +5,7 @@ module Sound.Tidal.StreamTest where import Test.Microspec import Sound.Tidal.Stream import Sound.Tidal.Pattern -import qualified Sound.OSC.FD as O +import qualified Sound.Osc.Fd as O import qualified Data.Map.Strict as M run :: Microspec () @@ -33,4 +33,4 @@ run = it "should work for params with fallback expressions" $ do getString (M.singleton "s" (VS "sn")) "s=bd" `shouldBe` Just "sn" it "should work for missing params with fallback expressions" $ do - getString M.empty "s=bd" `shouldBe` Just "bd" \ No newline at end of file + getString M.empty "s=bd" `shouldBe` Just "bd" diff --git a/tidal-listener/src/Sound/Tidal/Listener.hs b/tidal-listener/src/Sound/Tidal/Listener.hs index ce0d7c2bf..778653f80 100644 --- a/tidal-listener/src/Sound/Tidal/Listener.hs +++ b/tidal-listener/src/Sound/Tidal/Listener.hs @@ -8,7 +8,7 @@ import Sound.Tidal.ID import qualified Sound.Tidal.Context as T import Sound.Tidal.Hint import Sound.Tidal.Listener.Config -import Sound.OSC.FD as O +import Sound.Osc.Fd as O import Control.Concurrent import Control.Concurrent.MVar import qualified Network.Socket as N @@ -21,7 +21,7 @@ https://github.com/tidalcycles/tidal-listener/wiki data State = State {sIn :: MVar String, sOut :: MVar Response, - sLocal :: UDP, + sLocal :: Udp, sRemote :: N.SockAddr, sStream :: T.Stream } @@ -80,7 +80,7 @@ startHint = do mIn <- newEmptyMVar getcps st = streamGetcps (sStream st) act :: State -> Maybe O.Message -> IO State -act st (Just (Message "/code" [ASCII_String a_ident, ASCII_String a_code])) = +act st (Just (Message "/code" [AsciiString a_ident, AsciiString a_code])) = do let ident = ID $ ascii_to_string a_ident code = ascii_to_string a_code putMVar (sIn st) code diff --git a/tidal-listener/tidal-listener.cabal b/tidal-listener/tidal-listener.cabal index a7316fa62..f59365708 100644 --- a/tidal-listener/tidal-listener.cabal +++ b/tidal-listener/tidal-listener.cabal @@ -21,8 +21,8 @@ library Sound.Tidal.Hint build-depends: base, data-default, - tidal >=1.7.1, - hosc, + tidal ==1.9.3, + hosc >= 0.20 && < 0.21, hint, network default-language: Haskell2010 diff --git a/tidal.cabal b/tidal.cabal index fde8d0a6e..a25fb78a9 100644 --- a/tidal.cabal +++ b/tidal.cabal @@ -55,7 +55,7 @@ library base >=4.8 && <5 , containers < 0.7 , colour < 2.4 - , hosc >= 0.17 && < 0.20 + , hosc >= 0.20 && < 0.21 , text < 2.1 , parsec >= 3.1.12 && < 3.2 , network < 3.2 @@ -90,7 +90,7 @@ test-suite tests build-depends: base ==4.* , microspec >= 0.2.0.1 - , hosc >= 0.17 && < 0.20 + , hosc >= 0.20 && < 0.21 , containers , parsec , tidal