Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 1406416

Browse files
authored
support for hosc-0.20 (#981)
1 parent 58fab23 commit 1406416

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

src/Sound/Tidal/Stream.hs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import Foreign
3434
import Foreign.C.Types
3535
import System.IO (hPutStrLn, stderr)
3636

37-
import qualified Sound.OSC.FD as O
37+
import qualified Sound.Osc.Fd as O
38+
import qualified Sound.Osc.Time.Timeout as O
3839
import qualified Network.Socket as N
3940

4041
import Sound.Tidal.Config
@@ -45,7 +46,6 @@ import Sound.Tidal.Params (pS)
4546
import Sound.Tidal.Pattern
4647
import qualified Sound.Tidal.Tempo as T
4748
import Sound.Tidal.Utils ((!!!))
48-
-- import qualified Sound.OSC.Datum as O
4949
import Data.List (sortOn)
5050
import System.Random (getStdRandom, randomR)
5151
import Sound.Tidal.Show ()
@@ -59,15 +59,15 @@ data Stream = Stream {sConfig :: Config,
5959
sStateMV :: MVar ValueMap,
6060
-- sOutput :: MVar ControlPattern,
6161
sLink :: Link.AbletonLink,
62-
sListen :: Maybe O.UDP,
62+
sListen :: Maybe O.Udp,
6363
sPMapMV :: MVar PlayMap,
6464
sActionsMV :: MVar [T.TempoAction],
6565
sGlobalFMV :: MVar (ControlPattern -> ControlPattern),
6666
sCxs :: [Cx]
6767
}
6868

6969
data Cx = Cx {cxTarget :: Target,
70-
cxUDP :: O.UDP,
70+
cxUDP :: O.Udp,
7171
cxOSCs :: [OSC],
7272
cxAddr :: N.AddrInfo,
7373
cxBusAddr :: Maybe N.AddrInfo
@@ -256,13 +256,13 @@ sendHandshakes stream = mapM_ sendHandshake $ filter (oHandshake . cxTarget) (sC
256256
else
257257
hPutStrLn stderr "Can't handshake with SuperCollider without control port."
258258

259-
sendO :: Bool -> (Maybe O.UDP) -> Cx -> O.Message -> IO ()
259+
sendO :: Bool -> (Maybe O.Udp) -> Cx -> O.Message -> IO ()
260260
sendO isBusMsg (Just listen) cx msg = O.sendTo listen (O.Packet_Message msg) (N.addrAddress addr)
261261
where addr | isBusMsg && isJust (cxBusAddr cx) = fromJust $ cxBusAddr cx
262262
| otherwise = cxAddr cx
263263
sendO _ Nothing cx msg = O.sendMessage (cxUDP cx) msg
264264

265-
sendBndl :: Bool -> (Maybe O.UDP) -> Cx -> O.Bundle -> IO ()
265+
sendBndl :: Bool -> (Maybe O.Udp) -> Cx -> O.Bundle -> IO ()
266266
sendBndl isBusMsg (Just listen) cx bndl = O.sendTo listen (O.Packet_Bundle bndl) (N.addrAddress addr)
267267
where addr | isBusMsg && isJust (cxBusAddr cx) = fromJust $ cxBusAddr cx
268268
| otherwise = cxAddr cx
@@ -546,7 +546,7 @@ setPreviousPatternOrSilence stream =
546546
-- Send events early using timestamp in the OSC bundle - used by Superdirt
547547
-- Send events early by adding timestamp to the OSC message - used by Dirt
548548
-- Send events live by delaying the thread
549-
send :: Maybe O.UDP -> Cx -> Double -> Double -> (Double, Bool, O.Message) -> IO ()
549+
send :: Maybe O.Udp -> Cx -> Double -> Double -> (Double, Bool, O.Message) -> IO ()
550550
send listen cx latency extraLatency (time, isBusMsg, m)
551551
| oSchedule target == Pre BundleStamp = sendBndl isBusMsg listen cx $ O.Bundle timeWithLatency [m]
552552
| oSchedule target == Pre MessageStamp = sendO isBusMsg listen cx $ addtime m
@@ -555,7 +555,7 @@ send listen cx latency extraLatency (time, isBusMsg, m)
555555
sendO isBusMsg listen cx m
556556
return ()
557557
where addtime (O.Message mpath params) = O.Message mpath ((O.int32 sec):((O.int32 usec):params))
558-
ut = O.ntpr_to_ut timeWithLatency
558+
ut = O.ntpr_to_posix timeWithLatency
559559
sec :: Int
560560
sec = floor ut
561561
usec :: Int
@@ -659,7 +659,7 @@ streamSetB = streamSet
659659
streamSetR :: Stream -> String -> Pattern Rational -> IO ()
660660
streamSetR = streamSet
661661

662-
openListener :: Config -> IO (Maybe O.UDP)
662+
openListener :: Config -> IO (Maybe O.Udp)
663663
openListener c
664664
| cCtrlListen c = catchAny run (\_ -> do verbose c "That port isn't available, perhaps another Tidal instance is already listening on that port?"
665665
return Nothing
@@ -693,16 +693,16 @@ ctrlResponder waits c (stream@(Stream {sListen = Just sock}))
693693
return ()
694694
where
695695
bufferIndices [] = []
696-
bufferIndices (x:xs') | x == (O.ASCII_String $ O.ascii "&controlBusIndices") = catMaybes $ takeWhile isJust $ map O.datum_integral xs'
696+
bufferIndices (x:xs') | x == (O.AsciiString $ O.ascii "&controlBusIndices") = catMaybes $ takeWhile isJust $ map O.datum_integral xs'
697697
| otherwise = bufferIndices xs'
698698
-- External controller commands
699699
act (O.Message "/ctrl" (O.Int32 k:v:[]))
700700
= act (O.Message "/ctrl" [O.string $ show k,v])
701-
act (O.Message "/ctrl" (O.ASCII_String k:v@(O.Float _):[]))
701+
act (O.Message "/ctrl" (O.AsciiString k:v@(O.Float _):[]))
702702
= add (O.ascii_to_string k) (VF (fromJust $ O.datum_floating v))
703-
act (O.Message "/ctrl" (O.ASCII_String k:O.ASCII_String v:[]))
703+
act (O.Message "/ctrl" (O.AsciiString k:O.AsciiString v:[]))
704704
= add (O.ascii_to_string k) (VS (O.ascii_to_string v))
705-
act (O.Message "/ctrl" (O.ASCII_String k:O.Int32 v:[]))
705+
act (O.Message "/ctrl" (O.AsciiString k:O.Int32 v:[]))
706706
= add (O.ascii_to_string k) (VI (fromIntegral v))
707707
-- Stream playback commands
708708
act (O.Message "/mute" (k:[]))
@@ -729,7 +729,7 @@ ctrlResponder waits c (stream@(Stream {sListen = Just sock}))
729729
putMVar (sStateMV stream) $ Map.insert k v sMap
730730
return ()
731731
withID :: O.Datum -> (ID -> IO ()) -> IO ()
732-
withID (O.ASCII_String k) func = func $ (ID . O.ascii_to_string) k
732+
withID (O.AsciiString k) func = func $ (ID . O.ascii_to_string) k
733733
withID (O.Int32 k) func = func $ (ID . show) k
734734
withID _ _ = return ()
735735
ctrlResponder _ _ _ = return ()

src/Sound/Tidal/Tempo.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Sound.Tidal.Tempo where
66

77
import Control.Concurrent.MVar
88
import qualified Sound.Tidal.Pattern as P
9-
import qualified Sound.OSC.FD as O
9+
import qualified Sound.Osc.Fd as O
1010
import Control.Concurrent (forkIO, ThreadId, threadDelay)
1111
import Control.Monad (when)
1212
import qualified Data.Map.Strict as Map
@@ -39,7 +39,7 @@ import Sound.Tidal.StreamTypes
3939
along with this library. If not, see <http://www.gnu.org/licenses/>.
4040
-}
4141

42-
instance Show O.UDP where
42+
instance Show O.Udp where
4343
show _ = "-unshowable-"
4444

4545
type TransitionMapper = P.Time -> [P.ControlPattern] -> P.ControlPattern

test/Sound/Tidal/StreamTest.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Sound.Tidal.StreamTest where
55
import Test.Microspec
66
import Sound.Tidal.Stream
77
import Sound.Tidal.Pattern
8-
import qualified Sound.OSC.FD as O
8+
import qualified Sound.Osc.Fd as O
99
import qualified Data.Map.Strict as M
1010

1111
run :: Microspec ()
@@ -33,4 +33,4 @@ run =
3333
it "should work for params with fallback expressions" $ do
3434
getString (M.singleton "s" (VS "sn")) "s=bd" `shouldBe` Just "sn"
3535
it "should work for missing params with fallback expressions" $ do
36-
getString M.empty "s=bd" `shouldBe` Just "bd"
36+
getString M.empty "s=bd" `shouldBe` Just "bd"

tidal-listener/src/Sound/Tidal/Listener.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Sound.Tidal.ID
88
import qualified Sound.Tidal.Context as T
99
import Sound.Tidal.Hint
1010
import Sound.Tidal.Listener.Config
11-
import Sound.OSC.FD as O
11+
import Sound.Osc.Fd as O
1212
import Control.Concurrent
1313
import Control.Concurrent.MVar
1414
import qualified Network.Socket as N
@@ -21,7 +21,7 @@ https://github.com/tidalcycles/tidal-listener/wiki
2121

2222
data State = State {sIn :: MVar String,
2323
sOut :: MVar Response,
24-
sLocal :: UDP,
24+
sLocal :: Udp,
2525
sRemote :: N.SockAddr,
2626
sStream :: T.Stream
2727
}
@@ -80,7 +80,7 @@ startHint = do mIn <- newEmptyMVar
8080
getcps st = streamGetcps (sStream st)
8181

8282
act :: State -> Maybe O.Message -> IO State
83-
act st (Just (Message "/code" [ASCII_String a_ident, ASCII_String a_code])) =
83+
act st (Just (Message "/code" [AsciiString a_ident, AsciiString a_code])) =
8484
do let ident = ID $ ascii_to_string a_ident
8585
code = ascii_to_string a_code
8686
putMVar (sIn st) code

tidal-listener/tidal-listener.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ library
2121
Sound.Tidal.Hint
2222
build-depends: base,
2323
data-default,
24-
tidal >=1.7.1,
25-
hosc,
24+
tidal ==1.9.3,
25+
hosc >= 0.20 && < 0.21,
2626
hint,
2727
network
2828
default-language: Haskell2010

tidal.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ library
5555
base >=4.8 && <5
5656
, containers < 0.7
5757
, colour < 2.4
58-
, hosc >= 0.17 && < 0.20
58+
, hosc >= 0.20 && < 0.21
5959
, text < 2.1
6060
, parsec >= 3.1.12 && < 3.2
6161
, network < 3.2
@@ -90,7 +90,7 @@ test-suite tests
9090
build-depends:
9191
base ==4.*
9292
, microspec >= 0.2.0.1
93-
, hosc >= 0.17 && < 0.20
93+
, hosc >= 0.20 && < 0.21
9494
, containers
9595
, parsec
9696
, tidal

0 commit comments

Comments
 (0)