module Sound.Tidal.Stream.Main where
import Control.Concurrent (forkIO, newMVar)
import qualified Data.Map as Map
import qualified Sound.Tidal.Clock as Clock
import Sound.Tidal.Config
( Config (cCtrlAddr, cCtrlPort),
toClockConfig,
verbose,
)
import Sound.Tidal.Stream.Listen
( ctrlResponder,
openListener,
)
import Sound.Tidal.Stream.Process (doTick)
import Sound.Tidal.Stream.Target (getCXs, superdirtShape)
import Sound.Tidal.Stream.Types (OSC, Stream (..), Target)
import Sound.Tidal.Version (tidal_status_string)
import System.IO (hPutStrLn, stderr)
startTidal :: Target -> Config -> IO Stream
startTidal :: Target -> Config -> IO Stream
startTidal Target
target Config
config = Config -> [(Target, [OSC])] -> IO Stream
startStream Config
config [(Target
target, [OSC
superdirtShape])]
startStream :: Config -> [(Target, [OSC])] -> IO Stream
startStream :: Config -> [(Target, [OSC])] -> IO Stream
startStream Config
config [(Target, [OSC])]
oscmap = do
sMapMV <- Map String Value -> IO (MVar (Map String Value))
forall a. a -> IO (MVar a)
newMVar Map String Value
forall k a. Map k a
Map.empty
pMapMV <- newMVar Map.empty
globalFMV <- newMVar id
tidal_status_string >>= verbose config
verbose config $ "Listening for external controls on " ++ cCtrlAddr config ++ ":" ++ show (cCtrlPort config)
listen <- openListener config
cxs <- getCXs config oscmap
clockRef <- Clock.clocked (toClockConfig config) (doTick sMapMV pMapMV globalFMV cxs)
let stream =
Stream
{ sConfig :: Config
sConfig = Config
config,
sStateMV :: MVar (Map String Value)
sStateMV = MVar (Map String Value)
sMapMV,
sClockRef :: ClockRef
sClockRef = ClockRef
clockRef,
sListen :: Maybe Udp
sListen = Maybe Udp
listen,
sPMapMV :: MVar (Map String PlayState)
sPMapMV = MVar (Map String PlayState)
pMapMV,
sGlobalFMV :: MVar (ControlPattern -> ControlPattern)
sGlobalFMV = MVar (ControlPattern -> ControlPattern)
globalFMV,
sCxs :: [Cx]
sCxs = [Cx]
cxs
}
_ <- forkIO $ ctrlResponder config stream
return stream
startMulti :: [Target] -> Config -> IO ()
startMulti :: [Target] -> Config -> IO ()
startMulti [Target]
_ Config
_ = Handle -> String -> IO ()
hPutStrLn Handle
stderr String
"startMulti has been removed, please check the latest documentation on tidalcycles.org"